IP monitor

Forums:

IP Checker (piping.py) One of the things I wanted to add was the ability to monitor the status of all of the Raspberry Pi Overwatch units. I will run this on a few of the servers and then push it to the upload directory so it gets pushed to the base unit server. I may possibly add a wemo toggle to flip the power on/off to reset the unit completely but have not done so at this time. This should help to insure that the camera units are all operating as expected and something that I have meaning to do for some time now. The current source is below but I am adding more so you may want to wait until it is completed. This is just a simple IP mon that will dump an html table with the current status that I can stick on any page. Mouse over lists the last octet since I know what the base subnet mask is already.
RTRPi1!Pi2Pi3Pi4!Pi5Pi6
I have added it to the bottom of the bottom of the overwatch home page so that it now also shows the status of the units. This was done easily by simply adding an iframe right before the end body tag and pointing the src= to the output file. I then added a crontab to fire it off every 5 minutes using * /5 * * *. Due to it's location, you have to run sudo python.
Source: import os #piping.py ip monitor plist=['1','10','11','12','13','14','15;] nlist=['RTR','Pi1','Pi2','Pi3','Pi4','Pi5','Pi6'] def writep(dat): f = open("pr.html","w") f.write(dat) f.close() def getping(ip): cmd='ping -c 1 -W 1 {0}'.format(ip) print("Command {0}".format(cmd)) pval=os.popen(cmd) r=pval.read() return r.find('1 received') def runp(): pdat='' for x in plist: rp=getping("{0}{1}".format("192.168.1.",x)) rslt="" if rp > -1: rslt="<td style=\'background-color:#d6ffab\'>{0} OK</td>".format(nlist[cnt],x,rp) else: rslt="<td style=\'background-color:#ff3b62\'>{0} DN</td>".format(nlist[cnt],x,rp) pdat=pdat+rslt writep("<table border=0>{0}</table>".format(pdat)) runp()