# get site headers if it is reachable # create the agent my $ua = new LWP::UserAgent; my $url = "https://" . $site; # try to connect my $resp = $ua->get($url); # we don't care if the response code is a 200, 300, or 400 but 500 is still a # bad thing if ($resp->code >= 500) { $resp_line = $resp->status_line ? $resp->status_line : "Unable to connect to " . $site; $resp_headers = ""; $status_color = "red"; } else { $resp_line = $resp->protocol . " " . $resp->status_line; $resp_headers = $resp->headers_as_string; chomp($resp_headers); } # calculate Elapsed Time my $et = tv_interval ($t0); my $time = localtime; my $httpout = sprintf $HTTPFMT, $site, "http", $status_color, $time, $url, $resp_line, $resp_headers, $et; # send output to xymon send_2_xymon($XYMON_SVR, $XYMON_PORT, $httpout);