diff options
Diffstat (limited to 'plugins/check_mysql.c')
| -rw-r--r-- | plugins/check_mysql.c | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c index 3d7ec4cd..6134d6c6 100644 --- a/plugins/check_mysql.c +++ b/plugins/check_mysql.c | |||
| @@ -219,16 +219,13 @@ int main(int argc, char **argv) { | |||
| 219 | use_deprecated_slave_status = true; | 219 | use_deprecated_slave_status = true; |
| 220 | } | 220 | } |
| 221 | } | 221 | } |
| 222 | } else if (strstr(server_version, "MySQL") != NULL) { | 222 | } else { |
| 223 | // Looks like MySQL | 223 | // Looks like MySQL or at least not like MariaDB |
| 224 | if (major_version < 8) { | 224 | if (major_version < 8) { |
| 225 | use_deprecated_slave_status = true; | 225 | use_deprecated_slave_status = true; |
| 226 | } else if (major_version == 10 && minor_version < 4) { | 226 | } else if (major_version == 10 && minor_version < 4) { |
| 227 | use_deprecated_slave_status = true; | 227 | use_deprecated_slave_status = true; |
| 228 | } | 228 | } |
| 229 | } else { | ||
| 230 | printf("Not a known sever implementation: %s\n", server_version); | ||
| 231 | exit(STATE_UNKNOWN); | ||
| 232 | } | 229 | } |
| 233 | 230 | ||
| 234 | char *replica_query = NULL; | 231 | char *replica_query = NULL; |
| @@ -285,17 +282,32 @@ int main(int argc, char **argv) { | |||
| 285 | num_fields = mysql_num_fields(res); | 282 | num_fields = mysql_num_fields(res); |
| 286 | fields = mysql_fetch_fields(res); | 283 | fields = mysql_fetch_fields(res); |
| 287 | for (int i = 0; i < num_fields; i++) { | 284 | for (int i = 0; i < num_fields; i++) { |
| 288 | if (strcmp(fields[i].name, "Slave_IO_Running") == 0) { | 285 | if (use_deprecated_slave_status) { |
| 289 | replica_io_field = i; | 286 | if (strcmp(fields[i].name, "Slave_IO_Running") == 0) { |
| 290 | continue; | 287 | replica_io_field = i; |
| 291 | } | 288 | continue; |
| 292 | if (strcmp(fields[i].name, "Slave_SQL_Running") == 0) { | 289 | } |
| 293 | replica_sql_field = i; | 290 | if (strcmp(fields[i].name, "Slave_SQL_Running") == 0) { |
| 294 | continue; | 291 | replica_sql_field = i; |
| 295 | } | 292 | continue; |
| 296 | if (strcmp(fields[i].name, "Seconds_Behind_Master") == 0) { | 293 | } |
| 297 | seconds_behind_field = i; | 294 | if (strcmp(fields[i].name, "Seconds_Behind_Master") == 0) { |
| 298 | continue; | 295 | seconds_behind_field = i; |
| 296 | continue; | ||
| 297 | } | ||
| 298 | } else { | ||
| 299 | if (strcmp(fields[i].name, "Replica_IO_Running") == 0) { | ||
| 300 | replica_io_field = i; | ||
| 301 | continue; | ||
| 302 | } | ||
| 303 | if (strcmp(fields[i].name, "Replica_SQL_Running") == 0) { | ||
| 304 | replica_sql_field = i; | ||
| 305 | continue; | ||
| 306 | } | ||
| 307 | if (strcmp(fields[i].name, "Seconds_Behind_Source") == 0) { | ||
| 308 | seconds_behind_field = i; | ||
| 309 | continue; | ||
| 310 | } | ||
| 299 | } | 311 | } |
| 300 | } | 312 | } |
| 301 | 313 | ||
