Created
April 23, 2010 15:26
-
-
Save raine/376678 to your computer and use it in GitHub Desktop.
This file contains 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 | |
require 'date' | |
log, file = ARGV | |
regex = Regexp.new("GET.*#{file}\s.*200\s") | |
lines = File.open(log).readlines | |
gets = lines.grep regex | |
totals = {} | |
totals.default = 0 | |
gets.each do |l| | |
date = Date.parse(l.scan(/\[(.*?)\]/).to_s) | |
totals[date] += 1 | |
end | |
totals.sort_by { |d| d }.each do |date, count| | |
puts "#{date} — #{count}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment