Created
September 1, 2014 15:45
-
-
Save alexchantavy/fe3d408ef53d346d2130 to your computer and use it in GitHub Desktop.
Geolocate nginx visitors
This file contains hidden or 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
#!/bin/sh | |
# Geolocate nginx site visitors with geoiplookup. | |
# Output format = <IP> <Date> <Request> <City of IP> | |
NGINX_LOG_FILE=/my/log/file/here | |
cat $NGINX_LOG_FILE | awk '{print $1, $4, $5, $6, $7}' | | |
while read p ; do | |
set -- $p | |
echo "$p ["`geoiplookup -f /usr/share/GeoIP/GeoLiteCity.dat "$1" | awk '{print $6, $7, $8, $9, $10, $11}'`"]"; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment