Client Operation:
Yum install-y nagios-plugins nagios-plugins-all Nrpe Nagios-plugins-nrpe#安装
Vim/etc/nagios/nrpe.cfg #更改客户端的nrpe配置文件
allowed_hosts=192.168.20.168 #IP更改成监控端的地址, if it is multiple use, split open
#漏了这个后期会出现CHECK_NRPE: Error-could not complete SSL handshake. Of
Vim/usr/lib64/nagios/plugins/check_slave #编辑监控脚本
#!/bin/sh
Slave_r= ($ (/usr/local/mysql/bin/mysql-e "show slave status\g" |grep Running |awk ' {print $} '))
If ["${slave_r[0]}" = "yes"-a "${slave_r[1]}" = "yes"]
Then
echo "OK Rn2-slave is running"
Exit 0
Else
echo "Critical Rn2-slave is Error"
Exit 2
Fi
chmod +x/usr/lib64/nagios/plugins/check_slave #加上可执行权限, otherwise nrpe:unable to read output
Vim/etc/nagios/nrpe.cfg #编辑nrpe. CFG, plus the following:
Command[check_slave]=/usr/lib64/nagios/plugins/check_slave
To execute a monitoring script:
Sh/usr/lib64/nagios/plugins/check_slave #输出OK
/etc/init.d/nrpe Start #启动nrpe
Service side:
Vim/etc/nagios/conf.d/192.168.20.130.cfg
Define Host{
Use Linux-server
HOST_NAME 192.168.20.130
Alias 20.130
Address 192.168.20.130
}
Define Service{
Use Generic-service
HOST_NAME 192.168.20.130
Service_description Check_slave
Check_command Check_nrpe!check_slave
Max_check_attempts 2
Normal_check_interval 2
Contact_groups Common
Notifications_enabled 1
Notification_period 24x7
Notification_options W,u,c,r
}
Nagios-v/etc/nagios/nagios.cfg #检查脚本, no mistake, go on next
/etc/init.d/nagios restart
Login Monitoring view:
650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M01/7E/62/wKioL1b-AiKSBeb5AAC_EmacAfc913.jpg "title=" 3.jpg " alt= "Wkiol1b-aiksbeb5aac_emacafc913.jpg"/>
To stop the client's MySQL, check out:
650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M00/7E/62/wKioL1b-AjiT2FJVAADFpaQK9Mg872.jpg "title=" 4.jpg " alt= "Wkiol1b-ajit2fjvaadfpaqk9mg872.jpg"/>
Receive Alert Email:
650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M02/7E/66/wKiom1b-AlizgzEbAADQYgkkaBM086.jpg "title=" 5.jpg " alt= "Wkiom1b-alizgzebaadqygkkabm086.jpg"/>
Restore the MySQL slave end to normal and receive a return to normal mail:
650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M00/7E/62/wKioL1b-A2LhzcPpAAD7phNqZFc871.jpg "title=" 6.jpg " alt= "Wkiol1b-a2lhzcppaad7phnqzfc871.jpg"/>
This article is from the "Kw_lee" blog, make sure to keep this source http://11398377.blog.51cto.com/11388377/1759161
Nagios monitors MySQL master and slave, and email alerts!