Squid: list top X referers

If your Squid server logs the referers of its request (i.e.
1. you’ve configured squid-cache with --enable-referer-log before compiling and
2. you’ve included a referer_log /var/log/squid/referer.log in your squid.conf file),
you can easily show top 50 of most popular referers with a simple Bourne shell:
#!/bin/bash

  1. this script is ‘top_referers.sh’
  2. (c) 2004 Peter Forret – Open Source
    REFERERS=/var/log/squid/referer.log
    OUTPUT=/var/www/html/stats/referer.txt
    MAXLINES=50(
    echo REPORT MADE AT `date`
    echo =============================
    $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!

Related posts:

  1. Squid cachemgr.cgi UI hack Squid has a little system statistics viewer built-in: The cache...
  2. Estimate # of lines in a log file Let’s say you need an (approximate) count of the number...
  3. Calculate hit rate from a log file You have a huge file that contains one line per...
  4. List of quartets Here you go, Ine dear: Four jobs I’ve had/have (skip...
  5. B-list blogger via Ine and Clo...

0 Responses to “Squid: list top X referers”


Comments are currently closed.