Tuesday, September 9, 2008

Monitor a Site using CURL

/*
This program for the Monitoring our site status..

AZAds is a traffic exchange that we wrote.
We wanted to come up with a way to check the UP or DOWN status of a submitted URL.
Here is the solution we came up with. Can also be used for a site monitoring service.
*/

$uServer = 'http://evergreenphp.blogspot.com/';
@$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$uServer");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
@curl_exec($ch);
$errnum=curl_errno($ch);
@curl_close($ch);
if($errnum != "0") {
print "Remote Site Status: DOWN";
} else {
print "Remote Site Status: UP";
}
?>

No comments:

Popular Posts