mysql主从监控
#脚本如下,截取主从关键字
1
2
3
4
5
6
7
8
9
10
11
12
|
cat check_mysql_slave.sh
#!/bin/bash # declare -a 定义数组,slave_is 会被视为数组 declare -a slave_is
slave_is=($( /data/mysql/bin/mysql -e "show slave status\G" | grep -E "Slave_IO_Running|Slave_SQL_Running:" | awk '{print $2}' ))
if [ "${slave_is[0]}" = "Yes" -a "${slave_is[1]}" = "Yes" ]; then
echo "ok -slave is running"
exit 0
else echo "down -slave is not running"
exit 2
fi |
#zabbix_agentd.conf文件的配置如下:
1
|