例子,用python检测lvs real 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 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)
您可能感兴趣的文章:
Lvs DR模式实现负载均衡
LVS-DR方式的配置一例
lvs实现故障转移(backup)的配置实例
几个负载均衡软件比较(Haproxy、LVS、Nginx)
LVS-DR模式配置一例
LVS 和 realserver工作在同一机器上的实现方法
LVS调度算法和三种工作模式
LVS负载均衡-NAT模式实验
LVS负载均衡-TUN模式实验
lvs负载均衡-DR模式实验