Combine my other Zabbix to automatically discover MySQL and monitor blogs using the best:
Link contact me
The script is simple and you can see it at a glance:
[email protected] files]# cat libexec/slave.sh #!/bin/bash# #slave. sh# #YES----# #NO----0 Export Mysql_pwd=xxxxxxxstat S () {stats=$ (/usr/local/mysql/bin/mysql-h127.0.0.1-uuser_name-p$1-e "show slave status\g" | grep "\<$2\>" |awk ' {print $} ') if ["${stats}" = "Yes"]; Then echo 1else echo 0fi}if ["$"! = "Seconds_behind_master"];thenxstats $ $2elseresult=$ (/usr/local/mysql/bin/mysql -h127.0.0.1-umonitor-p$1-e "show Slave Status\g" | grep "Seconds_behind_master" |awk ' {print $NF} ') echo $resultfi
This defines the key value:
Userparameter=mysql_slave_status[*],/usr/local/zabbix/libexec/slave.sh $
In the template, write this:
mysql_slave_status[{#MYSQLPORT},seconds_behind_master]mysql_slave_status[{#MYSQLPORT},slave_io_running]mysql_ slave_status[{#MYSQLPORT},slave_sql_running]
This article is from the "Tongluowan" blog, make sure to keep this source http://wuhf2015.blog.51cto.com/8213008/1783782
MySQL master-Slave synchronization script monitoring script