Hi folks, I wrote a quick script to extract performance one-liners from Rails logs. (Didn''t want to futz with syslog for http://rails-analyzer.rubyforge.org/ .) Reads output from :info or :debug log levels (the defaults). Usage: # summarize < development.log # summarize < production.log Output looks like: (w/FULL_URL set false) 123.23.23.123 2006-05-05 10:59:42 | r 0.0--00 0% | db 0.00812 29% | 0.02726 36 r/s | 302 /some/uri 123.23.23.123 2006-05-05 10:59:43 | r 0.02059 55% | db 0.01246 33% | 0.03697 27 r/s | 200 /some/uri 123.23.23.123 2006-05-05 10:59:53 | r 0.00716 68% | db 0.00156 14% | 0.01048 95 r/s | 200 /some/uri 123.23.23.123 2006-05-05 10:59:57 | r 0.00727 72% | db 0.00109 10% | 0.01005 99 r/s | 200 /some/uri (w/FULL_URL set true) 123.23.23.123 2006-05-05 10:59:58 | r 0.0--00 0% | db 0.01137 27% | 0.04104 24 r/s | 302 https://a.b.com/some/uri 123.23.23.123 2006-05-05 10:59:58 | r 0.0--00 0% | db 0.00064 24% | 0.00255 392 r/s | 302 https://a.b.com/some/uri 123.23.23.123 2006-05-05 10:59:59 | r 0.08411 79% | db 0.01929 18% | 0.10589 9 r/s | 200 https://a.b.com/some/uri 123.23.23.123 2006-05-05 11:00:01 | r 0.0--00 0% | db 0.00721 57% | 0.01250 79 r/s | 302 https://a.b.com/some/uri 123.23.23.123 2006-05-05 11:00:01 | r 0.02212 56% | db 0.01381 35% | 0.03932 25 r/s | 200 https://a.b.com/some/uri 123.23.23.123 2006-05-05 11:00:05 | r 0.00734 72% | db 0.00109 10% | 0.01011 98 r/s | 200 https://a.b.com/some/uri (see attached summarize script) -jeremy _____________________________________________________________________ jeremy wohl ..: http://igmus.org -------------- next part -------------- #!/usr/bin/ruby # # summarize -- generate performance one-liners from Rails log input (:info or :debug) # # # urls keep proto://host bit? FULL_URL = false STDIN.read.split(/^\s*$/).each do |s| next if s !~ /^Processing.+Completed/m ip, time = s.match(/\(for (.+?) at (.+?)\)/)[1..-1] #puts s final_time, reqs_per_sec = s.match(/Completed in (\S+?) \((\S+?) reqs\/sec\)/)[1..-1] http_status, url = s.match(/\| (\d+) \w+ \[(.+?)\]$/)[1..-1] render_time, render_perc = s =~ /200 OK/ ? s.match(/Rendering: (\S+?) \((\d+)/)[1..-1] : [ ''0.0--00'', ''0'' ] db_time, db_perc = s =~ /DB: / ? s.match(/DB: (\S+) \((\d+)/)[1..-1] : [ ''0.0--00'', ''0'' ] url = url[/\w(\/.*)/, 1] if not FULL_URL puts sprintf("%15s %s | r %s %2s%% | db %s %2s%% | %s %4s r/s | %s %s", ip, time, render_time, render_perc, db_time, db_perc, final_time, reqs_per_sec, http_status, url) end