]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/munin/files/default/plugins/passenger_processes
Make replication delay monitoring more reliable
[chef.git] / cookbooks / munin / files / default / plugins / passenger_processes
index 0611ccc0e7ac4f54a5f2fa3e45b04bdf00a4fa64..863ff86106bbca36d533ea9d6e52bd0157acee39 100755 (executable)
@@ -1,9 +1,15 @@
 #!/usr/bin/env ruby
 
 require "English"
 #!/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 <<~CONFIG
 
 def output_config
   puts <<~CONFIG
+    graph_args --lower-limit 0
     graph_category passenger
     graph_title Passenger processes
     graph_order active inactive
     graph_category passenger
     graph_title Passenger processes
     graph_order active inactive
@@ -19,16 +25,19 @@ def output_config
 end
 
 def output_values
 end
 
 def output_values
-  status = `/usr/sbin/passenger-status`
-  unless $CHILD_STATUS.success?
-    warn "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
   end
-  status =~ /active\s+=\s+(\d+)/
-  puts "active.value #{Regexp.last_match[1]}"
 
 
-  status =~ /inactive\s+=\s+(\d+)/
-  puts "inactive.value #{Regexp.last_match[1]}"
+  puts "active.value #{active}"
+  puts "inactive.value #{inactive}"
 end
 
 if ARGV[0] == "config"
 end
 
 if ARGV[0] == "config"