diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 9fa4a60bf4069bf355c86073ea8127d7ac0ce646..544c5c0b281c05f61bd8a7c2729e8aca179633d2 100644 (file)
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
-/******************************************************************************
-*
+/*****************************************************************************
+*
* Nagios check_snmp plugin
-*
+*
* License: GPL
-* Copyright (c) 1999-2007 nagios-plugins team
-*
+* Copyright (c) 1999-2007 Nagios Plugins Development Team
+*
* Last Modified: $Date$
-*
+*
* Description:
-*
+*
* This file contains the check_snmp plugin
-*
-* Check status of remote machines and obtain system information via SNMP
-*
-*
-* License Information:
-*
-* This program is free software; you can redistribute it and/or modify
+*
+* Check status of remote machines and obtain system information via SNMP
+*
+*
+* 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.
-*
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
* $Id$
*
-******************************************************************************/
+*****************************************************************************/
const char *progname = "check_snmp";
const char *revision = "$Revision$";
timeout_interval = DEFAULT_TIMEOUT;
retries = DEFAULT_RETRIES;
+ /* Parse extra opts if any */
+ argv=np_extra_opts (&argc, argv, progname);
+
if (process_arguments (argc, argv) == ERROR)
usage4 (_("Could not parse arguments"));
strncat(perfstr, "| ", sizeof(perfstr)-strlen(perfstr)-1);
while (ptr) {
- char *foo;
+ char *foo, *ptr2;
unsigned int copylen;
foo = strstr (ptr, delimiter);
copylen = foo-ptr;
if (copylen > sizeof(perfstr)-strlen(perfstr)-1)
copylen = sizeof(perfstr)-strlen(perfstr)-1;
- strncat(perfstr, ptr, copylen);
+ ptr2 = ptr;
ptr = foo;
if (ptr == NULL)
i++;
- strncat(perfstr, "=", sizeof(perfstr)-strlen(perfstr)-1);
- strncat(perfstr, show, sizeof(perfstr)-strlen(perfstr)-1);
- if (type)
- strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1);
- strncat(perfstr, " ", sizeof(perfstr)-strlen(perfstr)-1);
+ if (is_numeric(show)) {
+ strncat(perfstr, ptr2, copylen);
+ strncat(perfstr, "=", sizeof(perfstr)-strlen(perfstr)-1);
+ strncat(perfstr, show, sizeof(perfstr)-strlen(perfstr)-1);
+
+ if (type)
+ strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1);
+ strncat(perfstr, " ", sizeof(perfstr)-strlen(perfstr)-1);
+ }
} /* end while (ptr) */
/* Test parameters */
case 'c': /* critical time threshold */
if (strspn (optarg, "0123456789:,") < strlen (optarg))
- usage2 (_("Invalid critical threshold: %s\n"), optarg);
+ usage2 (_("Invalid critical threshold"), optarg);
for (ptr = optarg; ptr && jj < MAX_OIDS; jj++) {
if (llu_getll (&lower_crit_lim[jj], ptr) == 1)
eval_method[jj] |= CRIT_LT;
break;
case 'w': /* warning time threshold */
if (strspn (optarg, "0123456789:,") < strlen (optarg))
- usage2 (_("Invalid warning threshold: %s\n"), optarg);
+ usage2 (_("Invalid warning threshold"), optarg);
for (ptr = optarg; ptr && ii < MAX_OIDS; ii++) {
if (llu_getll (&lower_warn_lim[ii], ptr) == 1)
eval_method[ii] |= WARN_LT;
print_usage ();
printf (_(UT_HELP_VRSN));
+ printf (_(UT_EXTRA_OPTS));
printf (_(UT_HOST_PORT), 'p', DEFAULT_PORT);
printf (" %s\n", "-A, --authpassword=PASSWORD");
printf (" %s\n", _("SNMPv3 authentication password"));
printf (" %s\n", "-X, --privpasswd=PASSWORD");
- printf (" %s\n", _("SNMPv3 crypt passwd (DES)"));
+ printf (" %s\n", _("SNMPv3 privacy password"));
/* OID Stuff */
printf (" %s\n", "-o, --oid=OID(s)");
printf (_(UT_VERBOSE));
- printf ("%s\n", _("This plugin uses the 'snmpget' command included with the NET-SNMP package."));
+ printf ("\n");
+ printf ("%s\n", _("This plugin uses the 'snmpget' command included with the NET-SNMP package."));
printf ("%s\n", _("if you don't have the package installed, you will need to download it from"));
printf ("%s\n", _("http://net-snmp.sourceforge.net before you can use this plugin."));
- printf ("%s\n", _("- Multiple OIDs may be indicated by a comma- or space-delimited list (lists with"));
- printf ("%s\n", _(" internal spaces must be quoted) [max 8 OIDs]"));
-
- printf ("%s\n", _("- Ranges are inclusive and are indicated with colons. When specified as"));
- printf ("%s\n", _(" 'min:max' a STATE_OK will be returned if the result is within the indicated"));
- printf ("%s\n", _(" range or is equal to the upper or lower bound. A non-OK state will be"));
- printf ("%s\n", _(" returned if the result is outside the specified range."));
-
- printf ("%s\n", _("- If specified in the order 'max:min' a non-OK state will be returned if the"));
- printf ("%s\n", _(" result is within the (inclusive) range."));
-
- printf ("%s\n", _("- Upper or lower bounds may be omitted to skip checking the respective limit."));
- printf ("%s\n", _("- Bare integers are interpreted as upper limits."));
- printf ("%s\n", _("- When checking multiple OIDs, separate ranges by commas like '-w 1:10,1:,:20'"));
- printf ("%s\n", _("- Note that only one string and one regex may be checked at present"));
- printf ("%s\n", _("- All evaluation methods other than PR, STR, and SUBSTR expect that the value"));
- printf ("%s\n", _(" returned from the SNMP query is an unsigned integer."));
+ printf ("\n");
+ printf ("%s\n", _("Notes:"));
+ printf (" %s\n", _("- Multiple OIDs may be indicated by a comma- or space-delimited list (lists with"));
+ printf (" %s\n", _("internal spaces must be quoted) [max 8 OIDs]"));
+
+ printf (" %s\n", _("- Ranges are inclusive and are indicated with colons. When specified as"));
+ printf (" %s\n", _("'min:max' a STATE_OK will be returned if the result is within the indicated"));
+ printf (" %s\n", _("range or is equal to the upper or lower bound. A non-OK state will be"));
+ printf (" %s\n", _("returned if the result is outside the specified range."));
+
+ printf (" %s\n", _("- If specified in the order 'max:min' a non-OK state will be returned if the"));
+ printf (" %s\n", _("result is within the (inclusive) range."));
+
+ printf (" %s\n", _("- Upper or lower bounds may be omitted to skip checking the respective limit."));
+ printf (" %s\n", _("- Bare integers are interpreted as upper limits."));
+ printf (" %s\n", _("- When checking multiple OIDs, separate ranges by commas like '-w 1:10,1:,:20'"));
+ printf (" %s\n", _("- Note that only one string and one regex may be checked at present"));
+ printf (" %s\n", _("- All evaluation methods other than PR, STR, and SUBSTR expect that the value"));
+ printf (" %s\n", _("returned from the SNMP query is an unsigned integer."));
+#ifdef NP_EXTRA_OPTS
+ printf (" -%s", _(UT_EXTRA_OPTS_NOTES));
+#endif
printf (_(UT_SUPPORT));
}