NAS: Analyse your squid logs

In a previous post I described how to install Squid on the Synology. This small tutorial will now explain how to display your usage behaviour in Squid via Webalizer.

You need to have ipkg installed and need to have an understanding on how to include 3rd party apps (i.e. via phpsrc).

  1. Install webalizer: ipkg install webalizer
  2. Create a new config file: cp /opt/etc/webalizer.conf.sample /opt/etc/webalizer.conf
  3. Adjust your log-file entry and point it to your Squid-access log: LogFile /opt/var/squid/logs/access.log
  4. Adjust your output directory (this is the HTML-directory from which you want to display your stats): OutputDir /volume1/webapps/scripts/squid/usage
  5. Create a cronjob entry (remember that the crontab needs to have tabs instead of spaces): 5 0 * * * root /opt/bin/webalizer -F squid -A 100 -C 100 -R 100 -S 100 -U 100 -e 100 -E 100 -Q

The above will create usage statistics every day (5 minutes past midnight) and publish the stats to the output-directory.

Some more cool stuff:

  • Use HideUrl to hide sites from the statistics. I typically hide access to all my local servers, since I am only interested in the outbound usage.
  • Use GroupUrl and HideUrl together to group certain websites and make it one line-item in the stats. I access the PS3ZA-forum frequently, so I don’t want to have every URL show, since it fills up the stats. Using GroupUrl and HideUrl will create one line-item in the stats. You can do the same with your RSS-feeds and others.
  • To avoid your logs filling up, you want to add a cronjob to rotate your squid access-logs (remember those TABS – this job will rotate the logs 30 minutes past midnight every month): 30 * 1 * * root /opt/sbin/squid -k rotate. Important: Webalizer don’t rotate the logs during the month – I was not able to get Webalizer to analyse those logs and you will lose your monthly stats.
Print Friendly, PDF & Email