Skip to content

Instantly share code, notes, and snippets.

@topfunky
Forked from wmoxam/gist:36116
Created August 18, 2009 18:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save topfunky/169876 to your computer and use it in GitHub Desktop.
Save topfunky/169876 to your computer and use it in GitHub Desktop.
Munin plugin for beanstalk queue
#!/opt/ruby-enterprise/bin/ruby
# MODIFIED: Minor fork to run smoothly under Ruby 1.8.6. Heredoc cleanup.
require 'rubygems'
require 'beanstalk-client'
if ARGV.length > 0 && ARGV[0] == 'config'
puts <<-END
graph_category App
graph_title Beanstalk Queue Size
graph_vlabel watching
watching.label Watching
graph_vlabel reserved
reserved.label Reserved
graph_vlabel ready
ready.label Ready
graph_vlabel using
using.label Using
graph_vlabel buried
buried.label Buried
graph_vlabel waiting
waiting.label Waiting
graph_vlabel delayed
delayed.label Delayed
graph_vlabel urgent
urgent.label Urgent
END
exit(0)
end
B = Beanstalk::Connection.new 'localhost:11300'
tubes = B.list_tubes
stats = {
'current-watching' => 0,
'current-jobs-reserved' => 0,
'current-jobs-ready' => 0,
'current-using' => 0,
'current-jobs-buried' => 0,
'current-waiting' => 0,
'current-jobs-delayed' => 0,
'current-jobs-urgent' => 0
}
tubes.each do |tube|
ts = B.stats_tube(tube)
ts.keys.sort.each do |key|
next unless stats.has_key?(key)
stats[key] += ts[key]
end
end
stats.each do |name, value|
puts "#{name.split('-').last}.value #{value}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment