X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/7b9ec4b60ee39614d1d083d7220e76b07d2b275f..27968a88f8d7fcc542cee54ebc9d66093564fda4:/cookbooks/munin/files/default/plugins/passenger_processes?ds=sidebyside diff --git a/cookbooks/munin/files/default/plugins/passenger_processes b/cookbooks/munin/files/default/plugins/passenger_processes index d89d0412e..863ff8610 100755 --- a/cookbooks/munin/files/default/plugins/passenger_processes +++ b/cookbooks/munin/files/default/plugins/passenger_processes @@ -1,32 +1,43 @@ #!/usr/bin/env ruby +require "English" +require "rexml/document" + +def passenger_status + @passenger_status ||= REXML::Document.new(`/usr/sbin/passenger-status --show=xml`) +end + def output_config - puts <<-END -graph_category passenger -graph_title Passenger processes -graph_order active inactive -graph_vlabel processes -graph_total total - -active.label busy servers -active.draw AREA -inactive.label idle servers -inactive.draw STACK -END + puts <<~CONFIG + graph_args --lower-limit 0 + graph_category passenger + graph_title Passenger processes + graph_order active inactive + graph_vlabel processes + graph_total total + + active.label busy servers + active.draw AREA + inactive.label idle servers + inactive.draw STACK + CONFIG exit 0 end def output_values - status = `/usr/sbin/passenger-status` - unless $?.success? - $stderr.puts "failed executing passenger-status" - exit 1 + active = 0 + inactive = 0 + + passenger_status.get_elements("//process").each do |process| + if process.text("sessions").to_i.positive? + active += 1 + else + inactive += 1 + end end - status =~ /active\s+=\s+(\d+)/ - puts "active.value #{$1}" - status =~ /inactive\s+=\s+(\d+)/ - puts "inactive.value #{$1}" + puts "active.value #{active}" + puts "inactive.value #{inactive}" end if ARGV[0] == "config"