[monitoring-plugins] Look for either replica or slave in replica status

Lorenz Kästle git at monitoring-plugins.org
Fri Nov 28 00:40:12 CET 2025


 Module: monitoring-plugins
 Branch: master
 Commit: fa6a274ad8a4ade54fe6d0b24be8788bd82b6212
 Author: Lorenz Kästle <12514511+RincewindsHat at users.noreply.github.com>
   Date: Thu Nov 27 12:55:26 2025 +0100
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=fa6a274a

Look for either replica or slave in replica status

---

 plugins/check_mysql.c | 48 +++++++++++++++++-------------------------------
 1 file changed, 17 insertions(+), 31 deletions(-)

diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index 009c9908..26730d4c 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -345,37 +345,23 @@ int main(int argc, char **argv) {
 			int replica_io_field = -1;
 			int replica_sql_field = -1;
 			int seconds_behind_field = -1;
-			int num_fields;
-			MYSQL_FIELD *fields;
-			num_fields = mysql_num_fields(res);
-			fields = mysql_fetch_fields(res);
-			for (int i = 0; i < num_fields; i++) {
-				if (use_deprecated_slave_status) {
-					if (strcmp(fields[i].name, "Slave_IO_Running") == 0) {
-						replica_io_field = i;
-						continue;
-					}
-					if (strcmp(fields[i].name, "Slave_SQL_Running") == 0) {
-						replica_sql_field = i;
-						continue;
-					}
-					if (strcmp(fields[i].name, "Seconds_Behind_Master") == 0) {
-						seconds_behind_field = i;
-						continue;
-					}
-				} else {
-					if (strcmp(fields[i].name, "Replica_IO_Running") == 0) {
-						replica_io_field = i;
-						continue;
-					}
-					if (strcmp(fields[i].name, "Replica_SQL_Running") == 0) {
-						replica_sql_field = i;
-						continue;
-					}
-					if (strcmp(fields[i].name, "Seconds_Behind_Source") == 0) {
-						seconds_behind_field = i;
-						continue;
-					}
+			unsigned int num_fields = mysql_num_fields(res);
+			MYSQL_FIELD *fields = mysql_fetch_fields(res);
+			for (int i = 0; i < (int)num_fields; i++) {
+				if ((strcasecmp(fields[i].name, "Slave_IO_Running") == 0) ||
+					(strcasecmp(fields[i].name, "Replica_IO_Running") == 0)) {
+					replica_io_field = i;
+					continue;
+				}
+				if ((strcasecmp(fields[i].name, "Slave_SQL_Running") == 0) ||
+					(strcasecmp(fields[i].name, "Replica_SQL_Running") == 0)) {
+					replica_sql_field = i;
+					continue;
+				}
+				if ((strcasecmp(fields[i].name, "Seconds_Behind_Master") == 0) ||
+					(strcasecmp(fields[i].name, "Seconds_Behind_Source") == 0)) {
+					seconds_behind_field = i;
+					continue;
 				}
 			}
 



More information about the Commits mailing list