标签:判断 mysq zabbix cas case show des stat ase
#!/bin/bash
#Desc:用于获取主从同步信息,判断主从是否出现异常,然后提交给zabbix
#Date: 2020-06-08
USER="用户名"
PASSWD="密码"
NAME=$1
function IO {
Slave_IO_Running=`mysql -u $USER -p$PASSWD -e "show slave status\G;" 2> /dev/null |grep Slave_IO_Running |awk ‘{print $2}‘`
if [ $Slave_IO_Running == "Yes" ];then
echo 1
else
echo 0
fi
}
function SQL {
Slave_SQL_Running=`mysql -u $USER -p$PASSWD -e "show slave status\G;" 2> /dev/null |grep Slave_SQL_Running: |awk ‘{print $2}‘`
if [ $Slave_SQL_Running == "Yes" ];then
echo 1
else
echo 0
fi
}
case $NAME in
io)
IO
;;
sql)
SQL
;;
*)
echo -e "Usage: $0 [io | sql]"
esac
标签:判断 mysq zabbix cas case show des stat ase
原文地址:https://blog.51cto.com/13293070/2506382