Squid SNMP Statistics: Using MRTG
Last Modified: 1-Feb-2008; 23:06 WST; adrian
Graph Squid SNMP statistics using MRTG.
It is best practice to monitor and graph Squid statistics in order to assist in both troubleshooting and capacity planning. This is an example for configuring SNMP statistics graphing using MRTG, a popular SNMP statistics graphing utility.
- 1. Make sure that Squid is compiled with SNMP support. squid -v will list the options which Squid was compiled with. It should either show --enable-snmp or not show --disable-snmp.
- 2. Install MRTG as per your operating environment instructions.
The following configuration fragment enables SNMP on port 3401, and allows access from localhost.
# SNMP configuration snmp_port 3401 acl snmppublic snmp_community public acl snmp_hosts src 127.0.0.1 snmp_access allow snmppublic snmp_hosts snmp_access deny all
Use squid -k check to verify that your new configuration is accepted. If squid is compiled with SNMP then the configuration should be accepted; if squid is not compiled with SNMP then it will give errors.
If this is successful then use squid -k reconfigure to enable the new SNMP configuration options.
Download and run the MRTG configuration generator
Xenion has provided a simple MRTG configuration template generator. It takes a pre-build MRTG configuration file and will add in the MRTG work directory, SNMP mib file location, SNMP host and SNMP community. This script uses standard UNIX utilities - it has been tested under FreeBSD 6.x, 7.x, and recent Linux distributions (Ubuntu 7.x, Fedora Core 7, CentOS 5.1.)
Download and run the template generation script available here.
The archive contains a README file. Follow the instructions to generate an MRTG configuration file, and follow your operating system MRTG documentation to configure it to run periodically (generally every 5 minutes); you may also need to install a web server and configure it to serve the MRTG web pages.