In each step, create a user name and password on the MySQL slave server database, and only grant the replication Client permission.
Step 2: Create the script check-mysql-slave on the monitored MySQL slave server
#! /Bin/sh
Declare-A slave_is
Slave_is = ($ (/usr/local/MySQL/bin/MySQL-unagios-P ******-e "show slave status \ G" | grep running | awk' {print $2 }'))
If ["$ {slave_is [0]}" = "yes"-a "$ {slave_is [1]}" = "yes"]
Then
Echo "OK slave is running"
Exit 0
Else
Echo "Critical slave be stoped"
Exit 2
Fi
Step 3: nrpe on the MySQL slave server. Add the following command to CFG.
Command [check_mysql_slave] =/usr/local/Nagios/libexec/check_mysql_slave
Other settings are the same as those for Linux monitoring.
In the Nagios configuration file VI/usr/local/Nagios/services/Nagios. confdefine Service {
Use Service
The IP address of the host_name monitored segment must have nrpe
Service_description check_mysql_slave Nagios display name
Check_command check_nrpe! Check_mysql_slave plugin
Icationication_options W, U, C, r status
Contact_groups Contact Group
} Vi/usr/local/Nagios/hosts/Nagios. confdefine host {
Use host
Host_name IP alias check_alive
Address IP contact_groups group}