topfunky (owner)

Fork Of

Revisions

gist: 169876 Download_button fork
public
Description:
Munin plugin for beanstalk queue
Public Clone URL: git://gist.github.com/169876.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/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