Friday, January 3, 2014

Apache logs: Get unique visitors in the last 60 seconds

This is modified from: http://nixcraft.com/showthread.php/13554-Script-to-count-unique-ips-in-apache-access-log/page3?p=32816&viewfull=1#post32816

To get the number of unique visitors (by ip) in the last 60 seconds from an Apache log:

awk  '{if ( substr($4,14) > strftime("%H:%M:%S", systime()-(60) )  && substr($4,2,9) == strftime("%d/%b/%C")) !a[$1]++}END{for(i in  a) k++; print k }' access_log

1 comment:

KC said...

Hi. I really enjoyed my brief visit on your site and I’ll be sure to be back for more.
Can you please consider placing my website on your link list?

Please email me back.

Thanks!
Kevin
kevincollins1012 gmail.com