summaryrefslogtreecommitdiffstats
path: root/plugins/t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/t')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index 25b7d7e..20901e6 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -123,18 +123,35 @@ main (int argc, char **argv)
123 die (STATE_CRITICAL, "%s\n", slaveresult); 123 die (STATE_CRITICAL, "%s\n", slaveresult);
124 } 124 }
125 125
126 } else if (mysql_field_count (&mysql) == 33) { 126 } else {
127 /* mysql >= 4.1.1 */ 127 /* mysql 4.x.x */
128 snprintf (slaveresult, SLAVERESULTSIZE, "Slave IO: %s Slave SQL: %s", row[10], row[11]); 128 int slave_io_field = -1 , slave_sql_field = -1, i, num_fields;
129 if (strcmp (row[10], "Yes") != 0 || strcmp (row[11], "Yes") != 0) { 129 MYSQL_FIELD* fields;
130
131 num_fields = mysql_num_fields(res);
132 fields = mysql_fetch_fields(res);
133 for(i = 0; i < num_fields; i++)
134 {
135 if (0 == strcmp(fields[i].name, "Slave_IO_Running"))
136 {
137 slave_io_field = i;
138 continue;
139 }
140 if (0 == strcmp(fields[i].name, "Slave_SQL_Running"))
141 {
142 slave_sql_field = i;
143 continue;
144 }
145 }
146 if ((slave_io_field < 0) || (slave_sql_field < 0) || (num_fields == 0))
147 {
130 mysql_free_result (res); 148 mysql_free_result (res);
131 mysql_close (&mysql); 149 mysql_close (&mysql);
132 die (STATE_CRITICAL, "%s\n", slaveresult); 150 die (STATE_CRITICAL, "Slave status unavailable\n");
133 } 151 }
134 } else { 152
135 /* mysql 4.0.x or 4.1.0 */ 153 snprintf (slaveresult, SLAVERESULTSIZE, "Slave IO: %s Slave SQL: %s", row[slave_io_field], row[slave_sql_field]);
136 snprintf (slaveresult, SLAVERESULTSIZE, "Slave IO: %s Slave SQL: %s", row[9], row[10]); 154 if (strcmp (row[slave_io_field], "Yes") != 0 || strcmp (row[slave_sql_field], "Yes") != 0) {
137 if (strcmp (row[9], "Yes") != 0 || strcmp (row[10], "Yes") != 0) {
138 mysql_free_result (res); 155 mysql_free_result (res);
139 mysql_close (&mysql); 156 mysql_close (&mysql);
140 die (STATE_CRITICAL, "%s\n", slaveresult); 157 die (STATE_CRITICAL, "%s\n", slaveresult);