summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fd94732)
raw | patch | inline | side by side (parent: fd94732)
author | M. Sean Finney <seanius@users.sourceforge.net> | |
Thu, 26 May 2005 02:13:19 +0000 (02:13 +0000) | ||
committer | M. Sean Finney <seanius@users.sourceforge.net> | |
Thu, 26 May 2005 02:13:19 +0000 (02:13 +0000) |
names instead for determining slave status. thanks to james kingston.
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1185 f882894a-f735-0410-b71e-b25c423dba1c
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1185 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_mysql.c | patch | blob | history |
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index 25b7d7e621a1b13bfaf618b3b9e5d8f0bd796946..20901e639d908afd7f211469d8e50fe69f95a56b 100644 (file)
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
die (STATE_CRITICAL, "%s\n", slaveresult);
}
- } else if (mysql_field_count (&mysql) == 33) {
- /* mysql >= 4.1.1 */
- snprintf (slaveresult, SLAVERESULTSIZE, "Slave IO: %s Slave SQL: %s", row[10], row[11]);
- if (strcmp (row[10], "Yes") != 0 || strcmp (row[11], "Yes") != 0) {
+ } else {
+ /* mysql 4.x.x */
+ int slave_io_field = -1 , slave_sql_field = -1, i, num_fields;
+ MYSQL_FIELD* fields;
+
+ num_fields = mysql_num_fields(res);
+ fields = mysql_fetch_fields(res);
+ for(i = 0; i < num_fields; i++)
+ {
+ if (0 == strcmp(fields[i].name, "Slave_IO_Running"))
+ {
+ slave_io_field = i;
+ continue;
+ }
+ if (0 == strcmp(fields[i].name, "Slave_SQL_Running"))
+ {
+ slave_sql_field = i;
+ continue;
+ }
+ }
+ if ((slave_io_field < 0) || (slave_sql_field < 0) || (num_fields == 0))
+ {
mysql_free_result (res);
mysql_close (&mysql);
- die (STATE_CRITICAL, "%s\n", slaveresult);
+ die (STATE_CRITICAL, "Slave status unavailable\n");
}
- } else {
- /* mysql 4.0.x or 4.1.0 */
- snprintf (slaveresult, SLAVERESULTSIZE, "Slave IO: %s Slave SQL: %s", row[9], row[10]);
- if (strcmp (row[9], "Yes") != 0 || strcmp (row[10], "Yes") != 0) {
+
+ snprintf (slaveresult, SLAVERESULTSIZE, "Slave IO: %s Slave SQL: %s", row[slave_io_field], row[slave_sql_field]);
+ if (strcmp (row[slave_io_field], "Yes") != 0 || strcmp (row[slave_sql_field], "Yes") != 0) {
mysql_free_result (res);
mysql_close (&mysql);
die (STATE_CRITICAL, "%s\n", slaveresult);