31.6. cachemgr.cgi

The cache manager (cachemgr.cgi) is a CGI utility for displaying statistics about the memory usage of a running Squid process. It is also a more convenient way to manage the cache and view statistics without logging the server.

31.6.1. Setup

First, a running Web server on your system is required. Configure Apache as described in Chapter 32, The Apache HTTP Server. To check if Apache is already running, as root enter the command rcapache status. If a message like this appears:

Checking for service httpd: OK 
Server uptime: 1 day 18 hours 29 minutes 39 seconds   

Apache is running on the machine. Otherwise, enter rcapache start to start Apache with the openSUSE default settings. The last step to set it up is to copy the file cachemgr.cgi to the Apache directory cgi-bin:

cp /usr/share/doc/packages/squid/scripts/cachemgr.cgi /srv/www/cgi-bin/

31.6.2. Cache Manager ACLs in /etc/squid/squid.conf

There are some default settings in the original file required for the cache manager. First, two ACLs are defined then http_access options use these ACLs to grant access from the CGI script to Squid. The first ACL is the most important, because the cache manager tries to communicate with Squid over the cache_object protocol.

acl manager proto cache_object
acl localhost src

The following rules give Apache the access rights to Squid:

http_access allow manager localhost
http_access deny manager

These rules assume that the Web server and Squid are running on the same machine. If the communication between the cache manager and Squid originates at the Web server on another computer, include an extra ACL as in Example 31.2, “Access Rules”.

Example 31.2. Access Rules

acl manager proto cache_object
acl localhost src
acl webserver src # webserver IP

Then add the rules in Example 31.3, “Access Rules” to permit access from the Web server.

Example 31.3. Access Rules

http_access allow manager localhost
http_access allow manager webserver
http_access deny manager

Configure a password for the manager for access to more options, like closing the cache remotely or viewing more information about the cache. For this, configure the entry cachemgr_passwd with a password for the manager and the list of options to view. This list appears as a part of the entry comments in /etc/squid/squid.conf.

Restart Squid every time the configuration file is changed. Do this easily with rcsquid reload.

31.6.3. Viewing the Statistics

Go to the corresponding Web site—http://webserver.example.org/cgi-bin/cachemgr.cgi. Press continue and browse through the different statistics. More details for each entry shown by the cache manager is in the Squid FAQ at http://www.squid-cache.org/Doc/FAQ/FAQ-9.html.