keepalived 脑裂监听脚本

2022-05-18 15:52:10 浏览数 (1)

!/bin/bash

while true do Master=10.0.0.10 Backup=10.0.0.11 Vip=10.0.0.100 M_num01=/bin/ping -c 2 -W 3 $Master >/dev/null 2>&1 ; echo $? B_num01=/bin/ping -c 2 -W 3 $Backup >/dev/null 2>&1 ; echo $?

M_num02=ssh $Master ip add|grep $Vip|wc -l

B_num02=ssh $Backup ip add|grep $Vip|wc -l

代码语言:javascript复制
    if [ "$M_num02" -ne 0 -a "$B_num02" -ne 0 ];then
            echo "The server suffered a brain fracture"
    else
            echo "Server normal"
    fi

done

0 人点赞