如题,那么个东西,可以一次性ping一堆网站,看看哪个挂掉了.方便系统管理员用的东西,不必被动地等用户来叫了才知道网站挂了.以前还写了个exe的,不过是会检查返回的页面是不是包含特定的关键字的,相比起来更有可信度,不然一个404的网站,ping返回还是正常的呢.
贴点关键代码:
[code=’php’]
$result = ping_site($_POST[“site”]);
$ip = “N/A”;
$ttl = “N/A”;
$time = “N/A”;
if($result != “Fail”)
{
$start = stripos($result, “from “) + 5;
$length = stripos($result, “:”) – stripos($result, “from “) – 5;
$ip = substr($result, $start, $length);
$start = stripos($result, “ttl=”) + 4;
$length = stripos($result, ” time=”) – stripos($result, “ttl=”) – 4;
$ttl = substr($result, $start, $length);
$start = stripos($result, “time=”) + 5;
$length = stripos($result, ” ms”) – stripos($result, “time=”) – 5;
$time = substr($result, $start, $length).” ms”;
echo “
“;
}
else
{
echo “
“;
}
function ping_site($target)
{
$command = “ping -c 1 $target”;
exec($command, $result);
if($result[1] == “”) { return “Fail”; }
else { return $result[1]; }
}
[/code]
跟这网站 http://www.51scan.cn 差不多吧。除PING 以外还监测端口。还提供免费的短信告警功能