Created
August 25, 2010 23:08
-
-
Save jakimowicz/550476 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/env ruby | |
def output_config | |
puts <<-END | |
graph_category passenger | |
graph_title memory | |
graph_vlabel megabytes | |
graph_info This graph shows the memory consumption made by passenger processes, passenger and nginx. | |
graph_order nginx passenger rails | |
rails.label rails | |
rails.draw AREA | |
rails.info Total memory used by all rails processes. | |
passenger.label passenger | |
passenger.draw AREA | |
passenger.info Total memory used by passenger. | |
nginx.label nginx | |
nginx.draw AREA | |
nginx.info Total memory used by nginx. | |
END | |
exit 0 | |
end | |
def total_for(component, str) | |
str.scan(/\d+\s+\d+.\d+ MB\s+(\d+.\d+) MB\s+#{component}/).flatten.collect(&:to_f).inject(:+) | |
end | |
def output_values | |
stats = `sudo passenger-memory-stats` | |
unless $?.success? | |
$stderr.puts "failed executing passenger-memory-stats" | |
exit 1 | |
end | |
puts "rails.value #{total_for 'Rails', stats}", | |
"passenger.value #{total_for 'Passenger', stats}", | |
"nginx.value #{total_for 'nginx', stats}" | |
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