[mrtg] Re: Modified your pageload.pl script

Garnel, Eric egarnel at Question.com
Thu Jul 26 21:44:55 MEST 2001


Cool!  I will post the new script up on the site with the mod info & kudos
to you.  Yeah .. the typo comes from using the cheesy file manager on
geocities to edit my pages. The editor will mangle ">"  and "<" when you
copy and paste html code over. I get tired of typing &gt; and &lt; all the
time!

 -----Original Message-----
From: 	Adam Augustine [mailto:adam_augustine at morinda.com] 
Sent:	Thursday, July 26, 2001 2:27 PM
To:	'egarnel at question.com'
Subject:	Modified your pageload.pl script

I modified your pageload.pl script to be a bit more generic, and thought you
might be interested in the result. It isn't much, just taking command line
arguments and tweaking the output to work nicely with rateup (rather than
RRDTool).

Your web page says that you need to multiply it by 1000000 in order to get
it to work with rateup, which doesn't work exactly. I think rateup chokes on
the large number (at least when writing it to the log file), so I changed it
so it multiplies by 1000 and does an int on the result.

The web page also has the sample mrtg.cfg file, which is great, but has a
typo on the PageTop line:

PageTop[crvload2]: -H1-Pageload times for www.www.com-/H1-

Should read:

PageTop[crvload2]: <H1>Pageload times for www.www.com</H1>

Anyway for what its worth:

#!/usr/bin/perl
#
# This script is free to use
# No warranty or copyright
#Use at your own discretion
use LWP::UserAgent;
use Time::HiRes qw ( gettimeofday tv_interval);

unless ($#ARGV eq 1) {

print <<ETX;

Usage: pageload.pl <URL> <text to search for>

ETX
exit;
}

$ua = new LWP::UserAgent;
#$URL ='http://intranet.morinda.com/proxy.cgi';
$URL = $ARGV[0];
$search_target = $ARGV[1];
$t0 = [gettimeofday];
$req = new HTTP::Request GET => $URL;
$foo = $ua->request($req);
$response = $$foo{_content};
$t1 = [gettimeofday];
$elapsed = tv_interval($t0,$t1);
$elapsed = int (1000*$elapsed);
# place some content from the page being retrieved below
if ($response =~ /$search_target/i) {
        print "1\n$elapsed\n0\n0\n";
}
else {
        print "0\n0\n0\n0\n";
}

Thanks for the script,
	Adam


--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the mrtg mailing list