nagios对mysql主从复制的监控
登陆从服务器mysql,添加验证的用户
1grant replication client on . to 'nagios'@localhost identified by 'jiankong';
2flush privileges;
查看是否添加成功
1select user,host from mysql.user
在从服务器安装 nrpe,然后在配置文件nrpe.cfg加入一行
1command[check_mysql_slave]=/usr/local/nagios/libexec/check_mysql_slave
添加这个文件内容
 1#!/bin/sh
 2
 3declare -a slave_is
 4slave_is=((/usr/local/mysql/bin/mysql -unagios -pjiankong -e "show slave statusG"|grep Running |awk '{print 2}'))
 5if [ "{slave_is[0]}" = "Yes" -a "{slave_is[1]}" = "Yes" ];then
 6    echo "OK -slave is running"
 7    exit 0
 8else
 9    echo "Critical -slave is error"
10    exit 2
11fi
再执行这个脚本,观察输出情况
1/usr/local/nagios/libexec/check_nrpe -H 192.168.0.200
2/usr/local/nagios/libexec/check_nrpe -H 192.168.0.200 -c check_mysql_slave
在主监控服务里面添加了重启
 1define service {
 2    host_name XXXX            //XXXX为主机名,自己可以做相应的更改
 3    service_description check_mysql_slave
 4    check_period 24x7
 5    max_check_attempts 5
 6    normal_check_interval 3
 7    retry_check_interval 2
 8    contact_groups mygroup
 9    notification_interval 5
10    notification_period 24x7
11    notification_options w,u,c,r
12    check_command check_nrpe!check_mysql_slave
13}
捐赠本站(Donate)
如您感觉文章有用,可扫码捐赠本站!(If the article useful, you can scan the QR code to donate))
- Author: shisekong
 - Link: https://blog.361way.com/mysql-nagios-replication/978.html
 - License: This work is under a 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议. Kindly fulfill the requirements of the aforementioned License when adapting or creating a derivative of this work.