summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-11-28 00:30:38 +0100
committerGitHub <noreply@github.com>2025-11-28 00:30:38 +0100
commit7827b55bbf3e0909b263f4e756c8dfcd12243b78 (patch)
tree2559f79b00cb4a2ecce1a22e28e6b2bf1b88ecdc /plugins
parent6c231f0dd8e6e07f58de155b0a879532583f4bf0 (diff)
parentfa6a274ad8a4ade54fe6d0b24be8788bd82b6212 (diff)
downloadmonitoring-plugins-7827b55bbf3e0909b263f4e756c8dfcd12243b78.tar.gz
Merge pull request #2184 from RincewindsHat/fix/check_mysql_replica_again
Look for either replica or slave in replica status
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_mysql.c48
1 files 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) {
345 int replica_io_field = -1; 345 int replica_io_field = -1;
346 int replica_sql_field = -1; 346 int replica_sql_field = -1;
347 int seconds_behind_field = -1; 347 int seconds_behind_field = -1;
348 int num_fields; 348 unsigned int num_fields = mysql_num_fields(res);
349 MYSQL_FIELD *fields; 349 MYSQL_FIELD *fields = mysql_fetch_fields(res);
350 num_fields = mysql_num_fields(res); 350 for (int i = 0; i < (int)num_fields; i++) {
351 fields = mysql_fetch_fields(res); 351 if ((strcasecmp(fields[i].name, "Slave_IO_Running") == 0) ||
352 for (int i = 0; i < num_fields; i++) { 352 (strcasecmp(fields[i].name, "Replica_IO_Running") == 0)) {
353 if (use_deprecated_slave_status) { 353 replica_io_field = i;
354 if (strcmp(fields[i].name, "Slave_IO_Running") == 0) { 354 continue;
355 replica_io_field = i; 355 }
356 continue; 356 if ((strcasecmp(fields[i].name, "Slave_SQL_Running") == 0) ||
357 } 357 (strcasecmp(fields[i].name, "Replica_SQL_Running") == 0)) {
358 if (strcmp(fields[i].name, "Slave_SQL_Running") == 0) { 358 replica_sql_field = i;
359 replica_sql_field = i; 359 continue;
360 continue; 360 }
361 } 361 if ((strcasecmp(fields[i].name, "Seconds_Behind_Master") == 0) ||
362 if (strcmp(fields[i].name, "Seconds_Behind_Master") == 0) { 362 (strcasecmp(fields[i].name, "Seconds_Behind_Source") == 0)) {
363 seconds_behind_field = i; 363 seconds_behind_field = i;
364 continue; 364 continue;
365 }
366 } else {
367 if (strcmp(fields[i].name, "Replica_IO_Running") == 0) {
368 replica_io_field = i;
369 continue;
370 }
371 if (strcmp(fields[i].name, "Replica_SQL_Running") == 0) {
372 replica_sql_field = i;
373 continue;
374 }
375 if (strcmp(fields[i].name, "Seconds_Behind_Source") == 0) {
376 seconds_behind_field = i;
377 continue;
378 }
379 } 365 }
380 } 366 }
381 367