LVS Health Detection Script
Writing is not good, basic realization, because the basic will not be used, there is time to improve, hehe
1 #!/bin/bash
2
3 rs= (' 192.168.61.130 ' 192.168.61.132 ')
4 vip= "192.168.61.100"
5 dip= "192.168.61.131"
6 Checkcount=1
7 checkloop=4
8 I=1
9
10
One while [$i-lt 2];d o
#sorry server detection, Director httpd default boot
If [$ (ipvsadm-ln |grep "\->" |wc-l)-lt 2];then
Ipvsadm-a-T $VIP ": $"-R $dip-G
All else
ipvsadm-d-T $vip ": Up"-R $dip-G
+ fi
18
#循环所有RS检测
Rs_x in ${rs[@]};d o
#只要在线并且之前已经下线的, on-line processing
If Curl--connect-timeout 2-s "/http" $rs _x "/index.html" &>/dev/null;then
Ipvsadm-ln |grep $rs _x &>/dev/null
If [$?-ne 0];then
Ipvsadm-a-T $vip ": Up"-R $rs _x &>/dev/null
#echo "Add Rs1 server OK"
+ fi
-Else
#当RS是刚离线的, every 1 seconds detection, detection 3 times is not online on the offline, if it is not done before the offline processing
Ipvsadm-ln |grep $rs _x &>/dev/null
If [$?-eq 0];then
[$checkcount-le $checkloop];d o
If Curl--connect-timeout 1-s "/http" $rs _x "index.html" &>/dev/null;then
Break
+ Else
checkcount++
Panax Notoginseng fi
If [$checkcount-eq 3];then
If Ipvsadm-ln |grep $rs _x &>/dev/null;then
ipvsadm-d-T $vip ": Up"-R $rs _x &>/dev/null
#echo "del rs1 server OK"
Break
+ fi
-Fi
1 sleep
Done
Checkcount=1
-Fi
49
Fi
Wuyi Done
52
3 Sleep
Wu Done
LVS Health Detection Script