From 0b6423f9c99d9edf8c96fefd0f6c453859395aa1 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Mon, 30 Sep 2013 00:03:24 +0200 Subject: Import Nagios Plugins site Import the Nagios Plugins web site, Cronjobs, infrastructure scripts, and configuration files. --- web/attachments/416883-check_mysql.patch | 70 ++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 web/attachments/416883-check_mysql.patch (limited to 'web/attachments/416883-check_mysql.patch') diff --git a/web/attachments/416883-check_mysql.patch b/web/attachments/416883-check_mysql.patch new file mode 100644 index 0000000..9643a98 --- /dev/null +++ b/web/attachments/416883-check_mysql.patch @@ -0,0 +1,70 @@ +--- a/nagios-plugins-1.4.15/plugins/check_mysql.c 2010-07-27 22:47:16.000000000 +0200 ++++ b/nagios-plugins-1.4.15/plugins/check_mysql.c 2011-06-30 11:12:09.000000000 +0200 +@@ -34,7 +34,7 @@ + const char *copyright = "1999-2007"; + const char *email = "nagiosplug-devel@lists.sourceforge.net"; + +-#define SLAVERESULTSIZE 70 ++#define SLAVERESULTSIZE 120 + + #include "common.h" + #include "utils.h" +@@ -158,7 +158,7 @@ + + } else { + /* mysql 4.x.x */ +- int slave_io_field = -1 , slave_sql_field = -1, seconds_behind_field = -1, i, num_fields; ++ int slave_io_field = -1 , slave_sql_field = -1, seconds_behind_field = -1, until_cond_field = -1, last_errno_field = -1, i, num_fields; + MYSQL_FIELD* fields; + + num_fields = mysql_num_fields(res); +@@ -176,16 +176,25 @@ + seconds_behind_field = i; + continue; + } ++ if (strcmp(fields[i].name, "Until_Condition") == 0) { ++ until_cond_field = i; ++ continue; ++ } ++ if (strcmp(fields[i].name, "Last_Errno") == 0) { ++ last_errno_field = i; ++ continue; ++ } + } + +- if ((slave_io_field < 0) || (slave_sql_field < 0) || (num_fields == 0)) { ++ if ((slave_io_field < 0) || (slave_sql_field < 0) || (last_errno_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], seconds_behind_field!=-1?row[seconds_behind_field]:"Unknown"); +- if (strcmp (row[slave_io_field], "Yes") != 0 || strcmp (row[slave_sql_field], "Yes") != 0) { ++ snprintf (slaveresult, SLAVERESULTSIZE, "Slave IO: %s Slave SQL: %s Seconds Behind Master: %s Until Condition: %s Last Errno: %s", row[slave_io_field], row[slave_sql_field], seconds_behind_field!=-1?row[seconds_behind_field]:"Unknown", row[until_cond_field], last_errno_field!=-1?row[last_errno_field]:"No Error"); ++ ++ if ((strcmp(row[until_cond_field], "None") == 0 && (strcmp (row[slave_io_field], "Yes") != 0 || strcmp (row[slave_sql_field], "Yes") != 0) ) || (strcmp(row[last_errno_field], "0") != 0)) { + mysql_free_result (res); + mysql_close (&mysql); + die (STATE_CRITICAL, "%s\n", slaveresult); +@@ -197,9 +206,19 @@ + } else { + printf ("seconds_behind_field(index %d)=%s\n", seconds_behind_field, row[seconds_behind_field]); + } ++ if (until_cond_field == -1) { ++ printf("until_cond_field not found\n"); ++ } else { ++ printf ("until_cond_field(index %d)=%s\n", until_cond_field, row[until_cond_field]); ++ } ++ if (last_errno_field == -1) { ++ printf("last_errno_field not found\n"); ++ } else { ++ printf("last_errno_field(index %d)=%s\n", last_errno_field, row[last_errno_field]); ++ } + } + +- if ((seconds_behind_field != -1) && (strcmp (row[seconds_behind_field], "NULL") != 0)) { ++ if ((seconds_behind_field != -1) && (row[seconds_behind_field] != NULL && (strcmp (row[seconds_behind_field], "NULL") != 0)) && (strcmp(row[until_cond_field], "None") == 0)) { + double value = atof(row[seconds_behind_field]); + int status; + -- cgit v1.2.3-74-g34f1