]> git.openstreetmap.org Git - chef.git/blob - cookbooks/munin/files/default/plugins/passenger_memory
7e6e36abc8da3b392f357e5b789594afc803ef8d
[chef.git] / cookbooks / munin / files / default / plugins / passenger_memory
1 #!/usr/bin/env ruby
2 # put in /etc/munin/plugins and restart munin-node
3 # by Dan Manges, http://www.dcmanges.com/blog/rails-application-visualization-with-munin
4 # NOTE: you might need to add munin to allow passwordless sudo for passenger-memory-stats
5
6 def output_config
7   puts <<-END
8 graph_args --base 1024 -l 0 --vertical-label bytes --upper-limit 4056231936
9 graph_category passenger
10 graph_title Passenger memory
11
12 memory.label memory
13 END
14   exit 0
15 end
16
17 def output_values
18   status = `/usr/sbin/passenger-memory-stats | tail -1`
19   unless $CHILD_STATUS.success?
20     $stderr.puts "failed executing passenger-memory-stats"
21     exit 1
22   end
23   status =~ /(\d+\.\d+)/
24   puts "memory.value #{(Regexp.last_match[1].to_f * 1024 * 1024).round}"
25 end
26
27 if ARGV[0] == "config"
28   output_config
29 else
30   output_values
31 end