Created
October 10, 2009 22:53
-
-
Save jcsalterego/207217 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 | |
| FIELDS=%w( req_total req_rendering req_database ) | |
| def output_config | |
| puts <<-END | |
| graph_category App | |
| graph_title Passenger Performance | |
| graph_vlabel time in seconds | |
| req_total.label Total time | |
| req_rendering.label Rendering time | |
| req_database.label Database time | |
| END | |
| exit 0 | |
| end | |
| def output_values | |
| status = `tail -n 20 production.log | grep Completed` | |
| unless $?.success? | |
| $stderr.puts "Failed viewing log file" | |
| exit 1 | |
| end | |
| if status.empty? | |
| $stderr.puts "No data available" | |
| end | |
| values = status.split("\n")[-1].scan(/\d+\.\d+/) | |
| if values.length < 3 | |
| $stderr.puts "Malformed data" | |
| end | |
| FIELDS.zip(values.slice(0, 3)) { |k, v| puts "#{k}.value #{v}" } | |
| end | |
| if $0 == __FILE__ | |
| if ARGV[0] == "config" | |
| output_config | |
| else | |
| output_values | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment