Index of /~wessels/squid-rrd

[ICO]NameLast modifiedSizeDescription

[DIR]Parent Directory  -  
[   ]1day-cgi13-Mar-2006 14:13 3.7K 
[   ]create.sh12-Jun-2006 19:17 5.0K 
[   ]cron07-Jun-2000 22:56 78  
[   ]htaccess07-May-2000 14:19 161  
[   ]poll.pl12-Jun-2006 19:11 13K 

Intro

I use my own Perl script to collect stats from Squid. The stats are stored in RRDtool databases, and RRDtool also generates the graphs. Stats are collected every five minutes. Apache is configured to expire the graph image files after five minutes.

For a sample, look here.

How to install this stuff

  1. Compile apache with the expires module:

    % cd apache_1.3.3. % ./configure --add-module=src/modules/standard/mod_expires.c

  2. Download RRDtool and unpack it.

  3. Put poll.pl, create.sh, 1day-cgi, and htaccess somewhere under your htdocs directory.

    Rename htaccess to .htaccess and make sure it is readable by all.

    Rename 1day-cgi to 1day.cgi. [sorry, I can't name it .cgi here, or else my server tries to execute it].

  4. Run the create.sh script to create the RRD databases.

  5. Try the poll.pl script by hand:

    % perl poll.pl localhost

  6. Add it to your cron jobs:

    % crontab */5 * * * * /usr/local/apache/share/htdocs/squid-rrd/poll.pl localhost ^D
  7. Tell apache to interpret .cgi as a CGI script by editing srm.conf and uncommenting this line:

    AddHandler cgi-script .cgi

  8. Tell apache its okay to execute CGI scripts, and to set Expires headers by adding this to access.conf:

    <Directory "/usr/local/apache/share/htdocs/squid-rrd"> AllowOverride Indexes Options ExecCGI <Directory>

  9. Apache needs write access to the directory where RRD creates the PNG files. For now, this is the same directory.

    % cd /usr/local/apache/share/htdocs/squid-rrd % su # chgrp nobody . # chmod 775 .

    Alternatively, you can create empty PNG files and make just those files writable by nobody:

    % cd /usr/local/apache/share/htdocs/squid-rrd % su # cp /dev/null connections.day.png ... # chgrp nobody *.png # chmod 775 *.png

To use

Request 1day.cgi in your browser. You should see a number of graphs and your browser should refresh the display every 2.5 minutes.

You may want to copy 1day.cgi to another filename, such as ``1week.cgi'' and change all occurances of ``day'' to ``week'' in the new file.

Bugs, Problems, Future Work

As written, the CGI file requires write access for the PNG files that it creates in the same directory as the RRD files. You can put the PNG files in a separate directory on your HTTP server, but you'll need to edit the CGI file. The RRDtool documentation explains how to do this.

It would be nice if I could use snmpget instead of the gross poll.pl script. However, at this time, a number of interesting stats are not available via Squid's SNMP MIB.


README.html,v 1.7 2004/03/08 21:03:49 wessels Exp