Created
April 18, 2012 20:35
-
-
Save j3tm0t0/2416404 to your computer and use it in GitHub Desktop.
mapper for S3 accesslog IP address check
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 | |
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