Listing 2: Poll.pl NONEXECUTABLE ######################################################################## # #Perl Script: Rapid prototype example for fetching a URL through an HTTP request # #Use poll.pl with webmonitoringmodulescript.pl # to measure Web site response time. # The script performs an http get command. # If the response is successful, the program continues. # If an error occurs, the program waits 10 seconds before continuing. # # ###################################################################### #Start the required Perl modules. use URI::URL; use LWP::UserAgent; use Getopt::Long; #Set the variable for the monitored Web site. # @ARGV acquires the Web site's name # from the timer program. $target=join("","http://",@ARGV[0]); #Identify the target URL. $url = new URI::URL $target; $ua = new LWP::UserAgent; $ua->agent("httpd-time/1.0 ". $ua->agent); #Request the target URL. $req = new HTTP::Request(GET,$url); #Perform the HTTP transaction. $get = $ua->request($req); #If the script successfully retrieves the page without errors, the script does nothing. # If an error (e.g., 404, 401) occurs, the program waits # 10 seconds to ensure that the response time exceeds baseline requirements. if ($get->is_success) {} else { #Delay the program for 10 seconds. sleep (10); } ######################################################################## # #SCRIPT ENDS HERE # ########################################################################