» IT tipps and howto's
Nagios Plugin: Check MySQL Replication Slave Status
Last Update 16.10.2008
I programmed this script, to check the status of the MySQL replication. It
is written in bash, so it is portable on all kind of Linux and even Unix systems. Please have a look at the history within the script to be informed about the changes made in the past.
Possible parameters you can use are:
-H Hostname or IP address of server to check
-P Port of MySQL server (standard is 3306)
-u Username of user who has rights on the MySQL server
-p Password of the user declared with -u parameter
--help Help text for correct use of this script
There has been a lot of changes in the past two months. Thanks to Victor Balada Diaz for his ideas which were added on 30.09.2008 and to Soren Klintrup who made a cleanup and inserted a lot of senseful stuff (i.e. usage of $PATH) to the script on 15.10.2008. Thank you guys!
Before you use the script, check the following variable. The 'grep', 'cut' and 'mysql' binaries have to be in one of those PATH locations. If they are located in another directory, feel free to add its directory to the PATH variable.
PATH=/usr/local/bin:/usr/bin:/bin # Set path
If you want to define the nagios check command, that's how I defined it:
# 'check_mysql_slavestatus' command definition
define command{
command_name check_mysql_slavestatus
command_line $USER1$/check_mysql_slavestatus.sh -H $HOSTADDRESS$ -P $ARG1$ -u $ARG2$ -p
$ARG3$
}
And define the check-service for the host:
# Service definition
define service{
use dienste-important-service ; Name of service template to use
host_name mysqldbserver
service_description MySQL Replication Status
check_command check_mysql_slavestatus!portnumber!username!passwd
}
And this is how it's gonna look in Nagios:

Now there's only one thing left: The plugin itself. Have fun!
Download
Nagios Plugin check_mysql_slavestatus - Version 2008101500
|