Code

check_host: Allocate a large-enough buffer for the host table.
[nagiosplug.git] / plugins / check_mysql.c
index 119ce0afa85681342086dff4c806f42010ca8705..d9b4e537230a281f85d9d265ca1b032129238665 100644 (file)
@@ -5,7 +5,7 @@
 * License: GPL
 * Copyright (c) 1999 Didi Rieder (adrieder@sbox.tu-graz.ac.at)
 * Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net)
-* Copyright (c) 1999-2007 Nagios Plugins Development Team
+* Copyright (c) 1999-2009 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -177,13 +177,14 @@ main (int argc, char **argv)
                                        continue;
                                }
                        }
+
                        if ((slave_io_field < 0) || (slave_sql_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], row[seconds_behind_field]);
+                       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) {
                                mysql_free_result (res);
                                mysql_close (&mysql);
@@ -357,9 +358,6 @@ validate_arguments (void)
        if (db_host == NULL)
                db_host = strdup("");
 
-       if (db_pass == NULL)
-               db_pass = strdup("");
-
        if (db == NULL)
                db = strdup("");
 
@@ -383,10 +381,10 @@ print_help (void)
 
        print_usage ();
 
-  printf (_(UT_HELP_VRSN));
-       printf (_(UT_EXTRA_OPTS));
+  printf (UT_HELP_VRSN);
+       printf (UT_EXTRA_OPTS);
 
-  printf (_(UT_HOST_PORT), 'P', myport);
+  printf (UT_HOST_PORT, 'P', myport);
   printf (" %s\n", "-s, --socket=STRING");
   printf ("    %s\n", _("Use the specified socket (has no effect if -H is used)"));
 
@@ -412,20 +410,19 @@ print_help (void)
   printf (" %s\n", _("using the default unix socket. You can force TCP on localhost by using an"));
   printf (" %s\n", _("IP address or FQDN ('localhost' will use the socket as well)."));
 
-#ifdef NP_EXTRA_OPTS
        printf ("\n");
        printf ("%s\n", _("Notes:"));
-       printf (_(UT_EXTRA_OPTS_NOTES));
-#endif
+       printf (" %s\n", _("You must specify -p with an empty string to force an empty password,"));
+       printf (" %s\n", _("overriding any my.cnf settings."));
 
-       printf (_(UT_SUPPORT));
+       printf (UT_SUPPORT);
 }
 
 
 void
 print_usage (void)
 {
-       printf (_("Usage:"));
+       printf ("%s\n", _("Usage:"));
   printf (" %s [-d database] [-H host] [-P port] [-s socket]\n",progname);
   printf ("       [-u user] [-p password] [-S]\n");
 }