原理:利用在slave上运行show slave status获取Slave_IO_Running和Slave_SQL_Running的值mysql
1.在zabbix客户端配置文件中加入:nginx
首先要对mysql提供一个查询主从状态的帐号!(固然用root也能够。)web
grant replication client on *.* to 'xxx'@'localhost' identified by 'xxx';sql
flush privileges;ide
UserParameter=mysql.replicate_error,if test `mysql -uxxx -pxxx -h127.0.0.1 -e 'show slave status\G' | awk -F: '{if($1~/Slave_IO_Running/) print$2}' ` = "Yes" -a `mysql -uxxx -pxxx -h127.0.0.1 -e 'show slave status\G' | awk -F: '{if($1~/Slave_SQL_Running/) print$2}' ` = "Yes";then echo 0; else echo 1;fimemcached
2.在web界面建立模板:3d
建立项目blog
添加触发器;io
添加动做略。模板
4.分享下其余服务的key:
UserParameter=nginx.status,netstat -tunlp | grep 80 | grep nginx | wc | awk '{print $1}'
UserParameter=memcached.stats,netstat -tunlp | grep 11211 | grep memcache | wc | awk '{print $1}'