but it is still not making the expected resultwhat is the expected result? what is the observed result?
use LWP:::Simple; my $res = get( $target ); if( is_success($res) ){ ... }else{ ... }
sub check_url { # subroutine who check given URL my $target = shift; my $response_limit = shift; my $time = time; # Start timer my($result, $rc, $error); my $res = get( $target ); if( is_success($res) ){ $time = sprintf "Response %d seconds", (time - $time); if ($response_limit && ($time >= $response_limit)) { # note + bugfix of direction of inequality $error = "Slow response from $target\: $time seconds"; ($rc, $result) = (-1, "SLOW"); } else { ($rc, $result) = (1, "ACCESSED"); } } else { # Error .... Site is DOWN and script send + e-mail to you.. ($rc, $result, $time) = (0, "DOWN", "N/A"); $error = "$target is DOWN." . $res; } push @errors, $error if defined $error; my $out_format = "| %-50.50s %-10s %-20s |\n"; printf OUT $out_format, $target, $result, $time; printf $out_format, $target, $result, $time; return $rc; }
In reply to Re: Script to monitor
by davidrw
in thread Script to monitor
by onomejiro
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |