zabbix 监控mysql主从

时间:2023-03-08 16:57:49

这里记录了,每次都百度查询多次。

zabbix默认包含mysql监控 其中包含 mysql的基本状态监控

MySQL主从监控需要结合自定义

1)目前项目需求 只对 Slave_IO_Running 、Slave_SQL_Running、Seconds_Behind_Master 状态进行监控

2)自定义脚本

UserParameter=mysql.replication,mysql -uroot -pgogogo -e 'show slave status\G' |grep -E "Slave_IO_Running|Slave_SQL_Running"|awk '{print $2}'|grep -c Yes
UserParameter=mysql.seconds_behind_master,mysql -uroot -pgogogo  -e 'show slave status\G' |grep -E "Seconds_Behind_Master"|awk '{print $2}'

3) 结合zabbix进行设置(当  mysql.replication 值不为 0 的时候,报警,当 seconds_behind_master 值 大于 0 的时候报警。)

附件:监控 MYSQL主从状态模板下载