[Nagiosplug-checkins] CVS: nagiosplug/plugins check_snmp.c,1.31,1.32

Karl DeBisschop kdebisschop at users.sourceforge.net
Thu Aug 7 05:01:08 CEST 2003


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv27545

Modified Files:
	check_snmp.c 
Log Message:
reorder for consistency (no code changes)

Index: check_snmp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_snmp.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -r1.31 -r1.32
*** check_snmp.c	7 Aug 2003 11:51:12 -0000	1.31
--- check_snmp.c	7 Aug 2003 12:00:18 -0000	1.32
***************
*** 1,26 ****
  /******************************************************************************
!  *
!  * Program: SNMP plugin for Nagios
!  * License: GPL
!  *
!  * License Information:
!  *
!  * 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
!  * (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.
!  *
!  *./plugins/check_snmp 127.0.0.1 -c public -o .1.3.6.1.4.1.2021.9.1.2.1
!  *
!  *****************************************************************************/
  
  const char *progname = "check_snmp";
--- 1,19 ----
  /******************************************************************************
! 
!  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
!  (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.
! 
! ******************************************************************************/
  
  const char *progname = "check_snmp";
***************
*** 29,32 ****
--- 22,29 ----
  const char *email = "nagiosplug-devel at lists.sourceforge.net";
  
+ #include "common.h"
+ #include "utils.h"
+ #include "popen.h"
+ 
  #define DEFAULT_COMMUNITY "public"
  #define DEFAULT_PORT "161"
***************
*** 37,164 ****
  #define DEFAULT_OUTPUT_DELIMITER " "
  
- #include "common.h"
- #include "utils.h"
- #include "popen.h"
- 
- void
- print_usage (void)
- {
- 	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);
- }
- 
- void
- print_help (void)
- {
- 	print_revision (progname, revision);
- 
- 	printf (_(COPYRIGHT), copyright, email);
- 
- 	printf (_("\
- Check status of remote machines and obtain sustem information via SNMP\n\n"));
- 
- 	print_usage ();
- 
- 	printf (_(UT_HELP_VRSN));
- 
- 	printf (_(UT_HOST_PORT), 'p', DEFAULT_PORT);
- 
- 	/* SNMP and Authentication Protocol */
- 	printf (_("\
-  -P, --protocol=[1|3]\n\
-     SNMP protocol version\n\
-  -L, --seclevel=[noAuthNoPriv|authNoPriv|authPriv]\n\
-     SNMPv3 securityLevel\n\
-  -a, --authproto=[MD5|SHA]\n\
-     SNMPv3 auth proto\n"));
- 
- 	/* Authentication Tokens*/
- 	printf (_("\
-  -C, --community=STRING\n\
-     Optional community string for SNMP communication\n\
-     (default is \"%s\")\n\
-  -U, --secname=USERNAME\n\
-     SNMPv3 username\n\
-  -A, --authpassword=PASSWORD\n\
-     SNMPv3 authentication password\n\
-  -X, --privpasswd=PASSWORD\n\
-     SNMPv3 crypt passwd (DES)\n"), DEFAULT_COMMUNITY);
- 
- 	/* OID Stuff */
- 	printf (_("\
-  -o, --oid=OID(s)\n\
-     Object identifier(s) whose value you wish to query\n\
-  -m, --miblist=STRING\n\
-     List of MIBS to be loaded (default = ALL)\n -d, --delimiter=STRING\n\
-     Delimiter to use when parsing returned data. Default is \"%s\"\n\
-     Any data on the right hand side of the delimiter is considered\n\
-     to be the data that should be used in the evaluation.\n"), DEFAULT_DELIMITER);
- 
- 	/* Tests Against Integers */
- 	printf (_("\
-  -w, --warning=INTEGER_RANGE(s)\n\
-     Range(s) which will not result in a WARNING status\n\
-  -c, --critical=INTEGER_RANGE(s)\n\
-     Range(s) which will not result in a CRITICAL status\n"));
- 
- 	/* Tests Against Strings */
- 	printf (_("\
-  -s, --string=STRING\n\
-     Return OK state (for that OID) if STRING is an exact match\n\
-  -r, --ereg=REGEX\n\
-     Return OK state (for that OID) if extended regular expression REGEX matches\n\
-  -R, --eregi=REGEX\n\
-     Return OK state (for that OID) if case-insensitive extended REGEX matches\n\
-  -l, --label=STRING\n\
-     Prefix label for output from plugin (default -s 'SNMP')\n"));
- 
- 	/* Output Formatting */
- 	printf (_("\
-  -u, --units=STRING\n\
-     Units label(s) for output data (e.g., 'sec.').\n\
-  -D, --output-delimiter=STRING\n\
-     Separates output on multiple OID requests\n"));
- 
- 	printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
- 
- 	printf (_(UT_VERBOSE));
- 
- 	printf (_("\n\
- - This plugin uses the 'snmpget' command included with the NET-SNMP package.\n\
-   If you don't have the package installed, you will need to download it from\n\
-   http://net-snmp.sourceforge.net before you can use this plugin.\n"));
- 
- 	printf (_("\
- - Multiple OIDs may be indicated by a comma- or space-delimited list (lists with\n\
-   internal spaces must be quoted) [max 8 OIDs]\n"));
- 
- 	printf (_("\
- - Ranges are inclusive and are indicated with colons. When specified as\n\
-   'min:max' a STATE_OK will be returned if the result is within the indicated\n\
-   range or is equal to the upper or lower bound. A non-OK state will be\n\
-   returned if the result is outside the specified range.\n"));
- 
- 	printf (_("\
- - If specified in the order 'max:min' a non-OK state will be returned if the\n\
-   result is within the (inclusive) range.\n"));
- 
- 	printf (_("\
- - Upper or lower bounds may be omitted to skip checking the respective limit.\n\
- - Bare integers are interpreted as upper limits.\n\
- - When checking multiple OIDs, separate ranges by commas like '-w 1:10,1:,:20'\n\
- - Note that only one string and one regex may be checked at present\n\
- - All evaluation methods other than PR, STR, and SUBSTR expect that the value\n\
-   returned from the SNMP query is an unsigned integer.\n"));
- 
- 	printf (_(UT_SUPPORT));
- }
- 
- 
  #define mark(a) ((a)!=0?"*":"")
  
