Forum Moderators: coopster
<?php
$urllist = array("http://example.com/", "http://example2.com/file.ext"); // set these to the files you want to check or remove the end part to check a full domain
set_time_limit(5000); // make sure the script doesn't time out too soon
echo("<table border='1'>"); // create a table
echo("<tr><th>#<th>URL<th>STATUS</tr>"); // more table stuff
for($i=0;$i<count($urllist);$i++){ // loops through each URL in $urllist
if($handle[$i] = @fopen($urllist[$i], 'r')){ // if the server responds
stream_set_timeout($handle[$i], 2); // set the timeout to 2 seconds so that it doesn't waste time
echo("<tr><td>".$i."</td><td><a href=" . $urllist[$i] . ">" . $urllist[$i] . "</a></td><td>Working</td></tr>\n"); // print the url and the status (working)
}
else{ // if the server does not respond
$message="$i\n\n$urllist[$i]";
mail("email@example3.com","Server is down", $message,"From: <notifications@example3.com>\nContent-Type: text/plain");
echo("<tr><td>".$i."</td><td><a href=" . $urllist[$i] . ">" . $urllist[$i] . "</a></td><td>Not Working</td></tr>\n"); // print url and status (not working)
}
}
echo("</tr></table><br>\n"); // end the table
?>
I was thinking of running this in the background as a cron job to periodically check the status of a few domains with known downtime status issues.
[edited by: eelixduppy at 5:30 pm (utc) on Oct. 22, 2007]
[ibm.com...]
ties together some shell script, cURL, and RRDTool to graph the response of your server over time.
Sean