def check_http(i):
try:
conn=httplib.HTTPConnection(i, 80, timeout=2)
conn.request("GET","/")
応答= conn.getresponse()
e:
の例外を除きます。 print "server "+i+" is down"
print e
print ""
os.system('./delete_real_server. sh '+i)
else:
#print response.read()
print "サーバー "+i+" は稼動しています"
os.system('./add_real.server.sh '+ i)
if __name__=="__main__":
httpservers=["127.0.0.1","10.0.0.1","192.168.35.28"]
while 1:
current_time=time .strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
httpservers の i の場合:
check_http(i)
print current_time+" checkfinishn"
time.sleep(60)