From ab3ada9aacd82356a6e5205f3ae26bbff55524db Mon Sep 17 00:00:00 2001 From: Thomas Guyot-Sionnest Date: Tue, 24 Mar 2009 02:01:48 -0400 Subject: check_mysql: Fix segfault with old slaves (#2696823 - Oskar Ahner) --- plugins/check_mysql.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c index 119ce0af..689648eb 100644 --- a/plugins/check_mysql.c +++ b/plugins/check_mysql.c @@ -177,13 +177,14 @@ main (int argc, char **argv) continue; } } + if ((slave_io_field < 0) || (slave_sql_field < 0) || (num_fields == 0)) { mysql_free_result (res); mysql_close (&mysql); die (STATE_CRITICAL, "Slave status unavailable\n"); } - snprintf (slaveresult, SLAVERESULTSIZE, "Slave IO: %s Slave SQL: %s Seconds Behind Master: %s", row[slave_io_field], row[slave_sql_field], row[seconds_behind_field]); + snprintf (slaveresult, SLAVERESULTSIZE, "Slave IO: %s Slave SQL: %s Seconds Behind Master: %s", row[slave_io_field], row[slave_sql_field], seconds_behind_field!=-1?row[seconds_behind_field]:"Unknown"); if (strcmp (row[slave_io_field], "Yes") != 0 || strcmp (row[slave_sql_field], "Yes") != 0) { mysql_free_result (res); mysql_close (&mysql); -- cgit v1.2.3-74-g34f1