Created
March 25, 2010 08:04
-
-
Save jfqd/343298 to your computer and use it in GitHub Desktop.
Passenger and Apache Memory Munin Plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# Passenger and Apache Memory Munin Plugin | |
# put in /usr/share/munin/plugins/ and link into /etc/munin/plugins then restart munin-node | |
# by Dan Manges, http://www.dcmanges.com/blog/rails-application-visualization-with-munin | |
# small changes by jfqd 2010-03-25 | |
# NOTE: you might need to add munin to allow passwordless sudo for passenger-memory-stats | |
def output_config | |
puts <<-END | |
graph_category App | |
graph_title Passenger and Apache Memory | |
graph_vlabel MB | |
apache.label apache | |
passenger.label passenger | |
END | |
exit 0 | |
end | |
def output_values | |
apache = nil | |
passenger = nil | |
`/usr/bin/passenger-memory-stats`.each_line do |line| | |
next unless /### Total private dirty RSS: (\d+\.\d+) MB/.match(line) | |
passenger = $~[1] unless apache.nil? | |
apache ||= $~[1] | |
end | |
puts "apache.value #{apache}" | |
puts "passenger.value #{passenger}" | |
end | |
if ARGV[0] == "config" | |
output_config | |
else | |
output_values | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment