Code

Fix includes for gettext
[nagiosplug.git] / plugins / check_snmp.c
index 750c47ea688db20d299e2df02405c4b8193de136..c1c4ea831b7db57093296956fe12ebb9fbde1e94 100644 (file)
  along with this program; if not, write to the Free Software
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+ $Id$
 ******************************************************************************/
 
 const char *progname = "check_snmp";
 const char *revision = "$Revision$";
-const char *copyright = "1999-2003";
+const char *copyright = "1999-2004";
 const char *email = "nagiosplug-devel@lists.sourceforge.net";
 
 #include "common.h"
@@ -111,16 +113,13 @@ unsigned long upper_crit_lim[MAX_OIDS];
 unsigned long response_value[MAX_OIDS];
 int check_warning_value = FALSE;
 int check_critical_value = FALSE;
-int eval_method[MAX_OIDS];
+unsigned long eval_method[MAX_OIDS];
 char *delimiter;
 char *output_delim;
 char *miblist;
 
 
 
-
-
-\f
 int
 main (int argc, char **argv)
 {
@@ -158,7 +157,7 @@ main (int argc, char **argv)
        miblist = strdup (DEFAULT_MIBLIST);
 
        if (process_arguments (argc, argv) == ERROR)
-               usage (_("Incorrect arguments supplied\n"));
+               usage4 (_("Could not parse arguments"));
 
        /* create the command line to execute */
        asprintf (&command_line, "%s -t 1 -r %d -m %s -v %s %s %s:%s %s",
@@ -260,7 +259,7 @@ main (int argc, char **argv)
 
                /* Process this block for string matching */
                else if (eval_method[i] & CRIT_STRING) {
-                       if (strcmp (response, string_value))
+                       if (strcmp (show, string_value))
                                iresult = STATE_CRITICAL;
                        else
                                iresult = STATE_OK;
@@ -319,7 +318,7 @@ main (int argc, char **argv)
 
        if (found == 0)
                die (STATE_UNKNOWN,
-                    _("%s problem - No data recieved from host\nCMD: %s\n"),
+                    _("%s problem - No data received from host\nCMD: %s\n"),
                     label,
                     command_line);
 
@@ -344,9 +343,6 @@ main (int argc, char **argv)
 
 
 
-
-
-\f
 /* process command-line arguments */
 int
 process_arguments (int argc, char **argv)
@@ -402,7 +398,9 @@ process_arguments (int argc, char **argv)
 
                switch (c) {
                case '?':       /* usage */
-                       usage3 ("Unknown argument", optopt);
+                       printf (_("%s: Unknown argument: %s\n\n"), progname, optarg);
+                       print_usage ();
+                       exit (STATE_UNKNOWN);
                case 'h':       /* help */
                        print_help ();
                        exit (STATE_OK); 
@@ -446,7 +444,7 @@ process_arguments (int argc, char **argv)
                        break;
                case 't':       /* timeout period */
                        if (!is_integer (optarg))
-                               usage2 (_("Timeout Interval must be an integer"), optarg);
+                               usage2 (_("Timeout interval must be a positive integer"), optarg);
                        else
                                timeout_interval = atoi (optarg);
                        break;
@@ -601,8 +599,6 @@ process_arguments (int argc, char **argv)
 }
 
 
-
-
 /******************************************************************************
 
 @@-
@@ -623,6 +619,8 @@ first character cannot be a number, however.</para>
 -@@
 ******************************************************************************/
 
+
+
 int
 validate_arguments ()
 {
@@ -658,14 +656,13 @@ validate_arguments ()
                }
                else if ( strcmp(seclevel, "authPriv") == 0 ) {
                        if ( secname == NULL || authpasswd == NULL || privpasswd == NULL ) {
-                               printf (("Missing secname (%s), authpassword (%s), or privpasswd (%s)! \n"),secname, authpasswd,privpasswd );
+                               printf (_("Missing secname (%s), authpassword (%s), or privpasswd (%s)! \n"),secname, authpasswd,privpasswd );
                                print_usage ();
                                exit (STATE_UNKNOWN);
                        }
                        asprintf(&authpriv, "-l authPriv -a %s -u %s -A %s -x DES -X %s ", authproto, secname, authpasswd, privpasswd);
                }
                
-                                                                       
        }
        else {
                printf (_("Invalid SNMP version: %s\n"), proto);
@@ -673,17 +670,11 @@ validate_arguments ()
                exit (STATE_UNKNOWN);                           
        }
                        
-       
-       
-
        return OK;
 }
 
 
 
-
-
-\f
 char *
 clarify_message (char *msg)
 {
@@ -721,7 +712,6 @@ clarify_message (char *msg)
 
 
 
-
 int
 check_num (int i)
 {
@@ -745,7 +735,7 @@ check_num (int i)
        }
 
        if (eval_method[i] & CRIT_GT && eval_method[i] & CRIT_LT &&
-                       lower_warn_lim[i] > upper_warn_lim[i]) {
+                       lower_crit_lim[i] > upper_crit_lim[i]) {
                if (response_value[i] <= lower_crit_lim[i] &&
                                response_value[i] >= upper_crit_lim[i]) {
                        result = STATE_CRITICAL;
@@ -766,7 +756,6 @@ check_num (int i)
 
 
 
-
 int
 lu_getll (unsigned long *ll, char *str)
 {
@@ -782,7 +771,6 @@ lu_getll (unsigned long *ll, char *str)
 
 
 
-
 int
 lu_getul (unsigned long *ul, char *str)
 {
@@ -798,7 +786,6 @@ lu_getul (unsigned long *ul, char *str)
 
 
 
-
 /* trim leading whitespace
         if there is a leading quote, make sure it balances */
 
@@ -815,7 +802,6 @@ thisarg (char *str)
 
 
 
-
 /* if there's a leading quote, advance to the trailing quote
         set the trailing quote to '\x0'
         if the string continues, advance beyond the comma */
@@ -851,15 +837,12 @@ nextarg (char *str)
 
 
 
-
-
-\f
 void
 print_help (void)
 {
        print_revision (progname, revision);
 
-       printf (_(COPYRIGHT), copyright, email);
+       printf (COPYRIGHT, copyright, email);
 
        printf (_("\
 Check status of remote machines and obtain sustem information via SNMP\n\n"));
@@ -960,15 +943,16 @@ Check status of remote machines and obtain sustem information via SNMP\n\n"));
        printf (_(UT_SUPPORT));
 }
 
+
+
 void
 print_usage (void)
 {
-       printf (_("\
+       printf ("\
 Usage: %s -H <ip_address> -o <OID> [-w warn_range] [-c crit_range] \n\
-  [-C community] [-s string] [-r regex] [-R regexi] [-t timeout]\n\
-  [-l label] [-u units] [-p port-number] [-d delimiter]\n\
-  [-D output-delimiter] [-m miblist] [-P snmp version]\n\
-  [-L seclevel] [-U secname] [-a authproto] [-A authpasswd]\n\
-  [-X privpasswd]\n"), progname);
-       printf (_(UT_HLP_VRS), progname, progname);
+                  [-C community] [-s string] [-r regex] [-R regexi] [-t timeout]\n\
+                  [-l label] [-u units] [-p port-number] [-d delimiter]\n\
+                  [-D output-delimiter] [-m miblist] [-P snmp version]\n\
+                  [-L seclevel] [-U secname] [-a authproto] [-A authpasswd]\n\
+                  [-X privpasswd]\n", progname);
 }