--- 34,37 ----
***************
*** 188,201 ****
  #define MAX_DELIM_LENGTH 8
  
- void print_usage (void);
- void print_help (void);
  int process_arguments (int, char **);
  int validate_arguments (void);
- int check_num (int);
  char *clarify_message (char *);
  int lu_getll (unsigned long *, char *);
  int lu_getul (unsigned long *, char *);
  char *thisarg (char *str);
  char *nextarg (char *str);
  
  #ifdef HAVE_REGEX_H
--- 61,74 ----
  #define MAX_DELIM_LENGTH 8
  
  int process_arguments (int, char **);
  int validate_arguments (void);
  char *clarify_message (char *);
+ int check_num (int);
  int lu_getll (unsigned long *, char *);
  int lu_getul (unsigned long *, char *);
  char *thisarg (char *str);
  char *nextarg (char *str);
+ void print_usage (void);
+ void print_help (void);
  
  #ifdef HAVE_REGEX_H
***************
*** 245,248 ****
--- 118,125 ----
  
  
+ 
+ 
+ 
+ 
  int
  main (int argc, char **argv)
***************
*** 428,435 ****
  
  	if (found == 0)
! 		die
! 			(STATE_UNKNOWN,
! 			 _("%s problem - No data recieved from host\nCMD: %s\n"),
! 			 label, command_line);
  
  	/* WARNING if output found on stderr */
--- 305,312 ----
  
  	if (found == 0)
! 		die (STATE_UNKNOWN,
! 		     _("%s problem - No data recieved from host\nCMD: %s\n"),
! 		     label,
! 		     command_line);
  
  	/* WARNING if output found on stderr */
***************
*** 452,455 ****
--- 329,337 ----
  }
  
+ 
+ 
+ 
+ 
+ 
  /* process command-line arguments */
  int
***************
*** 709,712 ****
--- 591,597 ----
  }
  
+ 
+ 
+ 
  /******************************************************************************
  
***************
*** 784,790 ****
  	return OK;
  }
- 
  
  
  char *
  clarify_message (char *msg)
--- 669,678 ----
  	return OK;
  }
  
  
+ 
+ 
+ 
+ 
  char *
  clarify_message (char *msg)
***************
*** 823,826 ****
--- 711,716 ----
  
  
+ 
+ 
  int
  check_num (int i)
***************
*** 866,869 ****
--- 756,761 ----
  
  
+ 
+ 
  int
  lu_getll (unsigned long *ll, char *str)
***************
*** 879,882 ****
--- 771,777 ----
  }
  
+ 
+ 
+ 
  int
  lu_getul (unsigned long *ul, char *str)
***************
*** 895,900 ****
  
  
- 
- 
  /* trim leading whitespace
  	 if there is a leading quote, make sure it balances */
