MOTD

Message Of The Day

Sat, 19 Mar 2005

05:57 [zork(~)] cat real-time-hit-meter.txt

If You Care

Real time apache hit meter. Displays number of hits per second on each line. Could probably be made more pretty with ANSI codes and whatnot. It only has one second of resolution which is a bit of a shame. Using something other than date could help that. I wrote this on a BSD system so GNU date may be better for this. Tuning the -10 passed to head varies the frequency of updating the output, and resolution a bit. And if you want to just check a part of the site or certain clients toss a grep (or some other selector) in between the while loop and the tail.

Note

Beware of I/O buffering. This is really not an accurate counter I've found because head can end up blocking more than is needed for its 10 lines of data.

tail -f access_log |
    (while true; do
        echo "`date +%s` `head -10 | wc -l` `date +%s`"
     done) |
    awk '$3 != $1 { print $2 / ($3 - $1) }'

[zork(~)] cal
[zork(~)] tree
[zork(~)] syndicate.py
[zork(~)] cat README