Skip to content

Instantly share code, notes, and snippets.

@raine
Created April 23, 2010 15:26
Show Gist options
  • Save raine/376678 to your computer and use it in GitHub Desktop.
Save raine/376678 to your computer and use it in GitHub Desktop.
#!/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