Monitoring Squid


Prepared By Visolve Squid Team

Enable SNMP in Squid
Installing and Configuring MRTG
Running MRTG


Squid runtime information like CPU usage, Memory usage, Cache Hit, Miss etc can be monitored using SNMP (a.k.a Simple Network Management Protocol). For this your squid server should have SNMP Server installed; True SNMP support is available from squid 2 and above. SNMP is normally transported through UDP packets. SNMP receives and responds to SNMP messages sent to the SNMP port on the local machine. The standard SNMP port is 161; by default Squid listens for incoming SNMP requests on port 3401.

There are a number of tools used to monitor Squid via SNMP, among which MRTG is mostly used. The Multi Router Traffic Grapher (MRTG) is a tool to monitor squid information which generates a real-time status (graphical representation), in dynamic view by sampling data every five minutes (may vary according to your need). MRTG shows activity - in the last 24 hours and also in a weekly, monthly and yearly graph.

Note: Working examples used in this document are from Linux OS. This may vary for other OS.

Enable SNMP in Squid

To use SNMP with squid, it must be enabled with the configure script, and rebuilt. To enable SNMP in squid go to squid src directory and follow the steps given below :
./configure --enable-snmp [ ... other configure options ]
make all
make install
And edit following tags in squid.conf file :
acl aclname snmp_community public
snmp_access aclname
Once you configure squid and SNMP server, Start SNMP and squid.
Querying the Squid SNMP agent
You can test if your Squid supports SNMP with the snmpwalk program (snmpwalk is a part of the UCD-SNMP project). Note that you have to specify the SNMP port, which in Squid defaults to 3401.
snmpwalk -p 3401 hostname communitystring . it gives output like :
enterprises.nlanr.squid.cacheSystem.cacheSysVMsize = 7970816
enterprises.nlanr.squid.cacheSystem.cacheSysStorage = 2796142
enterprises.nlanr.squid.cacheSystem.cacheUptime = Timeticks: (766299) 2:07:42.99
then it is working ok, and you should be able to make nice statistics out of mrtg tool.

Installing and configuring MRTG

You can get MRTG from a user for mrtg for example create a user name as mrtg and then untar the package
tar -xvzf mrtg-*
To configure, compile and install the mrtg enter the following commands :
make install
And run
/cfgmaker --global 'WorkDir: /home/mrtg/' --global 'Options[_]: bits,growright' --output /home/mrtg/cfg/mrtg.cfg public@ipaddress or hostname of SNMP-Squid machine
This will create a configuration file as mrtg.cfg in /home/mrtg/cfg/mrtg.cfg
Note: This example above will create an mrtg config file in /home/mrtg/cfg assuming /home/mrtg is visible on your webserver
Edit this configuration file (mrtg.cfg)
LoadMIBs: /mib.txt
And you have to set Target to get squid information.
(Note: The Squid MIB can be addressed by its root, which is In symbolic names, that is Symbolic names are used only when interacting with people - the packet only contains the numeric MIB label.)

Running MRTG

Once you have created a configuration file, try the following :
/mrtg /mrtg.cfg
This will query your squid and also create your first mrtg traffic graphs and webpages. When you run mrtg for the first time there will be a lot of complaints about missing log files. Don't worry, this is normal for the first 2 times you start mrtg. If it keeps complaining after this time you might want to look into the problem.
Sample Screen shots generated by MRTG-SNMP.
Starting mrtg by hand is not ideal in the long run. So when you are satisfied with the results you must automate the process of running mrtg in regular intervals (this means every 5 minutes by default).
If you are using Linux, then the line may look like this if you are using crontab -e
*/5 * * * * /mrtg /mrtg.cfg


ViSolve Squid Configuration Manual 2.4
ViSolve Squid Configuration Manual 3.0


ViSolve is an international corporation that provides technical services, for Internet based systems, for clients around the globe. ViSolve is in the business of providing software solutions since 1995. We have experience of executing several major projects and we are now completely focused on leading Internet technologies, Testing QA and support. We are committed to the Open source movement and in the same lines we provide free support for products like Linux, Apache and Squid to the user community.