脑裂监控
上一篇提到的脑裂,下面这个是实验步骤
基本环境:
环境 | IP | 所需要的应用 |
---|---|---|
服务器 | 192.168.230.101 | lamp架构、zabbix server |
客户端 | 192.168.235.160 | zabbix agent、keepalived |
对脑裂的监控应在备用服务器上进行,通过添加zabbix自定义监控进行。
监控什么信息呢?监控备上有无VIP地址
开始部署
#客户端监控脚本
[root@slave scripts]# vim check_keepalived.sh
[root@slave scripts]# cat check_keepalived.sh
#!/bin/bash
if [ `ip a show ens33 |grep 192.168.230.250|wc -l` -ne 0 ]
then
echo 0
else
echo 1
fi
[root@slave scripts]# chmod +x check_keepalived.sh
[root@slave scripts]# ll
总用量 8
-rwxr-xr-x. 1 root root 118 10月 24 04:39 check_keepalived.sh
-rwxr-xr-x. 1 root root 662 10月 24 03:44 notify.sh
[root@slave ~]# cd /usr/local/etc/
[root@slave etc]# vim zabbix_agentd.conf
# Default:
UnsafeUserParameters=1 //取消注释,并改为1
# Default: SOMAXCONN (hard-coded constant, depends on system)
# ListenBacklog=
UserParameter=check_log,/scripts/check_keepalived.sh //在最后的末尾加此行(监控名称与脚本路径)
[root@slave ~]# zabbix_agentd
[root@slave ~]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10050 0.0.0.0:*
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
[root@master etc]# zabbix_get -s 192.168.230.131 -k check_log
1
web页面设置监控
添加主机