import os import re import time import sys
lifeline = re.compile(r"(\d) received") report = ("No response","Partial Response","Alive")
print "running pres setup method()" print time.ctime()
for host in range(128,130):
""" 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()