]> git.openstreetmap.org Git - chef.git/blob - cookbooks/munin/files/default/plugins/passenger_memory
Fix munin replication plugin to work with osmium based state
[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 require "English"
7
8 def output_config
9   puts <<~CONFIG
10     graph_args --base 1024 -l 0 --vertical-label bytes --upper-limit 4056231936
11     graph_category passenger
12     graph_title Passenger memory
13
14     memory.label memory
15   CONFIG
16   exit 0
17 end
18
19 def output_values
20   status = `/usr/sbin/passenger-memory-stats | tail -1`
21   unless $CHILD_STATUS.success?
22     warn "failed executing passenger-memory-stats"
23     exit 1
24   end
25   status =~ /(\d+\.\d+)/
26   puts "memory.value #{(Regexp.last_match[1].to_f * 1024 * 1024).round}"
27 end
28
29 if ARGV[0] == "config"
30   output_config
31 else
32   output_values
33 end