Here is my simple URL Monitor written in PERL. The base Activestate PERL download includes all of the required modules for this code to run on Windows. This utility will be bundled with the 1.4 release of OpenESM. This monitor does not require any Tivoli resources.
#!c:/perl/bin/perl
use Time::HiRes;
use HTTP::Request;
use LWP::UserAgent;
use Time::localtime;
my $URLOUT="openesm_url_perfmon.txt";
my $URLLIST= shift;
open(IN, "$URLLIST");
while(
chomp;
$URL = $_;
$now = ctime();
$s1 = Time::HiRes::time;
$ua = LWP::UserAgent->new;
#UNCOMMENT THE LINE BELOW AND INSERT YOUR PROXY NAME IF NEEDED
#$ua->proxy('http', 'http://xx.xx.xx.xx:8080/');
$request = HTTP::Request->new(GET => $URL);
$response = $ua->request($request);
$ucode = $response->code,;
$umess = $response->message,;
$s2 = Time::HiRes::time;
$resptime = ($s2 - $s1);
$OUTFILE = ">> $URLOUT";
open(OUT, $OUTFILE);
print OUT "$now,$URL,$resptime,$umess,$ucode";
#INSERT ALERTING LOGIC HERE
#SUCH AS WPOSTEMSG OR SNMPTRAP
}
close(OUT);
No comments:
Post a Comment