Created
August 25, 2010 23:10
-
-
Save jakimowicz/550478 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 rails processes memory | |
graph_vlabel megabytes | |
graph_info This graph shows the average, min and max memory consumption made by rails processes. | |
graph_order max average min | |
max.label max | |
max.draw AREA | |
max.info Top memory consomption by a rails process. | |
min.label min | |
min.draw AREA | |
min.info Memory used by the application min (minimum memory consumption). | |
average.label average | |
average.draw AREA | |
average.info average memory consummed by all rails processes. | |
END | |
exit 0 | |
end | |
def output_values | |
stats = `sudo passenger-memory-stats` | |
unless $?.success? | |
$stderr.puts "failed executing passenger-memory-stats" | |
exit 1 | |
end | |
rails_processes = stats.scan(/\d+\s+\d+.\d+ MB\s+(\d+.\d+) MB\s+Rails/).flatten.collect(&:to_f) | |
puts "max.value #{rails_processes.max}" | |
puts "average.value #{rails_processes.inject(:+) / rails_processes.length.to_f}" | |
puts "min.value #{rails_processes.min}" | |
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