手机
当前位置:查字典教程网 >脚本专栏 >python >python检测lvs real server状态
python检测lvs real server状态
摘要:复制代码代码如下:importhttplibimportosimporttimedefcheck_http(i):try:conn=http...

复制代码 代码如下:

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 upn"

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 finishn"

time.sleep(60)

【python检测lvs real server状态】相关文章:

python解析文件示例

Python 开发Activex组件方法

使用go和python递归删除.ds store文件的方法

python连接池实现示例程序

python正则表达式re模块详解

python获取网页状态码示例

python显示天气预报

用Python和MD5实现网站挂马检测程序

python encode和decode的妙用

python client使用http post 到server端的代码

精品推荐
分类导航