diff options
Diffstat (limited to 'web/attachments/416883-check_mysql.patch')
-rw-r--r-- | web/attachments/416883-check_mysql.patch | 70 |
1 files changed, 70 insertions, 0 deletions
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 @@ | |||
1 | --- a/nagios-plugins-1.4.15/plugins/check_mysql.c 2010-07-27 22:47:16.000000000 +0200 | ||
2 | +++ b/nagios-plugins-1.4.15/plugins/check_mysql.c 2011-06-30 11:12:09.000000000 +0200 | ||
3 | @@ -34,7 +34,7 @@ | ||
4 | const char *copyright = "1999-2007"; | ||
5 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; | ||
6 | |||
7 | -#define SLAVERESULTSIZE 70 | ||
8 | +#define SLAVERESULTSIZE 120 | ||
9 | |||
10 | #include "common.h" | ||
11 | #include "utils.h" | ||
12 | @@ -158,7 +158,7 @@ | ||
13 | |||
14 | } else { | ||
15 | /* mysql 4.x.x */ | ||
16 | - int slave_io_field = -1 , slave_sql_field = -1, seconds_behind_field = -1, i, num_fields; | ||
17 | + int slave_io_field = -1 , slave_sql_field = -1, seconds_behind_field = -1, until_cond_field = -1, last_errno_field = -1, i, num_fields; | ||
18 | MYSQL_FIELD* fields; | ||
19 | |||
20 | num_fields = mysql_num_fields(res); | ||
21 | @@ -176,16 +176,25 @@ | ||
22 | seconds_behind_field = i; | ||
23 | continue; | ||
24 | } | ||
25 | + if (strcmp(fields[i].name, "Until_Condition") == 0) { | ||
26 | + until_cond_field = i; | ||
27 | + continue; | ||
28 | + } | ||
29 | + if (strcmp(fields[i].name, "Last_Errno") == 0) { | ||
30 | + last_errno_field = i; | ||
31 | + continue; | ||
32 | + } | ||
33 | } | ||
34 | |||
35 | - if ((slave_io_field < 0) || (slave_sql_field < 0) || (num_fields == 0)) { | ||
36 | + if ((slave_io_field < 0) || (slave_sql_field < 0) || (last_errno_field < 0) || (num_fields == 0)) { | ||
37 | mysql_free_result (res); | ||
38 | mysql_close (&mysql); | ||
39 | die (STATE_CRITICAL, "Slave status unavailable\n"); | ||
40 | } | ||
41 | |||
42 | - 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"); | ||
43 | - if (strcmp (row[slave_io_field], "Yes") != 0 || strcmp (row[slave_sql_field], "Yes") != 0) { | ||
44 | + 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"); | ||
45 | + | ||
46 | + 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)) { | ||
47 | mysql_free_result (res); | ||
48 | mysql_close (&mysql); | ||
49 | die (STATE_CRITICAL, "%s\n", slaveresult); | ||
50 | @@ -197,9 +206,19 @@ | ||
51 | } else { | ||
52 | printf ("seconds_behind_field(index %d)=%s\n", seconds_behind_field, row[seconds_behind_field]); | ||
53 | } | ||
54 | + if (until_cond_field == -1) { | ||
55 | + printf("until_cond_field not found\n"); | ||
56 | + } else { | ||
57 | + printf ("until_cond_field(index %d)=%s\n", until_cond_field, row[until_cond_field]); | ||
58 | + } | ||
59 | + if (last_errno_field == -1) { | ||
60 | + printf("last_errno_field not found\n"); | ||
61 | + } else { | ||
62 | + printf("last_errno_field(index %d)=%s\n", last_errno_field, row[last_errno_field]); | ||
63 | + } | ||
64 | } | ||
65 | |||
66 | - if ((seconds_behind_field != -1) && (strcmp (row[seconds_behind_field], "NULL") != 0)) { | ||
67 | + if ((seconds_behind_field != -1) && (row[seconds_behind_field] != NULL && (strcmp (row[seconds_behind_field], "NULL") != 0)) && (strcmp(row[until_cond_field], "None") == 0)) { | ||
68 | double value = atof(row[seconds_behind_field]); | ||
69 | int status; | ||
70 | |||