#!/usr/bin/env ruby
ip_address = nil
datetime = nil
ARGV.each do |filename|
File.open(filename, "r").each do |line|
if line =~ /^Processing .*for ([\d\.]+) at (\d\d\d\d\-\d\d\-\d\d \d\d:\d\d:\d\d)/
ip_address = $1
datetime = $2
elsif line =~ /^Completed in (\d+)ms .View: (\d+), DB: (\d+).*http(.*)\]/
puts "#{ip_address}\t#{datetime}\t#{$1}\t#{$2}\t#{$3}\thttp#{$4}"
end
end
end
Give it bunch of logs on the command line and it will output tab separated lines such as:
1.1.1.1 2010-04-05 04:03:03 7 1 4 http://www.example.com/fred
Where the values are as follows:
- The ip from which the request was made
- The data and time of the request
- The overall processing time in ms
- The ms timing for the view
- The ms timing for the db
- The requested url