Alexander Serkin wrote:
>
> Samath Wijesundera wrote:
> >
> >
> > This looks ok ! I tried to set the things up But I have the following questions.
> >
> > 1. On the mrtg.cfg you have lines such as
> >
> > Target[descr]: `/usr/local/lib/MRTG/get_cache_descr`
> >
> > On MRTG I think you need a executable with the above name (ie
> > get_cache_descr) for its opration ! Are these missing at the
> > http://cache.cnrs.fr/MRTG/config.html
>
> And is there an example of get_squid_uptime ?
I checked in about that, too ... see attachment ...
> > 2. How are executing your retrieve.script and echoping. Are you doing this
> > on a cron job ? or mrtg it do this automatically every time it is called !
> Actually i see stats only on file descriptors' usage. Bytes, Requests,
> DNS remains empty.
You have to changed read.txt to the appropriate filenames as listet in
mrtg.cfg ... that is, replace "Descr:" by the other field names and save
under the other file names ...
> Target[requests]: `/usr/src/cache/get_cache_requests`
get_cache_requests would have the line:
DESCR=` awk '/Requests:/ {print $2}' $FILE`
> By that time mrtg had been living in cron for an hour.
Could be that this happens due to the missing get_squid_uptime ...
gg
#!/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\@janus HTTP/1.0\n";# Request
my ($host) = "localhost"; # Host
my ($p) = 8080; # 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 Mon Jun 30 1997 - 07:27:40 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:35:35 MST