From looks of what your doing.... you might find Alert Ping software a better solution. I bought the Alert Ping Pro edition 10 years ago and it will monitor network devices/nodes and you can set rules on what to do if a certain condition is met including calling to start batch files, and EXE files or run console type command lines when a condition is met or not met.
I used this software to build a system that monitored 7 sites and with custom rules set in it I even had a PC Speaker to VoIP phone in a cardboard box together making it to where I had a script that called my phone and when I answered it it would play recorded voice audio files for conditions could be played to me in loop telling me where the problem is.... well Me telling myself since it was in my voice so I could be anywhere and get a phone call and be made aware that something is offline or misbehaving and then i can remote into the site and fix the issue or go to the site that the trouble is being reported from and fix the issue to stop getting called about it over and over again.
Lastly to state it can monitor any device/node as long as that device is set to allow pinging to it. So I had Network Printers, Computers and Servers, Point of Sale systems and servers, Scales in Deli, Meat, and Seafood departments on it, as well as other devices such as a Managed Switch or a Bridge connection from one site to another with latency info. And for one site that had these Copper-Link Modems that acted like a private DSL bridge connection at 2.4MB/2.4MB network bridge over a rented copper pair from the telephone company that we had listed with them as a burglar alarm circuit for reason we needed it were susceptible to static from bad storms ( Electro Magnetic Noise ) and the modems would get hung and unable to handshake and so the network bridge would go down and so I also had rules to have a script that worked with Web Power Control devices that would shut a relay off that the modems were powered through at each end and then relay would turn back on connecting them to 120VAC again and they would sync up and then network would fix itself from automated scripts that ran with the rules set in Alert Ping Pro.
Yes its $17 but I got a sweet raise from constructing this automated "Correction and Reporting System" project at the time and got reimbursed for the $17 cost. It made my job easier knowing what is going on and where at any time. As well as a system that would fix problems for me.
http://www.bestshareware.net/alert-ping.htm