Skip to content

Instantly share code, notes, and snippets.

@drsnyder
Created July 21, 2012 00:45
Show Gist options
  • Save drsnyder/3154072 to your computer and use it in GitHub Desktop.
Save drsnyder/3154072 to your computer and use it in GitHub Desktop.
Top IP access log requesters by frequency including company owner
#!/bin/bash
TMP=$(mktemp)
awk '{ a[$2]++ } END { for (d in a) { printf("%d %s\n", a[d], d) } }' | sort -nr > $TMP
count=0
while read line; do
count=$(echo $line | awk '{ print $1 }')
ip=$(echo $line | awk '{ print $2 }')
company=$(jwhois $ip | grep -i OrgName | awk -F':' '{ print $2 }')
echo "$count $ip $company"
count=$(($count+1))
if [[ $count -gt 10 ]]; then
break;
fi
done < $TMP
rm $TMP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment