check_mysql_slave - connects to a mysql replication slave and checks its status
check_mysql_slave -H slave.server.net -U nagios -P passwd check_mysql_slave -H slave.server.net -U nagios -P passwd -p 3306 check_mysql_slave --help
Currently not used. There are other nagios plugins that will check if a server is responding to connections. May be used in the future to specify how many bytes or seconds behind the master a slave may be. Also known as: -w <seconds>
Currently not used. There are other nagios plugins that will check if a server is responding to connections. May be used in the future to specify how many bytes or seconds behind the master a slave may be. Also known as: -c <seconds>
Abort with critical status if it takes longer than <seconds> to connect to the mysql server. Default is 60 seconds. Also known as: -t <seconds>
Address or name of the MySQL slave server. Examples: mysql5.server.net, localhost, 192.168.1.100 Also known as: -H <server>
Service port on the MySQL server. Default is 3306. Also known as: -p <number>
Username and password to use when connecting to the MySQL server. Also known as: -U <username> -P <password>
Display additional information. Useful for troubleshooting. Use together with --version to see the default warning and critical timeout values. Also known as: -v
Display plugin version and exit. Also known as: -V
Display this documentation and exit. Does not work in the ePN version. Also known as: -h
Display a short usage instruction and exit.
Check a slave listening on the standard MySQL port from the command line:
$ check_mysql_slave -H slave.server.net -U nagios -P 'password'
MYSQL SLAVE OK - file bin.000003, position 41267/41267
I prefer to define this service on each slave:
define command { command_name check_mysql_slave command_line $USER1$/check_mysql_slave -H $HOSTADDRESS$ -p 3306 -U $ARG1$ -P $ARG2$ }
define service { use your-service-template host_name slave.server.net service_description MySQL Replication Slave check_command check_mysql_slave!nagios!password }
But of course you could make the port number an argument and even define all your slave replication services on the master mysql host and use the slave server's hostname as an argument instead of HOSTADDRESS, like this:
command_line $USER1$/check_mysql_slave -H $ARG1$ -p $ARG2$ -U $ARG3$ -P $ARG4$
check_command check_mysql_slave!slave.server.net!3306!nagios!password
The usage is the same, but use the embedded-perl version of the plugin:
command_line $USER1$/check_mysql_slave_epn -H $ARG1$ -p $ARG2$ -U $ARG3$ -P $ARG4$
This plugin complies with the Nagios plug-in specification:
0 OK The plugin was able to check the service and it appeared to be functioning properly 1 Warning The plugin was able to check the service, but it appeared to be above some "warning" threshold or did not appear to be working properly 2 Critical The plugin detected that either the service was not running or it was above some "critical" threshold 3 Unknown Invalid command line arguments were supplied to the plugin or the plugin was unable to check the status of the given hosts/service
Nagios plugin reference: http://nagiosplug.sourceforge.net/developer-guidelines.html
This plugin does NOT use Nagios DEFAULT_SOCKET_TIMEOUT (provided by utils.pm as $TIMEOUT) because the path to utils.pm must be specified completely in this program and forces users to edit the source code if their install location is different (if they realize this is the problem). You can view the default timeout for this module by using the --verbose and --version options together. The short form is -vV.
Other than that, it attempts to follow published guidelines for Nagios plugins.
This section concerns mysql administrators who want to grant only minimal privileges to the nagios plugin (since its username and password are stored in the nagios config!).
The plugin executes the following commands on slave servers:
SHOW VARIABLES LIKE 'version'; SHOW SLAVE STATUS;
I recommend using the following minimal grants for the nagios plugin:
GRANT PROCESS ON *.* TO 'nagios'@'nagios.server.net' identified by 'password';
GRANT SUPER,REPLICATION CLIENT ON *.* TO 'nagios'@'nagios.server.net' identified by 'password';
GRANT SUPER,REPLICATION CLIENT ON *.* TO 'nagios'@'nagios.server.net' identified by 'password';
This plugin requires the following perl modules:
Getopt::Long DBI DBD::mysql
The manual for DBD::mysql states that a database is required in the connection string. This is not true if you are only using global privileges such as usage, process, super, or replication client without trying to open a specific database.
Tue Aug 19 17:46:02 PDT 2008 + version 0.1 Wed Aug 20 07:58:16 PDT 2008 + added helpful DBI error messages (access denied, incompatible versions, etc) + version 0.1.1
Jonathan Buhacoff <jonathan@buhacoff.net>
Copyright (C) 2008 Jonathan Buhacoff
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
http://www.gnu.org/licenses/gpl.txt