任何人都可以帮我获取检查多个主机的ping和端口连接的脚本。
<?php
echo "testing ";
function ping($host)
{
exec(sprintf('ping -c 1 -W 5 %s', escapeshellarg($host)), $res, $rval);
return $rval === 0;
}
$host = 'www.google.com';
$up = ping($host);
if($up)
echo "success";
else
echo "Failure";
?>