MYSAR – Squid Proxy Monitoring Tool

Recently I joined a new company as a Senior Linux Administrator. The IT manager told me that the users of our company are violating the Internet access policy rules. To catch the users who are violating the rules, they had configured SARG which is reference for Squid Access Report Genarator. SARG is a good tool but not good enough. SARG can show you all the inforamation like, which user browsed which site, Cache used by the user, bandwidth etc….. But the thing which was lacking here was the exact time when the user accessed that particular website. And that is the only problem I found with SARG.

I searched a lot on Internet and finally found that SARG can’t do this by any customization. So finally I decided to configure a new Proxy monitoring tool for my squid server. After searching a lot on Internet for a proxy monitoring tool as per my requirement, I finally found ‘MYSAR’.

MYSAR is reference for Mysql Squid Access Report. This tools reports the complete information like:

Total number of Users accessed the website on specific date

How many users browsed the website on specific day

How many site were browsed on specific day

Exact time when the user accessed the website

Total number of data[in bytes,kilobytes,mb,gb] user browsed

I think if you are getting above mentioned information from your Monitoring tool, you do not need any other monitoring tool. So here I am gonna show you , how to configure MYSAR on your Linux system.

Note: To configure MYSAR,you need to configure Mysql server on your system.

Step1. Download the latest version of MYSAR.

[root@server ~]# wget

Step2. Now extract the source file and move it to ‘/usr/local

[root@server ~]# tar -xzvf mysar-2.1.4.tar.gz

[root@server ~]# mv mysar /usr/local

Step3. Open your ‘httpd.conf’ and add below mentioned lines:

[root@server ~]# vim /etc/httpd/conf/httpd.conf

<VirtualHost *:80>
DocumentRoot /usr/local/mysar/www
ErrorLog logs/
CustomLog logs/ common

[root@server ~]# service httpd restart

Step4. Now map the domain name [] with your proxy server ip. Use ‘dns’ or ‘hosts’ file to do this.

Step5. Create a database for mysar and a user with full access to the mysar database.

Step6. Now open url ‘’ from your browser and fill the required details.

  • Click here to continue
  • New install

Mysql Administative Username: root
Mysql Administative Password: **********
Mysql Database Host: localhost
Mysql Database Name For Mysar: mysar
Mysql Databse Username to create. For mysar: mysar

Mysql Database Password for the new user defined above: MySaR

Creating database…Done!

Now just click on ‘click here’ option, wherever you find.

Steo7. Create a new file named ‘config.ini’ and fill database information here.

[root@server ~]# vim /usr/local/mysar/etc/config.ini

dbUser = mysar
dbPass = MySaR
dbHost = localhost
dbName = mysar

Step8. Now remove the ‘install’ directory from ‘/usr/local/mysar/www” .

Thats it. Here your Mysar configuration is all done.

Note: Run following command if you want to set cronjob for mysar, so that mysar present you the latest details.

[root@server ~]# ln -s /usr/local/mysar /etc/mysar.cron /etc/cron.d/mysar

[root@server ~]# ln -s /usr/local/bin/php /usr/bin/php

You can leave a response, or trackback from your own site.

One Response to “MYSAR – Squid Proxy Monitoring Tool”

  1. Amar Shakti says:

    Hey, very nice article..I am not very familier with database and squid proxy, so can you please configure my server with squid and mysar?

Leave a Reply