Squid cachemgr.cgi UI hack08 Nov 2004
Squid 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:
cachemgr2.cgiso 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
- suggestion: just let the CGI use a
style.cssfile 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
cachemgr2have the same # bytes
- now use
cachemgr2to 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 a
strings cachemgr.cgi > cachemgr.txtto extract only the text parts, and I did a
<b>diff</b> cachemgr.txt cachemgr2.txtto compare both files. You cannot do a file comparison of 2 binary files.
Cache Manager Interface
Cache Manager (pforret)
<link rel="stylesheet" type=text/css href="http://www.forret.com/forret/forret.css" mce_href="http://www.forret.com/forret/forret.css"></STYLE>