Re: Monitoring Squid with MRTG (nice graphics)

From: Samath Wijesundara <samath@dont-contact.us>
Date: Wed, 2 Jul 1997 21:47:38 +0600 (GMT+0600)

Stephane + Squid-Users who like MRTG for monitoring Squid,

Stephane thanks for all the help, MRTG is fine :-)

I find few things for anyone trying to configure MRTG for monitoring the squid-cache as you indicated (http://cache.cnrs.fr/MRTG/config.html)

Instead of get_url you can use the 'client' programme which comes with the squid. (I find it is in the squid distribution (I use 1.1.11) ). Just replace the get_url with squid-directory/bin/client in the script and it works.

I have seen few discussions about the get_cache_dns giving a value of zero.
I am using squid 1.1.11 and I find that there should be an Additional 'tail -1' as following in the shell script.

DNS=`./client cache_object://localhost/stats/dns | \
        head -2 | tail -1 | \
        awk '{print $3 * 60}' | \
        sed 's/}//' `

I included a new Computer LOAD Measurement using the 'w' command, which gives you a important parameter form your computer health. I use 100*load to make the load greater than 1.
(This should appear in the retrieve.txt shell script - I am using FreeBSD, and this is measuring fine the 5 minute average load, but for other UNIX machines you may have to adopt to the 'w' command o/p )

LOAD=`w | head -1 | awk '{print $9 * 100 }' `
echo "Load: $LOAD" >> $FILE

The mrtg.cfg for load graph for this can be get from a configuration similar to following,

Target[load]: `/usr/local/squid/bin/get_cache_load`
MaxBytes[load]: 1000
Title[load]: 100*Computer Load Where Squid is running
YLegend[load]: Units
ShortLegend[load]:
LegendI[load]: &nbsp;units
Legend1[load]:
LegendO[load]:
Options[load]: growright,gauge
Colours[load]: BROWN#e09010,VIOLET#ff00ff,BLUE#1000ff,ORANGE#ff8022
PageTop[load]: <H1> 100 times Computer Load
 </H1>
 <TABLE>
   <TR><TD>System:</TD><TD>proxy.slt.lk</TD></TR>
   <TR><TD>Maintainer:</TD><TD>samath@slt.lk</TD></TR>
   <TR><TD>Max Load (expected, but could be higher):</TD>
       <TD>1000</TD></TR>
  </TABLE>
 <P>This page shows the CPU Load </P>

My small cache - statistics can be viewed at

http://proxy.slt.lk/router/cache.html

- Samath
Sri Lanka

At 12:13 PM 6/30/97 +0200, you wrote:
>On Monday 30 June 97, at 13 h 50, the keyboard of Samath Wijesundara
><samath@slt.lk> wrote:
>
>> Where is the binary / executable
>> get_squid_uptime
>
>(You'll need the TimeDate Perl module as well, it's in the Perl CPAN,
>modules/by-category/06_Data_Type_Utilities/Date.)
>
>
>#!/usr/local/bin/perl
>
>#######################################################
># Get Web uptime from Squid version 1.1.1 or higher
>#######################################################
># Author: Anthony Rumble <anthony@rumble.waratah.id.au>
>#
># Revision: $Revision: 1.3 $
># Modified by Stephane Bortzmeyer <bortzmeyer@cache.cnrs.fr>
># to get uptime info
>#######################################################
>
>use strict;
>use Socket;
>use Date::Parse;
>
>my ($request) = "cache_object://localhost/info HTTP/1.0\n";# Request
>my ($host) = "localhost"; # Host
>my ($p) = 3128; # Port number
>
>my ($sin, $port, $iaddr, $paddr, $proto, $line, $uptime, $bytes);
>my ($diff, $start, $current, $ctime, $stime);
>
>$proto = getprotobyname('tcp');
>if (!$proto)
>{
> die("getsockbyname");
>}
>socket(S, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
>
>$port = shift || $p;
>
>$iaddr = gethostbyname($host);
>if (!$iaddr)
>{
> die("gethostbyname");
>}
>$sin = sockaddr_in($port, $iaddr);
>if (!$sin)
>{
> die("sockaddr_in");
>}
>connect(S, $sin) || die "connect: $!";
>
>select(S);
>$| = 1;
>select(STDOUT);
>
>print S "GET $request\n";
>
>while (<S>)
>{
> chop;
> if (/^{Start Time:\t(.*)}$/) {
> $start = $1;
> }
> if (/^{Current Time:\t(.*)}$/) {
> $current = $1;
> }
>}
>
>close(S);
>
>$stime = str2time($start);
>$ctime = str2time($current);
>
>$diff = $ctime - $stime;
>
>print &reltime2str ($diff), "\n";
>
>sub reltime2str {
> my ($time) = @_;
> my ($days, $hours, $minutes, $seconds);
> $days = int ($time / 86400);
> $time = $time - ($days * 86400);
> $hours = int ($time / 3600);
> $time = $time - ($hours * 3600);
> $minutes = int ($time / 60);
> $time = $time - ($minutes * 60);
> $seconds = $time;
> return "$days day(s) $hours hour(s) $minutes minute(s)";
>} #
>
>
>
Received on Wed Jul 02 1997 - 08:58:34 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:35:39 MST