<?php function pingAddress($ip, $ipname){ $pingresult = shell_exec("ping -c 1 $ip"); $dead = "1 received"; $deadoralive = strpos($pingresult, $dead ); echo $ipname; echo "<br>"; if ($deadoralive){ echo " IP address $ip is ONLINE"; echo "<br>"; echo $pingresult; echo "<br>"; } else { echo " ------ IP address $ip is dead ------"; } } echo "<br><br><br>"; $ip = "192.168.1.1"; $ipname = "Router"; pingAddress($ip, $ipname); echo "<br><br><br>"; $ip = "192.168.1.30"; $ipname = "KMtronic LAN Relay board"; pingAddress($ip, $ipname); echo "<br><br><br>"; $ip = "192.168.1.31"; $ipname = "KMtronic LAN Temperature"; pingAddress($ip, $ipname); echo "<br><br><br>"; $ip = "192.168.1.32"; $ipname = "Raspberry PI / Domoticz"; pingAddress($ip, $ipname); echo "<br><br><br>"; $ip = "192.168.1.255"; $ipname = "Invented IP for test"; pingAddress($ip, $ipname); ?>
Result
Router
IP address 192.168.1.1 is ONLINE
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data. 64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=2.85 ms — 192.168.1.1 ping statistics — 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 2.858/2.858/2.858/0.000 ms
KMtronic LAN Relay board
IP address 192.168.1.30 is ONLINE
PING 192.168.1.30 (192.168.1.30) 56(84) bytes of data. 64 bytes from 192.168.1.30: icmp_seq=1 ttl=64 time=0.034 ms — 192.168.1.30 ping statistics — 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.034/0.034/0.034/0.000 ms
KMtronic LAN Temperature
IP address 192.168.1.31 is ONLINE
PING 192.168.1.31 (192.168.1.31) 56(84) bytes of data. 64 bytes from 192.168.1.31: icmp_seq=1 ttl=100 time=2.45 ms — 192.168.1.31 ping statistics — 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 2.451/2.451/2.451/0.000 ms
Raspberry PI / Domoticz
IP address 192.168.1.32 is ONLINE
PING 192.168.1.32 (192.168.1.32) 56(84) bytes of data. 64 bytes from 192.168.1.32: icmp_seq=1 ttl=100 time=1.45 ms — 192.168.1.32 ping statistics — 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 1.457/1.457/1.457/0.000 ms
InventedĀ IP for test
—— IP address 192.168.1.255 is dead ——
