wario

Posted by & filed under geek, howto.

The other day I came across a situation where a web-server was getting hammered, and we needed to know who the offend(ers) were. While watching a logfile tail by at high speeds is always fun, we wanted to be able to sort the web-server access log and find top users, to be able to narrow down where the traffic was coming from. While we don’t want to block users that want to access our data, sometimes we need to throttle things back so one requester doesn’t overwhelm all the available bandwidth and make the site unusable for others. So after some playing around and digging on Google, we came up with a nice, succinct one liner to do this, here it is:

cat /path/to/access.log | awk '{print $1}' | sort | uniq -c | sort -n | tail

Recently it seems that piping cat output to other apps is all I do on my servers, and I’m ok with that!


Related posts:

  1. HOWTO: log the user's IP, not the proxy's, in nginx access log
  2. HOWTO: Configure nginx for Debian / Ubuntu
  3. Apache server lockdown challenge
  4. HOWTO: webserver in 100 lines of Bash
  5. HOWTO: log the user's IP, not the proxy's, in Lighttpd access log
  • Anonymous

    YOU POSTED…YOU WROTE…YOU LIVE!!!!
    What a good day.
    Too bad i don’t understand any of this…NEVERTHELESS…Welcome back!

  • matt1912

    YOU POSTED…YOU WROTE…YOU LIVE!!!! What a good day.Too bad i don't understand any of this…NEVERTHELESS…Welcome back!

  • http://www.titidirectonline.co.uk/mobile-phones Dual Sim Phone

    great read

  • http://www.google.com Dual Sim Phone

    great read

  • http://www.titidirectonline.co.uk/mobile-phones Dual Sim Phone

    great read