2
I'm continuously retrieving data from a remote sensor connected over Ethernet via a switch. I see that about twice per hour, the connection breaks down for a couple of seconds.
I know that the remote sensor doesn't reboot (it would log this), but I can't ping it anymore. Now I need to know if my connection to the Ethernet switch breaks down, or if it's the network connection of the sensor.
Any idea how?
1A little script: ping to the sensors with the counter set to 1 (only one ping). If up wait nn seconds and repeat. If ping doesn't answer then ping to a well known and working ip (e.g. 8.8.8.8). If it answers it is down the connection with the sensors, if it doesn't it is down the internet connection. – Hastur – 2016-04-25T09:44:36.843
That's a good idea actually. I can just connect something to the switch where i'm rather sure it's stable. Than I run two endless ping commands, one to the sensor, one to the know good device. If I see timeouts in both, it's the PC or the switch. If it's only the sensor, it's the sensor. – fschmitt – 2016-04-25T10:53:02.313
Try with a ping with interval of 1 second. Catch the exit status (in bash
$?
) or use it directly. In a one line bashwhile : ; do ping -c 1 ip_sensor || ping -c 8.8.8.8 && echo " Sensor Down" || echo " Internet down" ; sleep 1s; done
. Translate it for windows or use a bash under windows (cygwin, native if win 10, virtual machine [ok the last one too much :-) ]). – Hastur – 2016-04-25T11:08:57.687