Squid cachemgr.cgi UI hack
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:
- copy
cachemgr.cgitocachemgr2.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
<title>and<style>to something that suits you. You will have to do this at 2 locations in the file: one for the homepage template and one for the other pages’ template. - 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
cachemgrand thecachemgr2have 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.txt to extract only the text parts, and I did a diff cachemgr.txt cachemgr2.txt to compare both files. You cannot do a file comparison of 2 binary files.
173,174c173,174
< <HTML><HEAD><TITLE>Cache Manager Interface</TITLE>
< <STYLE type="text/css"><!-- BODY{background-color:#ffffff;font-family:verdana,sans-serif} --></STYLE></HEAD>
---
> <HTML><HEAD><TITLE>Cache Manager (pforret)</TITLE>
> <link rel="stylesheet" type="text/css" href="http://www.forret.com/forret/forret.css" mce_href="http://www.forret.com/forret/forret.css" /> </HEAD>
199c199
< <STYLE type="text/css"><!-- BODY{background-color:#ffffff;font-family:verdana,sans-serif} TABLE{background-color:#333333;border:0pt;padding:0pt}TH,TD{background-color:#ffffff}--></STYLE>
---
> <link rel="stylesheet" type=text/css href="http://www.forret.com/forret/forret.css" mce_href="http://www.forret.com/forret/forret.css"><!-- TABLE{background-color:#333333;border:0pt;padding:0pt} TH,TD{background-color:#ffffff}--></STYLE>