Skip to content

Instantly share code, notes, and snippets.

@jfqd
Created March 25, 2010 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfqd/343298 to your computer and use it in GitHub Desktop.
Save jfqd/343298 to your computer and use it in GitHub Desktop.
Passenger and Apache Memory Munin Plugin
#!/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