The monitoring plugin check_mysql_slavestatus has a special place in my Open Source heart: It's the first monitoring plugin (back then: Nagios-Plugin) I publicly released back in 2008. Today it's still alive and helps to monitor MySQL and MariaDB replications.
But since 2008 a lot has happened.
In the past, the check_mysql_slavestatus plugin simply used the SHOW SLAVE STATUS command to obtain information about the current replication status. But with all the wording changes, which are even different depending on the database vendor, this broke the plugin.
More or less a year ago, a first PR was sent in the GitHub repository. However the PR only changed the wording, which would have worked for newer MySQL releases. But neither would it have worked on older MySQL releases nor for MariaDB servers. But the PR was very helpful to me to get into this topic more and understand the underlying changes.
My two main goals of the monitoring plugins I share is: "Keep it simple" and "backward compatible". Although not always possible, I try to adjust the plugins in a way, that existing monitoring setups don't break, when a new version of the plugin is installed.
In this situation, the plugin first needs to know...
... it is checking.
To achieve this, the plugin now uses the SELECT VERSION() command. Luckily this command is still universal and supported by both database types.
As you could have guessed, the output looks different:
ck@mysql:~$ mysql -h localhost -u monitoring -Bse "SELECT VERSION();"
8.4.7-7
ck@mariadb:~$ mysql -h localhost -u monitoring -Bse "SELECT VERSION();"
11.8.3-MariaDB-0+deb13u1 from Debian
From the output you can see the MySQL version just shows a version. The MariaDB version output shows the string "MariaDB" in it. This helps to differ between the two database types, without having to run yet another command.
But due to the completely different release numbers, the plugin can't simply say "everything starting from version 8.x now uses the new wording", as MariaDB 10.1 for example still uses the old wording.
Based on the releases that changed the Slave to Replica wording, the plugin now internally checks:
Based on the detected database type, the field wording (from the SHOW REPLICA STATUS output) also needed adjustments. In MySQL 8.0.22 and newer, the output changed:
mysql> SHOW REPLICA STATUS\G;
*************************** 1. row ***************************
Replica_IO_State: Waiting for source to send event
Source_Host: xxx.xxx.xxx.xxx
Source_User: repl
Source_Port: 3306
Connect_Retry: 60
Source_Log_File: binlog.001215
[...]
Slave_* fields have become Replica_* fields. Master_* fields have become Source_* fields.
But MariaDB kept the old wording and only changed the command.
Now with the changes in place and merged, replications on both MySQL and MariaDB can be monitored again. The plugin supports newer and older releases of both database types.
On MySQL 8.4:
$ ./check_mysql_slavestatus.sh -H localhost -u user -p secret
OK: Replica SQL running: Yes Replica IO running: Yes / Source: xxx.xxx.xxx.xxx / Replica is 0 seconds behind Source | delay=0s
On MariaDB 10.5:
$ ./check_mysql_slavestatus.sh -H localhost -u user -p secret
OK: Slave SQL running: Yes Slave IO running: Yes / Master: xxx.xxx.xxx.xxx / Slave is 0 seconds behind Master | delay=0s
Enjoy :-)
No comments yet.
AWS Android Ansible Apache Apple Atlassian BSD Backup Bash Bluecoat CMS Chef Cloud Coding Consul Containers CouchDB DB DNS Databases Docker ELK Elasticsearch Filebeat FreeBSD Galera Git GlusterFS Grafana Graphics HAProxy HTML Hacks Hardware Icinga Influx Internet Java KVM Kibana Kodi Kubernetes LVM LXC Linux Logstash Mac Macintosh Mail MariaDB Minio MongoDB Monitoring Multimedia MySQL NFS Nagios Network Nginx OSSEC OTRS Observability Office OpenSearch PHP Perl Personal PostgreSQL PowerDNS Proxmox Proxy Python Rancher Rant Redis Roundcube SSL Samba Seafile Security Shell SmartOS Solaris Surveillance Systemd TLS Tomcat Ubuntu Unix VMware Varnish Virtualization Windows Wireless Wordpress Wyse ZFS Zoneminder