Skip to content

Instantly share code, notes, and snippets.

@j3tm0t0
Created April 18, 2012 20:35
Show Gist options
  • Save j3tm0t0/2416404 to your computer and use it in GitHub Desktop.
Save j3tm0t0/2416404 to your computer and use it in GitHub Desktop.
mapper for S3 accesslog IP address check
#!/usr/bin/env ruby
ARGF.each do |line|
line = line.chomp
data = line.split(/ /)
# IP address is 5th column if split by space
ip = data[4]
key = ip
# value is a count of 1 occurence
value = 1
# output to STDOUT only if it were for /index.html access
if data[8] == "index.html"
puts key + "\t" + value.to_s
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment