I am trying to make a page in PHP and HTML that pings a list of IP's in a file called ips.txt
and returns it to a nic HTML / PHP page where I show said data in the following format
IP - Latency
And I have no clue how I would tackle this issue. I could ping every IP but how would I show that data? And how would I format it? I could use exec()
But I have no clue. If anyone knows any smart way to do it and could point me in the right direction that would be great.
Thanks
For good start
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<ol>
<?php
$lists =['1.1.1.1', '8.8.8.8','8.8.8.4','080'];
$output=null;
$retval=null;
foreach($lists as $ip)
{
$output=null;
$retval=null;
exec('ping '.$ip.' -n 1 -w 100', $output, $retval);
if($output[0] != '')
echo '<li>'.$ip.' = '.$output[0].'</li>';
else
echo '<li>'.$ip.' = '.$output[5].'</li>';
}
?>
</ol>
<body>
</html>
This output this
1) 1.1.1.1 = Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
2) 8.8.8.8 = Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
3) 8.8.8.4 = Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),
4) 080 = Ping request could not find host 080. Please check the name and try again.