Squid cachemgr.cgi UI hack
08 Nov 2004Squid has a little system statistics viewer built-in:
The cache manager (cachemgr.cgi) is a CGI utility for displaying statistics about the squid process as it runs. The cache manager is a convenient way to manage the cache and view statistics without logging into the server.
(from Squid FAQ)
The only thing is … it’s so ugly! It uses plain HTML and cannot be customized, the FAQ says. However, there is a way to do it:
- copy
cachemgr.cgi
tocachemgr2.cgi
so if you do something wrong, the original is not lost. - open the CGI file in a text-editor. I used
vi
, but if you’re not used to working with it, use something else (emacs?). - in the binary file, look for some text portions that look like HTML code
- while keeping in mind that the # of characters should remain the same, change the
and - suggestion: just let the CGI use a
style.css
file that you drop into the same folder.
<link rel="stylesheet" type="text/css" href="style.css" mce_href="style.css" />
and fill up with spaces to keep the same # characters - verify that the
cachemgr
and thecachemgr2
have the same # bytes - now use
cachemgr2
to display your statistics. I did something a bit different (I wanted to use the CSS of my own website), so I ‘ll show you the difference between the two versions.
In order to get to the following comparison, I did astrings cachemgr.cgi > cachemgr.txt
to extract only the text parts, and I did a<b>diff</b> cachemgr.txt cachemgr2.txt
to compare both files. You cannot do a file comparison of 2 binary files.
`
173,174c173,174
< <HTML><HEAD>Cache Manager Interface
< </HEAD>
—
Cache Manager (pforret)
199c199
<
---
<link rel="stylesheet" type=text/css href="http://www.forret.com/forret/forret.css" mce_href="http://www.forret.com/forret/forret.css"></STYLE>
`