Tuesday, March 9, 2010

SARG on FreeBSD+Squid

Squid Report Analysis using SARG in FreeBSD and Squid 


Ok if you want to be the big brother and wanted to monitor and analyse the web usage of your users sarg is your best friend. Do let me warn you about
the consiquences of using it and breaking the users privacy and legal mess you can be. Do kindly let ur users know that they are getting monitored on their 
web usage.




Now why SARG?
Bcoz it produces nice report in html format neatly that too datewise and userwise


Prior requirment? Yes Apache and squid which I hope you guys have installed and running already


Installation is as root
#cd /usr/ports/www/sarg
#make install clean


Ok thats it you got it installed guys! Dont you love freebsd for its ports?


Now time to tweak sarg settings
#cd /usr/local/etc/sarg/


Lets edit sarg configuaration file
#vi sarg.conf


First of all modify the like which talks about squid access log file. Modify it according to ur squid log file location
Ok I am just putting only the besic ones kindly go through ur sarg configuration file and see what and all you can change and tweak


access_log /usr/local/squid/var/logs/access.log
graphs yes
graph_days_bytes_bar_color orange
title "Squid User Access Reports"
output_dir /var/www/htdocs/sarg
resolve_ip no
topuser_sort_field BYTES reverse
user_sort_field BYTES reverse


Ok save it and now its time for us to run it everyday so that it can produce the report at the end of the day
in my case I wanted sarge to produce the report at midnight so that I can check my users access next day morning


Now how to run it everyday mid night? There comes the cron for your help
Create a crontab entry to run the sarg at mid night everyday
#cronttab -e    
01 * * * *   root /usr/local/bin/sarg


Ok guys thats all , Ready to be the big brother and snoop on users . Shame on you guys :) dont you feel guily? Yeah I know the anser, WHY THE HELL I MUST BE?
If our bosses doesnt feel that, balls to users ha? LOL


OK I hope some desparete user dont kill us LOL