I fixed it. Thank you.
.....
There is no problem to reuse the code.
I'm building mining farm monitoring too and this is just the first part.
Next month when I have little more time, I will do the monitoring of the environment (temp, humidity, smoke detector & etc.). If temp is hotter , turn on the vents and so on. Also I will build a basic webpage for configuration and statistics.
Of course I think to add another functionality to check miners from the miners statistics.
FIrst check ping, second check the hashrate of the machines. If the miner is stuck, hard-reset again.,
but Mine can't be dependent on an internet connection for auto-rebooting rigs, because there are unique conditions that add hiccups in my ability to remotely send reboot commands.
I don't understand why the internet connection is problem. My code is pinging the machines in the local network, so even without working internet it will show that machines are working, because they are on the local network.