Script to check Server Status

by kalai 2008-03-15 14:26:16

To check whether server is up or down you can use the code given below.

<?php

$url = 'http://codingcoding.com/';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$status = curl_exec($ch);
$time = round(curl_getinfo($ch, CURLINFO_TOTAL_TIME));


if (!$status)
{
$icon = 'red';
}
else if ($time > 2)
{
$icon = 'amber';
}
else
{
$icon = 'green';
}

?>

<img src="<?php echo $icon; ?>.jpg" />

Tagged in:

2450
like
0
dislike
0
mail
flag

You must LOGIN to add comments