diff options
| -rw-r--r-- | plugins/check_snmp.c | 7 | ||||
| -rw-r--r-- | plugins/t/check_snmp.t | 6 |
2 files changed, 10 insertions, 3 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index dff5bccd..9096cdad 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
| @@ -100,7 +100,7 @@ size_t nunits = 0; | |||
| 100 | size_t unitv_size = 8; | 100 | size_t unitv_size = 8; |
| 101 | int numoids = 0; | 101 | int numoids = 0; |
| 102 | int numauthpriv = 0; | 102 | int numauthpriv = 0; |
| 103 | int verbose = FALSE; | 103 | int verbose = 0; |
| 104 | int usesnmpgetnext = FALSE; | 104 | int usesnmpgetnext = FALSE; |
| 105 | char *warning_thresholds = NULL; | 105 | char *warning_thresholds = NULL; |
| 106 | char *critical_thresholds = NULL; | 106 | char *critical_thresholds = NULL; |
| @@ -255,6 +255,9 @@ main (int argc, char **argv) | |||
| 255 | ptr = chld_out.line[i]; | 255 | ptr = chld_out.line[i]; |
| 256 | oidname = strpcpy (oidname, ptr, delimiter); | 256 | oidname = strpcpy (oidname, ptr, delimiter); |
| 257 | response = strstr (ptr, delimiter); | 257 | response = strstr (ptr, delimiter); |
| 258 | if (verbose > 2) { | ||
| 259 | printf("Processing line %i\n line: %s\n oidname: %s\n response: %s\n", i+1, ptr, oidname, response); | ||
| 260 | } | ||
| 258 | 261 | ||
| 259 | /* We strip out the datatype indicator for PHBs */ | 262 | /* We strip out the datatype indicator for PHBs */ |
| 260 | 263 | ||
| @@ -431,7 +434,7 @@ process_arguments (int argc, char **argv) | |||
| 431 | print_revision (progname, NP_VERSION); | 434 | print_revision (progname, NP_VERSION); |
| 432 | exit (STATE_OK); | 435 | exit (STATE_OK); |
| 433 | case 'v': /* verbose */ | 436 | case 'v': /* verbose */ |
| 434 | verbose = TRUE; | 437 | verbose++; |
| 435 | break; | 438 | break; |
| 436 | 439 | ||
| 437 | /* Connection info */ | 440 | /* Connection info */ |
diff --git a/plugins/t/check_snmp.t b/plugins/t/check_snmp.t index e0138e6b..2ce08585 100644 --- a/plugins/t/check_snmp.t +++ b/plugins/t/check_snmp.t | |||
| @@ -8,7 +8,7 @@ use strict; | |||
| 8 | use Test::More; | 8 | use Test::More; |
| 9 | use NPTest; | 9 | use NPTest; |
| 10 | 10 | ||
| 11 | my $tests = 44; | 11 | my $tests = 46; |
| 12 | plan tests => $tests; | 12 | plan tests => $tests; |
| 13 | my $res; | 13 | my $res; |
| 14 | 14 | ||
| @@ -54,6 +54,10 @@ SKIP: { | |||
| 54 | cmp_ok( $value, ">", 0, "Got a time value" ); | 54 | cmp_ok( $value, ">", 0, "Got a time value" ); |
| 55 | like($res->perf_output, "/sysUpTime.*$1/", "Got perfdata with value '$1' in it"); | 55 | like($res->perf_output, "/sysUpTime.*$1/", "Got perfdata with value '$1' in it"); |
| 56 | 56 | ||
| 57 | $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:"); | ||
| 58 | cmp_ok( $res->return_code, '==', 0, "Test with numeric OID (no mibs loaded)" ); | ||
| 59 | like($res->output, '/^SNMP OK - \d+/', "String contains SNMP OK"); | ||
| 60 | |||
| 57 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysDescr.0"); | 61 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysDescr.0"); |
| 58 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying sysDescr" ); | 62 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying sysDescr" ); |
| 59 | unlike($res->perf_output, '/sysDescr/', "Perfdata doesn't contain string values"); | 63 | unlike($res->perf_output, '/sysDescr/', "Perfdata doesn't contain string values"); |
