标签:监控脚本
检测思路:正常情况下keepalived的VIP地址是在主节点上的,如果在从节点发现了VIP,就设置报警信息
脚本如下:
#!/bin/bash # 检查脑裂的脚本,在备节点上进行部署 LB01_VIP=10.10.10.229 LB01_IP=10.10.10.129 LB02_IP=10.10.10.130 while true do ping -c 2 -W 3 $LB01_VIP &>/dev/null if [ $? -eq 0 -a `ip add|grep "$LB01_VIP"|wc -l` -eq 1 ];then echo "ha is brain." else echo "ha is ok" fi sleep 5 done 执行结果如下: [root@mysql-master mysqlbackup]# bash check_split_brain.sh ha is ok ha is ok ha is ok ha is ok 当发现异常时候的执行结果: [root@mysql-master mysqlbackup]# bash check_split_brain.sh ha is ok ha is ok ha is ok ha is ok ha is brain. ha is brain.
说明:可以将此脚本与监控平台进行结合(比如zabbix以及nagios等)
本文出自 “冰冻vs西瓜” 博客,请务必保留此出处http://molewan.blog.51cto.com/287340/1880210
标签:监控脚本
原文地址:http://molewan.blog.51cto.com/287340/1880210