#!/usr/bin/perl ############################################################## # By BumbleBeeWare.com 2006 # server monitoring with perl # program to access each server/website and give status response ############################################################## # setup array of servers/websites to check @sitestocheck = ('mywebsite.com','mywebsite2.com'); # the relative url of the website response script in each site $responseprogram = "/cgi-bin/mystatus1.cgi"; # refresh time in seconds 5 minutes is 300 seconds $refreshtime = 300; ############################################################### # End Configuration ############################################################### # main program use LWP::UserAgent; # print page print "Content-type: text/html\n\n"; print " Server Status "; # now check each url in your array foreach $sitetocheck (@sitestocheck){ $ua = new LWP::UserAgent; $req = new HTTP::Request 'GET',"http://$sitetocheck$responseprogram"; $res = $ua->request($req); if ($res->is_success) { if ($res->content =~ /I AM WORKING/i){print "SERVER OK - $sitetocheck
\n";} else {print "WARNING! There appears to be a problem, FIX ME!
\n";} } else { $timestamp = localtime; print "UNABLE TO CONNECT TO $sitetocheck on $timestamp"; } print "
\n"; } print ""; exit;