[rrd-users] Detecting poor web server response.

Stanley Hopcroft Stanley.Hopcroft at IPAustralia.Gov.AU
Fri Sep 20 12:43:11 MEST 2002

Dear Sir,

It seems to me that there are 2 parts to the problem you have raised

1 Getting a sequence of URLs and timing how long they take
2 Archiving the data (with RRD).

Part 2 is a matter of designing your RRD and using one of a number of
standard documented ways to update it.

Part 1 is also a problem with many standard solutions, among which

.. (Netsaint) a shell/perl wrapper around check_http

.. other standard 'service checks' of web servers (Big Brother etc)

.. a Perl program using LWP


.. the HTTP::MonkeyWrench module (SourceForge not CPAN) with the
associated HTTP::TestEngine.

In the first cases, you are going to have to deal with timeouts
yourself, while 'MonkeyWrench may accept a timeout parameter.

Here's something to get you started if you role your own :-

#!/usr/bin/perl -w

use strict ;

use LWP::Simple ;
use Time:HiRes qw(gettimeofday tv_interval) ;

$SIG{"ALRM"} = sub { die "Alarm clock restart" } ;

my @urls = qw(http://site1/ http://site2/ ...) ;
my @elapsed ;

foreach (@urls) {
   eval {
     alarm(10) ;	# your timeout value
     my $t0 = [gettimeofday] ;
     my $content = get($_) ;
     my $elapsed = tv_interval ($t0) ;
     push @elapsed, $elapsed ;
     alarm(0) ;
  if ($@ =~ /Alarm clock restart/) {
     push @elapsed, 10 ;
  } else {
    die "Error in eval: $@\n" ;
    			# or do something appropriate

# do something with @elapsed

This simple approach will _not_ work if you 

 . need methods other than GET
 . require to set a user-agent header
 . need to handle HTTP errors
 . need password authentication
 . access sites via proxy

For these you would be better off with LWP, HTTP::MonkeyWrench or
wrapping wget etc


Yours sincerely.

Stanley Hopcroft

'...No man is an island, entire of itself; every man is a piece of the
continent, a part of the main. If a clod be washed away by the sea,
Europe is the less, as well as if a promontory were, as well as if a
manor of thy friend's or of thine own were. Any man's death diminishes
me, because I am involved in mankind; and therefore never send to know
for whom the bell tolls; it tolls for thee...'

from Meditation 17, J Donne.

Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi

More information about the rrd-users mailing list