[Nagiosplug-checkins] SF.net SVN: nagiosplug:[2234] nagiosplug/trunk/plugins

dermoth at users.sourceforge.net dermoth at users.sourceforge.net
Fri Jul 31 09:53:30 CEST 2009


Revision: 2234
          http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=2234&view=rev
Author:   dermoth
Date:     2009-07-31 07:53:30 +0000 (Fri, 31 Jul 2009)

Log Message:
-----------
check_snmp: Add some verbose output and tests

From: Thomas Guyot-Sionnest <dermoth at aei.ca>

Modified Paths:
--------------
    nagiosplug/trunk/plugins/check_snmp.c
    nagiosplug/trunk/plugins/t/check_snmp.t

Modified: nagiosplug/trunk/plugins/check_snmp.c
===================================================================
--- nagiosplug/trunk/plugins/check_snmp.c	2009-07-31 07:09:11 UTC (rev 2233)
+++ nagiosplug/trunk/plugins/check_snmp.c	2009-07-31 07:53:30 UTC (rev 2234)
@@ -100,7 +100,7 @@
 size_t unitv_size = 8;
 int numoids = 0;
 int numauthpriv = 0;
-int verbose = FALSE;
+int verbose = 0;
 int usesnmpgetnext = FALSE;
 char *warning_thresholds = NULL;
 char *critical_thresholds = NULL;
@@ -255,6 +255,9 @@
 		ptr = chld_out.line[i];
 		oidname = strpcpy (oidname, ptr, delimiter);
 		response = strstr (ptr, delimiter);
+		if (verbose > 2) {
+			printf("Processing line %i\n  line: %s\n  oidname: %s\n  response: %s\n", i+1, ptr, oidname, response);
+		}
 
 		/* We strip out the datatype indicator for PHBs */
 
@@ -431,7 +434,7 @@
 			print_revision (progname, NP_VERSION);
 			exit (STATE_OK);
 		case 'v': /* verbose */
-			verbose = TRUE;
+			verbose++;
 			break;
 
 	/* Connection info */

Modified: nagiosplug/trunk/plugins/t/check_snmp.t
===================================================================
--- nagiosplug/trunk/plugins/t/check_snmp.t	2009-07-31 07:09:11 UTC (rev 2233)
+++ nagiosplug/trunk/plugins/t/check_snmp.t	2009-07-31 07:53:30 UTC (rev 2234)
@@ -8,7 +8,7 @@
 use Test::More;
 use NPTest;
 
-my $tests = 44;
+my $tests = 46;
 plan tests => $tests;
 my $res;
 
@@ -54,6 +54,10 @@
 		cmp_ok( $value, ">", 0, "Got a time value" );
 		like($res->perf_output, "/sysUpTime.*$1/", "Got perfdata with value '$1' in it");
 
+		$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o .1.3.6.1.2.1.1.3.0 -w 1: -c 1:");
+		cmp_ok( $res->return_code, '==', 0, "Test with numeric OID (no mibs loaded)" );
+		like($res->output, '/^SNMP OK - \d+/', "String contains SNMP OK");
+
 		$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysDescr.0");
 		cmp_ok( $res->return_code, '==', 0, "Exit OK when querying sysDescr" ); 
 		unlike($res->perf_output, '/sysDescr/', "Perfdata doesn't contain string values");


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Commits mailing list