Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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
Add Comment
Please, Sign In to add comment