Tuesday, September 10, 2013

Nginx - Count of IP addresses in /var/log/nginx/access.log

Inspired by this post which supposedly works for Apache and also works for my Nginx installation. It seems however, some of the comments didn't work quite right on our Debian Lenny equipment.

Did away with grep (instead using cat) and tweaked to fix sorting not working correctly.

cat access.log | cut -d' ' -f1 | sort | uniq -c | sort -rg

If your log is big enough to scroll multiple pages when logged in remotely.

cat access.log | cut -d' ' -f1 | sort | uniq -c | sort -rg | less

No comments: