[mrtg] Re: Apache monitor scripts - latest versions

Daniel J McDonald dan.mcdonald at austinenergy.com
Thu Feb 23 19:54:08 MET 2006


On Thu, 2006-02-23 at 16:57 +0000, David Herring wrote:
> hello,
> 
> first post - so happy to take pointers to best mrtg sites, etc....

> Also, has anyone done a script that does a 'web ping' for web server
> response time / correctness - kind of a big brother / what's up gold etc
> type of monitor for mrtg.

Yes, but I had to stop running it.  Seems I was 95% of the traffic ;-)

But I'd recommend that you use hobbit instead - it's much more feature
rich, already knows how to track apache stats, and has good alarms.

Anyway, the script is here in-line.  I don't remember if I modified it
or not.

#!/usr/bin/perl
##########################################################
# SYNTAX ./httpGet.pl [http://www.myserver.com/page_to_get.htm]
# Version : 1.0 tom_vandevelde at yahoo.com
###########################################################
package Page;
$returnedRes;

sub get{
        use LWP::UserAgent;

        $get_page = @_[1];
        $ua = new LWP::UserAgent;

        $request = new HTTP::Request('GET',$get_page);
        $request->header(Expires=> "Mon, 26 Jul 1997 05:00:00 GMT");

        my $response = $ua->request($request);

        if($response->code == 200) {
                $returnedRes=$response->content;
                return 0;
        } else {
                return 1;
        }
}

sub size{
        return length($returnedRes);
}


package main;
use Time::HiRes qw(usleep gettimeofday tv_interval);
my $page=Page;
$check_url= $ARGV[0];

($s, $usec) = gettimeofday;
$t0 = [gettimeofday];
$res=$page->get($check_url);
$elapsed1 = tv_interval ($t0);
if ($res==0){
     printf("%.3f\n",$elapsed1);
     printf("%.3f\n",$elapsed1);
     print "(check successful)\n";
     print "$check_url\n";
     exit (0);
}else{
     printf("\n");
     printf("\n");
     print "(Cannot check)\n";
     print "$check_url\n";
}
exit(1);


-- 
Daniel J McDonald, CCIE # 2495, CNX, CISSP # 78281
Austin Energy
dan.mcdonald at austinenergy.com


gpg Key: http://austinnetworkdesign.com/pgp.key
Key fingerprint = B527 F53D 0C8C D38B DCC7  901D 2F19 A13A 22E8 A76A

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



More information about the mrtg mailing list