Skip to content

Instantly share code, notes, and snippets.

@fduran
Created February 20, 2012 18:27
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save fduran/1870507 to your computer and use it in GitHub Desktop.
Save fduran/1870507 to your computer and use it in GitHub Desktop.
Apache find IPs with most connections
# www.fduran.com
# Number of top 10 current TCP connections per IP
netstat -tan| grep -v 'LISTEN'| awk '{print $5}'| grep -v 'and' |grep -v 'Address' |cut -d':' -f1 |sort -n | uniq -c | sort -rn | head -n10
# Top 10 IPs in Apache log files
cd /var/log/apache2; for i in ./access.log*; do echo $i; cat $i | awk '{print $1}'| sort -n | uniq -c | sort -rn | head -n10; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment