]> git.openstreetmap.org Git - chef.git/blob - cookbooks/munin/files/default/plugins/passenger_processes
Fix munin replication plugin to work with osmium based state
[chef.git] / cookbooks / munin / files / default / plugins / passenger_processes
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 processes
15     graph_order active inactive
16     graph_vlabel processes
17     graph_total total
18
19     active.label busy servers
20     active.draw AREA
21     inactive.label idle servers
22     inactive.draw STACK
23   CONFIG
24   exit 0
25 end
26
27 def output_values
28   active = 0
29   inactive = 0
30
31   passenger_status.get_elements("//process").each do |process|
32     if process.text("sessions").to_i.positive?
33       active += 1
34     else
35       inactive += 1
36     end
37   end
38
39   puts "active.value #{active}"
40   puts "inactive.value #{inactive}"
41 end
42
43 if ARGV[0] == "config"
44   output_config
45 else
46   output_values
47 end