亲宝软件园·资讯

展开

python检测lvs real server状态 python检测lvs real server状态

人气:0
想了解python检测lvs real server状态的相关内容吗,在本文为您仔细讲解python检测lvs real server状态的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:检测lvs,server状态,下面大家一起来学习吧。

复制代码 代码如下:

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)

加载全部内容

相关教程
猜你喜欢
用户评论