python檢測lvs real server狀態(tài)
import httplib
import os
import time
def check_http(i):
try:
conn=httplib.HTTPConnection(i, 80, timeout=2)
conn.request("GET","/")
response = conn.getresponse()
except Exception as e:
print "server "+i+" is down"
print e
print ""
os.system('./delete_real_server.sh '+i)
else:
#print response.read()
print "server "+i+" is up\n"
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()))
for i in httpservers:
check_http(i)
print current_time+" check finish\n"
time.sleep(60)
相關文章
python不使用for計算兩組、多個矩形兩兩間的iou方式
今天小編就為大家分享一篇python不使用for計算兩組、多個矩形兩兩間的iou方式,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-01-01在django項目中導出數(shù)據(jù)到excel文件并實現(xiàn)下載的功能
這篇文章主要介紹了在django項目中導出數(shù)據(jù)到excel文件并實現(xiàn)下載的功能,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-03-03在Python函數(shù)中輸入任意數(shù)量參數(shù)的實例
今天小編就為大家分享一篇在Python函數(shù)中輸入任意數(shù)量參數(shù)的實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-07-07python實現(xiàn)畫出e指數(shù)函數(shù)的圖像
今天小編就為大家分享一篇python實現(xiàn)畫出e指數(shù)函數(shù)的圖像,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-11-11Python3網(wǎng)絡爬蟲中的requests高級用法詳解
本節(jié)我們再來了解下 Requests 的一些高級用法,如文件上傳,代理設置,Cookies 設置等等。感興趣的朋友跟隨小編一起看看吧2019-06-06