]> git.openstreetmap.org Git - chef.git/blob - cookbooks/munin/files/default/plugins/passenger_queues
Rework passenger munin plugins to work with current passenger versions
[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_category passenger
13     graph_title Passenger queues
14     graph_vlabel count
15
16     global.label global
17     global.draw AREA
18   CONFIG
19
20   groups = passenger_status.get_elements("//supergroup").map do |supergroup|
21     supergroup.text("name")
22   end
23
24   groups.sort.each do |name|
25     puts "#{name}.label #{name}"
26     puts "#{name}.draw STACK"
27   end
28 end
29
30 def output_values
31   global = passenger_status.text("/item/get_wait_list").to_i
32
33   puts "global.value #{global}"
34
35   passenger_status.get_elements("//supergroup").each do |supergroup|
36     name = supergroup.text("name")
37     queue = supergroup.text("get_wait_list").to_i
38
39     puts "#{name}.value #{queue}"
40   end
41 end
42
43 if ARGV[0] == "config"
44   output_config
45 else
46   output_values
47 end