Code

Add newline after "Usage:" in --help
[nagiosplug.git] / plugins / check_load.c
index 9de8ff78546ae6718e102ab9735c7f06a1735d4d..1bdb06aa2c0c98f39b3bfa846bd01ea3a5a42962 100644 (file)
@@ -1,42 +1,35 @@
-/******************************************************************************
-*
+/*****************************************************************************
+* 
 * Nagios check_load plugin
-*
+* 
 * License: GPL
-* Copyright (c) 1999-2006 nagios-plugins team
-*
-* Last Modified: $Date$
-*
+* Copyright (c) 1999-2007 Nagios Plugins Development Team
+* 
 * Description:
-*
+* 
 * This file contains the check_load plugin
-*
-*  This plugin tests the current system load average.
-*
-*
-* License Information:
-*
-* This program is free software; you can redistribute it and/or modify
+* 
+* This plugin tests the current system load average.
+* 
+* 
+* This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
+* the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
-*
+* 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
-*
+* 
 * You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id$
-
-******************************************************************************/
+* along with this program.  If not, see <http://www.gnu.org/licenses/>.
+* 
+* 
+*****************************************************************************/
 
 const char *progname = "check_load";
-const char *revision = "$Revision$";
-const char *copyright = "1999-2006";
+const char *copyright = "1999-2007";
 const char *email = "nagiosplug-devel@lists.sourceforge.net";
 
 #include "common.h"
@@ -77,6 +70,7 @@ static void
 get_threshold(char *arg, double *th)
 {
        size_t i, n;
+       int valid = 0;
        char *str = arg, *p;
 
        n = strlen(arg);
@@ -84,12 +78,13 @@ get_threshold(char *arg, double *th)
                th[i] = strtod(str, &p);
                if(p == str) break;
 
+               valid = 1;
                str = p + 1;
                if(n <= (size_t)(str - arg)) break;
        }
 
        /* empty argument or non-floatish, so warn about it and die */
-       if(!i) usage (_("Warning threshold must be float or float triplet!\n"));
+       if(!i && !valid) usage (_("Warning threshold must be float or float triplet!\n"));
 
        if(i != 2) {
                /* one or more numbers were given, so fill array with last
@@ -120,6 +115,9 @@ main (int argc, char **argv)
        textdomain (PACKAGE);
        setlocale(LC_NUMERIC, "POSIX");
 
+       /* Parse extra opts if any */
+       argv = np_extra_opts (&argc, argv, progname);
+
        if (process_arguments (argc, argv) == ERROR)
                usage4 (_("Could not parse arguments"));
 
@@ -243,7 +241,7 @@ process_arguments (int argc, char **argv)
                        take_into_account_cpus = 1;
                        break;
                case 'V':                                                                       /* version */
-                       print_revision (progname, revision);
+                       print_revision (progname, NP_VERSION);
                        exit (STATE_OK);
                case 'h':                                                                       /* help */
                        print_help ();
@@ -296,7 +294,7 @@ validate_arguments (void)
 void
 print_help (void)
 {
-       print_revision (progname, revision);
+       print_revision (progname, NP_VERSION);
 
        printf ("Copyright (c) 1999 Felipe Gustavo de Almeida <galmeida@linux.ime.usp.br>\n");
        printf (COPYRIGHT, copyright, email);
@@ -304,10 +302,11 @@ print_help (void)
        printf (_("This plugin tests the current system load average."));
 
   printf ("\n\n");
-  
+
        print_usage ();
 
-       printf (_(UT_HELP_VRSN));
+       printf (UT_HELP_VRSN);
+       printf (UT_EXTRA_OPTS);
 
        printf (" %s\n", "-w, --warning=WLOAD1,WLOAD5,WLOAD15");
   printf ("    %s\n", _("Exit with WARNING status if load average exceeds WLOADn"));
@@ -317,12 +316,12 @@ print_help (void)
   printf (" %s\n", "-r, --percpu");
   printf ("    %s\n", _("Divide the load averages by the number of CPUs (when possible)"));
 
-       printf (_(UT_SUPPORT));
+       printf (UT_SUPPORT);
 }
 
 void
 print_usage (void)
 {
-  printf (_("Usage:"));
+  printf ("%s\n", _("Usage:"));
        printf ("%s [-r] -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15\n", progname);
 }