Network Status Notification for Internet:
import commands as cd from testclassdec import myclass x=myclass() while 1: fileforpin = open("pin.txt","r") output = cd.getoutput("ping -c 1 210.212.252.25") dte = cd.getoutput("date") res = output.split(" ") l = fileforpin.read() fileforpin.close() if(res[0] == "connect:"): if(l != "a"): print("Network is down") string = "Network is down at : " + str(dte) x.sendsms(9790834921,string) filetowrite = open("pin.txt","w") filetowrite.write("a") filetowrite.close() else: filetoclear = open("pin.txt","w") filetoclear.write(" ") filetoclear.close()
Network Status Notification for Intranet:
import commands as cd from testclassdec import myclass x=myclass() while 1: fileforpin = open("pin.txt","r") output = cd.getoutput("ping -c 1 192.168.1.148") dte = cd.getoutput("date") res = output.split(" ") flag = fileforpin.read() fileforpin.close() if(res[0] == "connect:"): if(flag != "a"): print("Network is down") string = "Network is down at : " + str(dte) x.sendsms(9790834921,string) filetowrite = open("pin.txt","w") filetowrite.write("a") filetowrite.close() else: filetoclear = open("pin.txt","w") filetoclear.write(" ") filetoclear.close()
With Regards, Thanga.
|
No feedbacks found. Be the first to respond and make money from revenue sharing program.
|