diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 750c47ea688db20d299e2df02405c4b8193de136..c1c4ea831b7db57093296956fe12ebb9fbde1e94 100644 (file)
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
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"
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)
{
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",
/* 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;
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);
-
-
-\f
/* process command-line arguments */
int
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);
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;
}
-
-
/******************************************************************************
@@-
-@@
******************************************************************************/
+
+
int
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);
exit (STATE_UNKNOWN);
}
-
-
-
return OK;
}
-
-
-\f
char *
clarify_message (char *msg)
{
-
int
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;
-
int
lu_getll (unsigned long *ll, char *str)
{
-
int
lu_getul (unsigned long *ul, char *str)
{
-
/* trim leading whitespace
if there is a leading quote, make sure it balances */
-
/* 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 */
-
-
-\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);
}