Perhaps I was the only one getting this problem, 'cause I never heard
about it on the list, but there's probably something to be learned from
this experience, so here goes:
$ ./phttp.monitor www2
Use of uninitialized value at ./phttp.monitor line 685.
www2(2)
Detail for id:1 -> www2(2)
+ resolving www2 succeeded
+ pack_sockaddr_in command succeeded
+ socket command succeeded
+ fcntl command succeeded
+ first connect succeeded
+ reconnect command succeeded EISCONN : Socket is already connected
+ syswrite command succeeded
- did not match the pattern expected
OK, something's wrong with the web server, but what? And why is
my friend and loyal assistant, phttp.monitor, issuing Perl warnings?
$ telnet www2 80
Trying 192.168.1.1
Connected to www2.example.com (192.168.1.1)
Escape character is '^]'.
GET / HTTP/1.0
Connection closed by foreign host.
Hmmm, I typed in the GET and got back just a null response. Turned
out Apache was issuing "Out of memory!" errors.
The problem with phttp.monitor turned out to be that if the response
received from the web server is zero bytes long, $rbuf is
"uninitialized" and trips the Perl warnings. This was really
annoying because once or twice my boss got paged with "Use of
uninitialized value...", not exactly a vote of confidence in the
monitoring system.
Patch to fix the problem (and to show the length of the response in
the diagnostic output) is below.
--- phttp.monitor 2001/10/10 15:33:09 1.2
+++ phttp.monitor 2002/02/09 11:59:35
@@ -677,7 +677,7 @@
sub analyse_race {
$debugGeneral and print "ANALYSING RESPONSES\n";
foreach my $id (sort { $a <=> $b } keys(%goodrace)) {
- my $rbuf = $client{$id}{'rbuf'};
+ my $rbuf = $client{$id}{'rbuf'} || "";
my $host = $client{$id}{'host'};
my $timeresponse = $client{$id}{'end'} - $client{$id}{'begin'};
$debugAnalyse and print "$host response in $timeresponse s :\n$rbuf";
@@ -697,7 +697,7 @@
$pacerace{$id}++;
};
}else{
- $client{$id}{"problem"} .= "- did not match the pattern
expected\n";
+ $client{$id}{"problem"} .= "- did not match the pattern
+expected, response was " . length($rbuf) . " bytes\n";
$badrace{$id}++;
}
}