]> git.openstreetmap.org Git - chef.git/blob - cookbooks/munin/files/default/plugins/passenger_queues
Make replication delay monitoring more reliable
[chef.git] / cookbooks / munin / files / default / plugins / passenger_queues
1 #!/usr/bin/env ruby
2
3 require "English"
4 require "rexml/document"
5
6 def passenger_status
7   @passenger_status ||= REXML::Document.new(`/usr/sbin/passenger-status --show=xml`)
8 end
9
10 def output_config
11   puts <<~CONFIG
12     graph_args --lower-limit 0
13     graph_category passenger
14     graph_title Passenger queues
15     graph_vlabel count
16
17     global.label global
18     global.draw AREA
19   CONFIG
20
21   groups = passenger_status.get_elements("//supergroup").map do |supergroup|
22     supergroup.text("name")
23   end
24
25   groups.sort.each do |name|
26     puts "#{name}.label #{name}"
27     puts "#{name}.draw STACK"
28   end
29 end
30
31 def output_values
32   global = passenger_status.text("/item/get_wait_list").to_i
33
34   puts "global.value #{global}"
35
36   passenger_status.get_elements("//supergroup").each do |supergroup|
37     name = supergroup.text("name")
38     queue = supergroup.text("get_wait_list").to_i
39
40     puts "#{name}.value #{queue}"
41   end
42 end
43
44 if ARGV[0] == "config"
45   output_config
46 else
47   output_values
48 end