LVS Health Detection Script

Source: Internet
Author: User

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


3 rs= (' ' ')

4 vip= ""

5 dip= ""

6 Checkcount=1

7 checkloop=4

8 I=1



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



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


#当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


+ Else


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"


+ fi


1 sleep






Wuyi Done


3 Sleep

Wu Done

LVS Health Detection Script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.