Install Sarg – Squid Analysis Report Generator
wget -O sarg-latest.tar.gz http://sourceforge.net/projects/sarg/files/latest/download?source=files
tar zxvf sarg-latest.tar.gz
cd sarg-*
./configure
make
sudo make install
/usr/local/etc/sarg.conf
access_log /var/log/squid3/access.log
output_dir /var/www/squid-reports
temporary_dir /var/tmp/sarg
date_format e
overwrite_report yes
lastlog 45
resolve_ip yes
mkdir -p /var/www/squid-reports /var/tmp/sarg
chown www-data:www-data /var/www/squid-reports /var/tmp/sarg
chmod 775 /var/tmp/sarg
usermod -a -G proxy,staff www-data
Generate Sarg report
su -c "sarg -x" www-data
Access Sarg report
http://your_server/squid-reports
Automatic generating Sarg reports
Daily report
/etc/cron.daily/sarg
#!/bin/sh
su -c "sarg -d day-1 -w /var/tmp/sarg/sarg.daily -o /var/www/squid-reports/Daily /var/log/squid3/access.log*" www-data
Weekly report
/etc/cron.weekly/sarg
#!/bin/sh
su -c "sarg -d week-1 -w /var/tmp/sarg/sarg.weekly -o /var/www/squid-reports/Weekly /var/log/squid3/access.log*" www-data
Monthly report
/etc/cron.monthly/sarg
#!/bin/sh
su -c "sarg -d month-1 -w /var/tmp/sarg/sarg.monthly -o /var/www/squid-reports/Monthly /var/log/squid3/access.log*" www-data
chmod 755 /etc/cron.daily/sarg /etc/cron.weekly/sarg /etc/cron.monthly/sarg