获得';状态';通过PHP在网络上对机器的访问
我需要或多或少地获得一个表,该表报告本地网络上机器的IP,以及是否可以找到它 我已经设置了20台机器,都是静态IP地址,从获得';状态';通过PHP在网络上对机器的访问,php,html,arrays,ip,ip-address,Php,Html,Arrays,Ip,Ip Address,我需要或多或少地获得一个表,该表报告本地网络上机器的IP,以及是否可以找到它 我已经设置了20台机器,都是静态IP地址,从192.168.1.111到192.168.1.120 如何检查机器是否“联机”,并将其状态报告回网页 目前,我正在这样做: <?php $nodes = array( "192.168.1.111", "192.168.1.112", "192.168.1.113", "192.168.1.11
192.168.1.111到192.168.1.120
如何检查机器是否“联机”,并将其状态报告回网页
目前,我正在这样做:
<?php
$nodes = array(
"192.168.1.111",
"192.168.1.112",
"192.168.1.113",
"192.168.1.114", // offline
);
$table = "";
for($i = 0; $i < count($nodes); ++$i) {
exec("ping -c 4 " . $nodes[$i], $output, $result);
if ($result == 0) {
// echo "Ping successful!";
$table += "<tr>";
$table += "<td>Node " . $i . "</td>";
$table += "<td> " . $nodes[$i] . "</td>";
$table += "<td>Ready</td>";
$table += "</tr>";
} else {
// echo "Ping unsuccessful!";
$table += "<tr>";
$table += "<td>Node " . $i . "</td>";
$table += "<td> " . $nodes[$i] . "</td>";
$table += "<td>Offline</td>";
$table += "</tr>";
}
}
echo $table;
?>
请尝试以下操作,或使用/bin/ping-n3
<?php
function pingAddress($ip) {
$pingresult = exec("/bin/ping -n 3 $ip", $outcome, $status);
if (0 == $status) {
return = True;
} else {
return = False;
}
}
pingAddress("127.0.0.1");
?>
<?php
function pingAddress($ip) {
$pingresult = exec("/bin/ping -n 3 $ip", $outcome, $status);
if (0 == $status) {
return = True;
} else {
return = False;
}
}
pingAddress("127.0.0.1");
?>