Skip to content

Instantly share code, notes, and snippets.

@dacort
Created November 7, 2009 20:12
Show Gist options
  • Save dacort/228868 to your computer and use it in GitHub Desktop.
Save dacort/228868 to your computer and use it in GitHub Desktop.
A munin script to monitor starling queues via starling_top
#!/usr/bin/env ruby
#
# A munin script to monitor starling queues via starling_top
# Damon P. Cortesi (@dacort)
def output_config(queue_items)
puts <<-END
graph_category App
graph_title starling queues
graph_vlabel count
#{queue_items.split("\n").select{|x| x !~ /(expired|total)_items/}.collect{|x| x.split("__")[0].gsub(/^queue_/, "").split('_').map {|w| w.capitalize}.join}.collect{|x| "#{x}.label #{x}"}.join("\n")}
END
exit 0
end
def output_values(queue_items)
queue_items.split("\n").select{|x| x !~ /(expired|total)_items/}.each do |x|
x =~ /queue_(\w+)__\w+: (\d+)/
queue,val = $1,$2
puts "#{queue.split('_').map {|w| w.capitalize}.join}.value #{val}"
end
end
queue_items = `/usr/bin/starling_top -p 15151 | grep -E "^queue_.*_items"`
unless $?.success?
$stderr.puts "failed executing starling_top"
exit 1
end
if ARGV[0] == "config"
output_config queue_items
else
output_values queue_items
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment