summaryrefslogtreecommitdiff
path: root/puppet/modules/passenger/files/munin/passenger_stats
diff options
context:
space:
mode:
authorMicah <micah@leap.se>2016-07-12 16:46:06 -0400
committerMicah <micah@leap.se>2016-07-12 16:46:06 -0400
commit4a11e48e397f1a7eb4c68a1dd1f9e3c5a11352f8 (patch)
tree66379b593391e99bb5dc66cf7e9ef48947d80a21 /puppet/modules/passenger/files/munin/passenger_stats
parent95d95925e53ec98f3f5868479328a69449de3ca7 (diff)
git subrepo clone https://leap.se/git/puppet_passenger puppet/modules/passenger
subrepo: subdir: "puppet/modules/passenger" merged: "47fca11" upstream: origin: "https://leap.se/git/puppet_passenger" branch: "master" commit: "47fca11" git-subrepo: version: "0.3.0" origin: "https://github.com/ingydotnet/git-subrepo" commit: "1e79595" Change-Id: Idba1129126ca0f13a4441e00d7b53e8b4f856825
Diffstat (limited to 'puppet/modules/passenger/files/munin/passenger_stats')
-rwxr-xr-xpuppet/modules/passenger/files/munin/passenger_stats47
1 files changed, 47 insertions, 0 deletions
diff --git a/puppet/modules/passenger/files/munin/passenger_stats b/puppet/modules/passenger/files/munin/passenger_stats
new file mode 100755
index 00000000..f06e88a0
--- /dev/null
+++ b/puppet/modules/passenger/files/munin/passenger_stats
@@ -0,0 +1,47 @@
+#!/usr/bin/env ruby
+
+PASSENGER_STATUS = ENV['passenger_status'] || '/usr/local/bin/passenger-status'
+
+def output_config
+ puts <<-END
+graph_category Passenger
+graph_title passenger status
+graph_vlabel count
+
+sessions.label sessions
+max.label max processes
+running.label running processes
+active.label active processes
+inactive.label inactive processes
+END
+ exit 0
+end
+
+def output_values
+ status = `#{PASSENGER_STATUS}`
+ unless $?.success?
+ $stderr.puts "failed executing passenger-status"
+ exit 1
+ end
+ status =~ /max\s+=\s+(\d+)/
+ puts "max.value #{$1}"
+
+ status =~ /count\s+=\s+(\d+)/
+ puts "running.value #{$1}"
+
+ status =~ /active\s+=\s+(\d+)/
+ puts "active.value #{$1}"
+
+ status =~ /inactive\s+=\s+(\d+)/
+ puts "inactive.value #{$1}"
+
+ total_sessions = 0
+ status.scan(/Sessions: (\d+)/).flatten.each { |count| total_sessions += count.to_i }
+ puts "sessions.value #{total_sessions}"
+end
+
+if ARGV[0] == "config"
+ output_config
+else
+ output_values
+end