[Nagiosplug-checkins] nagiosplug/plugins check_snmp.c,1.56,1.57

Subhendu Ghosh sghosh at users.sourceforge.net
Wed Jun 1 12:43:02 CEST 2005


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7369

Modified Files:
	check_snmp.c 
Log Message:
only load mibs if needed or specified - patch 1212395

Index: check_snmp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_snmp.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- check_snmp.c	25 May 2005 15:40:32 -0000	1.56
+++ check_snmp.c	1 Jun 2005 19:41:01 -0000	1.57
@@ -121,7 +121,9 @@
 unsigned long eval_method[MAX_OIDS];
 char *delimiter;
 char *output_delim;
-char *miblist;
+char *miblist = NULL;
+int needmibs = FALSE;
+
 
 int
 main (int argc, char **argv)
@@ -158,7 +160,7 @@
 	output = strdup ("");
 	delimiter = strdup (" = ");
 	output_delim = strdup (DEFAULT_OUTPUT_DELIMITER);
-	miblist = strdup (DEFAULT_MIBLIST);
+	/* miblist = strdup (DEFAULT_MIBLIST); */
 	timeout_interval = DEFAULT_TIMEOUT;
 	retries = DEFAULT_RETRIES;
 
@@ -510,6 +512,15 @@
 				retries = atoi(optarg);
 			break;
 		case 'o':									/* object identifier */
+			if ( strspn( optarg, "0123456789." ) != strlen( optarg ) ) {
+					/*
+					 * we have something other than digits and periods, so we
+					 * have a mib variable, rather than just an SNMP OID, so
+					 * we have to actually read the mib files
+					 */
+					needmibs = TRUE;
+			}
+
 			for (ptr = optarg; (ptr = index (ptr, ',')); ptr++)
 				ptr[0] = ' '; /* relpace comma with space */
 			for (ptr = optarg; (ptr = index (ptr, ' ')); ptr++)
@@ -627,6 +638,8 @@
 
 	if (community == NULL)
 		community = strdup (DEFAULT_COMMUNITY);
+	
+
 
 	return validate_arguments ();
 }
@@ -640,13 +653,11 @@
 
 <para>&PROTO_validate_arguments;</para>
 
-<para>Given a database name, this function returns TRUE if the string
-is a valid PostgreSQL database name, and returns false if it is
-not.</para>
+<para>Checks to see if the default miblist needs to be loaded. Also verifies 
+the authentication and authorization combinations based on protocol version 
+selected.</para>
 
-<para>Valid PostgreSQL database names are less than &NAMEDATALEN;
-characters long and consist of letters, numbers, and underscores. The
-first character cannot be a number, however.</para>
+<para></para>
 
 </sect3>
 -@@
@@ -657,6 +668,15 @@
 int
 validate_arguments ()
 {
+	/* check whether to load locally installed MIBS (CPU/disk intensive) */
+	if (miblist == NULL) {
+		if ( needmibs  == TRUE ) {
+			miblist = strdup (DEFAULT_MIBLIST);
+		}else{
+			miblist = "''";			/* don't read any mib files for numeric oids */
+		}
+	}
+
 
 	/* Need better checks to verify seclevel and authproto choices */
 	
@@ -913,9 +933,11 @@
 	/* OID Stuff */
 	printf (_("\
  -o, --oid=OID(s)\n\
-    Object identifier(s) whose value you wish to query\n\
+    Object identifier(s) or SNMP variables whose value you wish to query\n\
  -m, --miblist=STRING\n\
-    List of MIBS to be loaded (default = ALL)\n -d, --delimiter=STRING\n\
+    List of MIBS to be loaded (default = none if using numeric oids or 'ALL'\n\
+		for symbolic oids.)\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);





More information about the Commits mailing list