基于搭建mysql主从,在客户端操作
1,创建监控mysql主从状态脚本,并创建授权用户
[root@localhost ~] cd /etc/zabbix/scripts/
[root@localhost scripts] vim check_mysql.sh
[root@localhost scripts] cat check_mysql.sh
#!/bin/bash
case $1 in
slave_status)
mysql -ucheck -p123 -e "show slave status \G"|grep "Running"|grep "Yes"|awk '{print $2}'|wc -l
;;
esac
#在slave库创建授权用户
MariaDB [(none)]> grant all on *.* to 'check'@'localhost' identified by '123';
MariaDB [(none)]> flush privileges;
2,编辑客户端配置文件,并重启
[root@localhost scripts] cd /etc/zabbix/zabbix_agentd.d/
[root@localhost zabbix_agentd.d] vim check_mysql.conf
[root@localhost zabbix_agentd.d