Nagios Plugin to check the Status of a MySQL Slave
https://www.claudiokuenzler.com/monitoring-plugins/check_mysql_slavestatus.php
Monitoring plugin to check the Status of a MySQL/MariaDB replication slave
Nagios Plugin to check the Status of a MySQL Slave
https://www.claudiokuenzler.com/monitoring-plugins/check_mysql_slavestatus.php
Thank you very much for making this available. I have a small improvement request. Could support for the --login-path parameter for the mysql client be added to this script ?
For example if a new "-l" switch was added the affected lines of code might be something like these (plus relevant documentation changes):
...
while getopts "H:P:u:p:S:s:w:c:o:m:h:l" Input;
...
l) loginpath="--login-path=${OPTARG}";;
...
then for the case we receive the -l switch the invoke of the mysql client would be
ConnectionResult=$(mysql ${loginpath} ${optfile} ... -e "show slave ${connection} status\G" 2>&1)
...
Thank you again for considering this
To success conection i had to add "passoword" variable in "ConnectionResult"; in the socket section. Like this:
ConnectionResult=$(mysql ${optfile} ${socket} ${user} -p"${password}" -e "SHOW SLAVE ${connection} STATUS ${channel}\G" 2>&1)
Hello,
Apologies in advance if this is not the right place to submit a request for help. This is not an issue but rather a plea for some further guidance beyond your documentation. Please do not hesitate to redirect me.
Unable to get ./check_mysql_slavestatus.sh working even from the command line where I receive the following error:
$ ./check_mysql_slavestatus.sh -H 127.0.0.1 -u nagios -p <password> CRITICAL: Unable to connect to server
The replication rights were granted to the user nagios as confirmed below:
MariaDB [(none)]> SHOW GRANTS FOR nagios; +--------------------------------------------------------------------------------------------------------------------+ | Grants for nagios@% | +--------------------------------------------------------------------------------------------------------------------+ | GRANT REPLICATION CLIENT ON *.* TO
nagios@
% IDENTIFIED BY PASSWORD '*BA3BD6712CF1AE71D3969D83CDA598A2D9191CBD' | +--------------------------------------------------------------------------------------------------------------------+
Indeed I can confirm command line access to the db server locally and remotely.
The NRPE.cfg entry on the remote client (db server) is as follows:
command[check_mysql_slavestatus]=/usr/local/nagios/libexec/check_mysql_slavestatus -H localhost -u nagios -p <password>
with the correct string for , of course.
In other words, I can confirm connection to the db server, locally or remotely, using the same credentials that I am using for the NRPE plugin. Can you please let me know how to troubleshoot this operator/user error for your script? Thanks.
Kind regards.
When the plugin detects that the slave process is not running, the plugin output looks strange:
# /usr/lib/nagios/plugins/check_mysql_slavestatus.sh -H mysqlserver -u monitoring -p secret
CRITICAL: -h mysqlserver:-P 3306 Slave_SQL_Running: No
The parameters here should not show up.
Since MariaDB 10.5+ the REPLICA MONITOR
privilege needs to be used to be able to fetch replication status; previously this was REPLICATION CLIENT
. Additionally the suggested source-specification of "any" (%
) in script and documentation seems a bit broad.
When connection options are read from an options file (-o
) a socket specified in there is ignored by MariaDB as check_mysql_slavestatus still sets -P 3306
which causes MariaDB to use TCP.
MariaDB warning: WARNING: Forcing protocol to TCP due to option specification. Please explicitly state intended protocol.
We noticed that due to an error from check_mysql_slavestatus CRITICAL: Unable to connect to server
as we had only allowed "localhost" but at the same time disabled name resolution (reverse dns) by setting skip-name-resolve=on
. That way the tcp connect from 127.0.0.1 no longer matched the permitted host "localhost".
Workaround:
Specify socket again on the command line, a valid user and a dummy password; the password will be overwritten with the value read from the options file. This will cause check_mysql_slavestatus not to use -P
towards MariaDB.
Only specifying the socket file doesn't work as user/password are required parameters in that case.
Example:
check_mysql_slavestatus.sh -o mysql.credentials -S /run/mysqld/mysqld.sock -u monitoring -p dummy ...
Tested with: MariaDB 10.6.11
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.