From fa6a274ad8a4ade54fe6d0b24be8788bd82b6212 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Thu, 27 Nov 2025 12:55:26 +0100 Subject: Look for either replica or slave in replica status --- plugins/check_mysql.c | 48 +++++++++++++++++------------------------------- 1 file changed, 17 insertions(+), 31 deletions(-) (limited to 'plugins/check_mysql.c') 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; } } -- cgit v1.2.3-74-g34f1