Pinger With Python
Pinger With Python
""" This loop runs individual and sequential pings. Since ping is implemented differently on different versions of Linux and Unix, you may need to change your ping options and the regular expression that it matches to get the correct results """
ip = "192.168.38."+str(host) pingaling = os.popen("ping -q -c2 "+ip,"r") print "Testing ",ip, sys.stdout.flush() while 1: line = pingaling.readline() if not line: break igot = re.findall(lifeline,line)
if igot: print report[int(igot[0])] status=int(igot[0]) if status == 0: print "ping failed this server, can not continue Test as both servers are not available" sys.exit() print status print time.ctime()