gutbobs has asked for the wisdom of the Perl Monks concerning the following question:
I'm developing a system that monitors around 100 proxy servers. The proxy servers have a web page on them that displays the system status and I can't get this info out of them via SNMP.
I'm trying to replace a bash script that uses lynx to browse to the appropriate page because lynx falls over if the password is wrong. I've got the following code, which works, but when one of the proxy servers is switched off the time out period is being ignored and there is a pause of nearly 4 minutes whilst the perl script sits round doing nothing. My code is below.
It's running on Ubuntu 8.04 server (kernel is 2.6.15-26) and perl is version 5.8.7. WWW::Mechanize should be the latest version
Am I missing something obvious? I've done various searches and can't see what might be wrong#!/usr/bin/perl use WWW::Mechanize; use MIME::Base64; use warnings; $PASSWORD=$ARGV[1]; $IPADDRESS="HTTPS://" . $ARGV[0]; print "IP Address:$ARGV[0]\n"; print "Password:$ARGV[1]\n"; my $mech=WWW::Mechanize->new( stack_depth => 0, timeout => 10, autocheck => 0, ); #$mech->agent_alias( 'Windows IE 6' ); my @args = ( Authorization => "Basic " . MIME::Base64::encode( 'manage +r' . ':' . $PASSWORD )); $mech->get( $IPADDRESS, @args ); if ( $mech->success( ) ) { print "OK:",$mech->response->status_line(),"\n"; $EXIT_CODE=0; } else { print "Fail:",$mech->response->status_line(),"\n"; $EXIT_CODE=1; } #print $mech->content(); print "Exiting with exit code:$EXIT_CODE\n"; exit($EXIT_CODE)
Cheers
Rich
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: WWW::Mechanize Timeout period
by jrsimmon (Hermit) on Jul 27, 2009 at 16:05 UTC | |
by alexm (Chaplain) on Jul 27, 2009 at 22:54 UTC | |
|
Re: WWW::Mechanize Timeout period
by Anonymous Monk on Jul 27, 2009 at 16:03 UTC | |
|
Re: WWW::Mechanize Timeout period
by alexm (Chaplain) on Jul 27, 2009 at 23:01 UTC | |
by gutbobs (Initiate) on Jul 28, 2009 at 08:00 UTC | |
by alexm (Chaplain) on Jul 29, 2009 at 19:31 UTC |