summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--REQUIREMENTS5
-rw-r--r--plugins/check_mysql.c11
2 files changed, 10 insertions, 6 deletions
diff --git a/REQUIREMENTS b/REQUIREMENTS
index 9f2eec0..1f673e9 100644
--- a/REQUIREMENTS
+++ b/REQUIREMENTS
@@ -36,10 +36,9 @@ check_ldap:
36 36
37check_mysql, check_mysql_query: 37check_mysql, check_mysql_query:
38 - Requires the MySQL libraries available from 38 - Requires the MySQL libraries available from
39 http://www.mysql.org/ 39 http://dev.mysql.com/downloads/
40 Lib: libmysql, libmysqlclient 40 Lib: libmysql, libmysqlclient
41 Redhat Powertools Source: mysql-3.20.32a-3.i386.rpm, mysql-devel-3.20.32a-3.i386.rpm (these seem to be broken, however) 41 Redhat Source (RHEL6, YUM): mysql-devel, mysql-libs
42 RPMS from www.mysql.org work better
43 Must have mysql_config in PATH or specified with --with-mysql=DIR for DIR/bin/mysql_config 42 Must have mysql_config in PATH or specified with --with-mysql=DIR for DIR/bin/mysql_config
44 43
45check_pqsql: 44check_pqsql:
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index 4fbdc2b..51579c2 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -5,7 +5,7 @@
5* License: GPL 5* License: GPL
6* Copyright (c) 1999 Didi Rieder (adrieder@sbox.tu-graz.ac.at) 6* Copyright (c) 1999 Didi Rieder (adrieder@sbox.tu-graz.ac.at)
7* Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net) 7* Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net)
8* Copyright (c) 1999-2009 Nagios Plugins Development Team 8* Copyright (c) 1999-2011 Nagios Plugins Development Team
9* 9*
10* Description: 10* Description:
11* 11*
@@ -31,7 +31,7 @@
31*****************************************************************************/ 31*****************************************************************************/
32 32
33const char *progname = "check_mysql"; 33const char *progname = "check_mysql";
34const char *copyright = "1999-2007"; 34const char *copyright = "1999-2011";
35const char *email = "nagiosplug-devel@lists.sourceforge.net"; 35const char *email = "nagiosplug-devel@lists.sourceforge.net";
36 36
37#define SLAVERESULTSIZE 70 37#define SLAVERESULTSIZE 70
@@ -157,7 +157,7 @@ main (int argc, char **argv)
157 } 157 }
158 158
159 } else { 159 } else {
160 /* mysql 4.x.x */ 160 /* mysql 4.x.x and mysql 5.x.x */
161 int slave_io_field = -1 , slave_sql_field = -1, seconds_behind_field = -1, i, num_fields; 161 int slave_io_field = -1 , slave_sql_field = -1, seconds_behind_field = -1, i, num_fields;
162 MYSQL_FIELD* fields; 162 MYSQL_FIELD* fields;
163 163
@@ -178,13 +178,17 @@ main (int argc, char **argv)
178 } 178 }
179 } 179 }
180 180
181 /* Check if slave status is available */
181 if ((slave_io_field < 0) || (slave_sql_field < 0) || (num_fields == 0)) { 182 if ((slave_io_field < 0) || (slave_sql_field < 0) || (num_fields == 0)) {
182 mysql_free_result (res); 183 mysql_free_result (res);
183 mysql_close (&mysql); 184 mysql_close (&mysql);
184 die (STATE_CRITICAL, "Slave status unavailable\n"); 185 die (STATE_CRITICAL, "Slave status unavailable\n");
185 } 186 }
186 187
188 /* Save slave status in slaveresult */
187 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"); 189 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");
190
191 /* Raise critical error if SQL THREAD or IO THREAD are stopped */
188 if (strcmp (row[slave_io_field], "Yes") != 0 || strcmp (row[slave_sql_field], "Yes") != 0) { 192 if (strcmp (row[slave_io_field], "Yes") != 0 || strcmp (row[slave_sql_field], "Yes") != 0) {
189 mysql_free_result (res); 193 mysql_free_result (res);
190 mysql_close (&mysql); 194 mysql_close (&mysql);
@@ -199,6 +203,7 @@ main (int argc, char **argv)
199 } 203 }
200 } 204 }
201 205
206 /* Check Seconds Behind against threshold */
202 if ((seconds_behind_field != -1) && (strcmp (row[seconds_behind_field], "NULL") != 0)) { 207 if ((seconds_behind_field != -1) && (strcmp (row[seconds_behind_field], "NULL") != 0)) {
203 double value = atof(row[seconds_behind_field]); 208 double value = atof(row[seconds_behind_field]);
204 int status; 209 int status;