Squid: list top X referers
19 Oct 2004If your Squid server logs the referers of its request (i.e.
- you’ve configured squid-cache with
--enable-referer-log
before compiling and -
you’ve included a
referer_log /var/log/squid/referer.log
in yoursquid.conf
file),
you can easily show top 50 of most popular referers with a simple Bourne shell:
#!/bin/bash
- this script is ‘top_referers.sh’
- (c) 2004 Peter Forret – Open Source
REFERERS=/var/log/squid/referer.log
OUTPUT=/var/www/html/stats/referer.txt
MAXLINES=50(<br /> echo REPORT MADE AT `date`<br /> echo =============================<br /> $OUTPUT
Then add it to your crontab:
10 * * * * /(path)/top_referers.sh
and you have an hourly updated stat!
Add a little HTML formatting if you’re aesthetically demanding!