Last active
August 29, 2015 13:56
-
-
Save dannysheehan/9084174 to your computer and use it in GitHub Desktop.
Find what countries your users are logging into your server from. Tested on SLES only and needs geoip-lookup to be installed on your server.
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
#!/bin/bash | |
grep "Accepted .* for " /var/log/messages | awk '{print $9, $11}' | egrep -v "nagios|bb|172\.|10\.|192\.168\." | sort | uniq | while read u | |
do | |
AUSER=`echo $u | awk '{print $1}'` | |
AIP=`echo $u | awk '{print $2}'` | |
COUNTRY=`geoip-lookup $AIP` | |
#echo $AUSER $COUNTRY $AIP | |
echo $AUSER $COUNTRY | |
done | sort | uniq -c | sort -n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment