summaryrefslogtreecommitdiff
path: root/files
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2010-04-26 17:30:11 -0400
committerMicah Anderson <micah@riseup.net>2010-04-26 17:30:11 -0400
commit8b8254af56943e761289d54d5c57fd942303f914 (patch)
tree05b41635c97310683be94a18612c69b52b1dc60a /files
initial commit
Diffstat (limited to 'files')
-rwxr-xr-xfiles/munin/passenger_mem31
-rwxr-xr-xfiles/munin/passenger_stats45
2 files changed, 76 insertions, 0 deletions
diff --git a/files/munin/passenger_mem b/files/munin/passenger_mem
new file mode 100755
index 0000000..47fba09
--- /dev/null
+++ b/files/munin/passenger_mem
@@ -0,0 +1,31 @@
+#!/usr/bin/env ruby
+# by Dan Manges, http://www.dcmanges.com/blog/rails-application-visualization-with-munin
+
+def output_config
+ puts <<-END
+graph_category App
+graph_title Passenger memory stats
+graph_vlabel count
+
+memory.label memory
+END
+ exit 0
+end
+
+def output_values
+ status = `/usr/sbin/passenger-memory-stats | tail -1`
+ unless $?.success?
+ $stderr.puts "failed executing passenger-memory-stats"
+ exit 1
+ end
+ status =~ /(\d+\.\d+)/
+ puts "memory.value #{$1}"
+end
+
+if ARGV[0] == "config"
+ output_config
+else
+ output_values
+end
+
+
diff --git a/files/munin/passenger_stats b/files/munin/passenger_stats
new file mode 100755
index 0000000..00bf5e4
--- /dev/null
+++ b/files/munin/passenger_stats
@@ -0,0 +1,45 @@
+#!/usr/bin/env ruby
+
+def output_config
+ puts <<-END
+graph_category App
+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 = `/usr/sbin/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