--- 790,793 ----
***************
*** 912,915 ****
--- 805,810 ----
  
  
+ 
+ 
  /* if there's a leading quote, advance to the trailing quote
  	 set the trailing quote to '\x0'
***************
*** 945,947 ****
--- 840,966 ----
  	}
  	return NULL;
+ }
+ 
+ 
+ 
+ 
+ 
+ 
+ void
+ print_help (void)
+ {
+ 	print_revision (progname, revision);
+ 
+ 	printf (_(COPYRIGHT), copyright, email);
+ 
+ 	printf (_("\
+ Check status of remote machines and obtain sustem information via SNMP\n\n"));
+ 
+ 	print_usage ();
+ 
+ 	printf (_(UT_HELP_VRSN));
+ 
+ 	printf (_(UT_HOST_PORT), 'p', DEFAULT_PORT);
+ 
+ 	/* SNMP and Authentication Protocol */
+ 	printf (_("\
+  -P, --protocol=[1|3]\n\
+     SNMP protocol version\n\
+  -L, --seclevel=[noAuthNoPriv|authNoPriv|authPriv]\n\
+     SNMPv3 securityLevel\n\
+  -a, --authproto=[MD5|SHA]\n\
+     SNMPv3 auth proto\n"));
+ 
+ 	/* Authentication Tokens*/
+ 	printf (_("\
+  -C, --community=STRING\n\
+     Optional community string for SNMP communication\n\
+     (default is \"%s\")\n\
+  -U, --secname=USERNAME\n\
+     SNMPv3 username\n\
+  -A, --authpassword=PASSWORD\n\
+     SNMPv3 authentication password\n\
+  -X, --privpasswd=PASSWORD\n\
+     SNMPv3 crypt passwd (DES)\n"), DEFAULT_COMMUNITY);
+ 
+ 	/* OID Stuff */
+ 	printf (_("\
+  -o, --oid=OID(s)\n\
+     Object identifier(s) whose value you wish to query\n\
+  -m, --miblist=STRING\n\
+     List of MIBS to be loaded (default = ALL)\n -d, --delimiter=STRING\n\
+     Delimiter to use when parsing returned data. Default is \"%s\"\n\
+     Any data on the right hand side of the delimiter is considered\n\
+     to be the data that should be used in the evaluation.\n"), DEFAULT_DELIMITER);
+ 
+ 	/* Tests Against Integers */
+ 	printf (_("\
+  -w, --warning=INTEGER_RANGE(s)\n\
+     Range(s) which will not result in a WARNING status\n\
+  -c, --critical=INTEGER_RANGE(s)\n\
+     Range(s) which will not result in a CRITICAL status\n"));
+ 
+ 	/* Tests Against Strings */
+ 	printf (_("\
+  -s, --string=STRING\n\
+     Return OK state (for that OID) if STRING is an exact match\n\
+  -r, --ereg=REGEX\n\
+     Return OK state (for that OID) if extended regular expression REGEX matches\n\
+  -R, --eregi=REGEX\n\
+     Return OK state (for that OID) if case-insensitive extended REGEX matches\n\
+  -l, --label=STRING\n\
+     Prefix label for output from plugin (default -s 'SNMP')\n"));
+ 
+ 	/* Output Formatting */
+ 	printf (_("\
+  -u, --units=STRING\n\
+     Units label(s) for output data (e.g., 'sec.').\n\
+  -D, --output-delimiter=STRING\n\
+     Separates output on multiple OID requests\n"));
+ 
+ 	printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
+ 
+ 	printf (_(UT_VERBOSE));
+ 
+ 	printf (_("\n\
+ - This plugin uses the 'snmpget' command included with the NET-SNMP package.\n\
+   If you don't have the package installed, you will need to download it from\n\
+   http://net-snmp.sourceforge.net before you can use this plugin.\n"));
+ 
+ 	printf (_("\
+ - Multiple OIDs may be indicated by a comma- or space-delimited list (lists with\n\
+   internal spaces must be quoted) [max 8 OIDs]\n"));
+ 
+ 	printf (_("\
+ - Ranges are inclusive and are indicated with colons. When specified as\n\
+   'min:max' a STATE_OK will be returned if the result is within the indicated\n\
+   range or is equal to the upper or lower bound. A non-OK state will be\n\
+   returned if the result is outside the specified range.\n"));
+ 
+ 	printf (_("\
+ - If specified in the order 'max:min' a non-OK state will be returned if the\n\
+   result is within the (inclusive) range.\n"));
+ 
+ 	printf (_("\
+ - Upper or lower bounds may be omitted to skip checking the respective limit.\n\
+ - Bare integers are interpreted as upper limits.\n\
+ - When checking multiple OIDs, separate ranges by commas like '-w 1:10,1:,:20'\n\
+ - Note that only one string and one regex may be checked at present\n\
+ - All evaluation methods other than PR, STR, and SUBSTR expect that the value\n\
+   returned from the SNMP query is an unsigned integer.\n"));
+ 
+ 	printf (_(UT_SUPPORT));
+ }
+ 
+ void
+ print_usage (void)
+ {
+ 	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);
  }





More information about the Commits mailing list