diff options
Diffstat (limited to 'plugins/tests/check_snmp.t')
-rwxr-xr-x | plugins/tests/check_snmp.t | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t index 1ef0b209..d865e190 100755 --- a/plugins/tests/check_snmp.t +++ b/plugins/tests/check_snmp.t | |||
@@ -8,7 +8,7 @@ use Test::More; | |||
8 | use NPTest; | 8 | use NPTest; |
9 | use FindBin qw($Bin); | 9 | use FindBin qw($Bin); |
10 | 10 | ||
11 | my $tests = 53; | 11 | my $tests = 67; |
12 | # Check that all dependent modules are available | 12 | # Check that all dependent modules are available |
13 | eval { | 13 | eval { |
14 | require NetSNMP::OID; | 14 | require NetSNMP::OID; |
@@ -59,7 +59,7 @@ if ($ARGV[0] && $ARGV[0] eq "-d") { | |||
59 | } | 59 | } |
60 | 60 | ||
61 | # We should merge that with $ENV{'NPTEST_CACHE'}, use one dir for all test data | 61 | # We should merge that with $ENV{'NPTEST_CACHE'}, use one dir for all test data |
62 | $ENV{'NAGIOS_PLUGIN_STATE_DIRECTORY'} ||= "/var/tmp"; | 62 | $ENV{'MP_STATE_PATH'} ||= "/var/tmp"; |
63 | 63 | ||
64 | my $res; | 64 | my $res; |
65 | 65 | ||
@@ -79,7 +79,7 @@ Copyright (c) 1986-2004 by cisco Systems, Inc. | |||
79 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.0 -o sysContact.0 -o .1.3.6.1.4.1.8072.3.2.67.1"); | 79 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.0 -o sysContact.0 -o .1.3.6.1.4.1.8072.3.2.67.1"); |
80 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying multi-line OIDs" ); | 80 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying multi-line OIDs" ); |
81 | like($res->output, '/^SNMP OK - /', "String contains SNMP OK"); | 81 | like($res->output, '/^SNMP OK - /', "String contains SNMP OK"); |
82 | like($res->output, '/'.quotemeta('SNMP OK - Cisco Internetwork Operating System Software Alice Kisco Outernetwork Oserating Gystem Totware | | 82 | like($res->output, '/'.quotemeta('SNMP OK - Cisco Internetwork Operating System Software "Alice" Kisco Outernetwork Oserating Gystem Totware | |
83 | .1.3.6.1.4.1.8072.3.2.67.0: | 83 | .1.3.6.1.4.1.8072.3.2.67.0: |
84 | "Cisco Internetwork Operating System Software | 84 | "Cisco Internetwork Operating System Software |
85 | IOS (tm) Catalyst 4000 \"L3\" Switch Software (cat4000-I9K91S-M), Version | 85 | IOS (tm) Catalyst 4000 \"L3\" Switch Software (cat4000-I9K91S-M), Version |
@@ -109,7 +109,7 @@ like($res->output, '/'.quotemeta('SNMP OK - And now have fun with with this: \"C | |||
109 | "And now have fun with with this: \"C:\\\\\" | 109 | "And now have fun with with this: \"C:\\\\\" |
110 | because we\'re not done yet!"').'/m', "Attempt to confuse parser No.3"); | 110 | because we\'re not done yet!"').'/m', "Attempt to confuse parser No.3"); |
111 | 111 | ||
112 | system("rm -f ".$ENV{'NAGIOS_PLUGIN_STATE_DIRECTORY'}."/check_snmp/*"); | 112 | system("rm -f ".$ENV{'MP_STATE_PATH'}."/check_snmp/*"); |
113 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -w 600" ); | 113 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -w 600" ); |
114 | is($res->return_code, 0, "Returns OK"); | 114 | is($res->return_code, 0, "Returns OK"); |
115 | is($res->output, "No previous data to calculate rate - assume okay"); | 115 | is($res->output, "No previous data to calculate rate - assume okay"); |
@@ -214,3 +214,31 @@ $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1 | |||
214 | is($res->return_code, 0, "String check should check whole string, not a parsed number" ); | 214 | is($res->return_code, 0, "String check should check whole string, not a parsed number" ); |
215 | is($res->output, 'SNMP OK - "CUSTOM CHECK OK: foo is 12345" | ', "String check witn numbers returns whole string"); | 215 | is($res->output, 'SNMP OK - "CUSTOM CHECK OK: foo is 12345" | ', "String check witn numbers returns whole string"); |
216 | 216 | ||
217 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" ); | ||
218 | is($res->return_code, 0, "Negative integer check OK" ); | ||
219 | is($res->output, 'SNMP OK - -2 | iso.3.6.1.4.1.8072.3.2.67.16=-2 ', "Negative integer check OK output" ); | ||
220 | |||
221 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" ); | ||
222 | is($res->return_code, 1, "Negative integer check WARNING" ); | ||
223 | is($res->output, 'SNMP WARNING - *-3* | iso.3.6.1.4.1.8072.3.2.67.16=-3 ', "Negative integer check WARNING output" ); | ||
224 | |||
225 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" ); | ||
226 | is($res->return_code, 2, "Negative integer check CRITICAL" ); | ||
227 | is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.16=-4 ', "Negative integer check CRITICAL output" ); | ||
228 | |||
229 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.17 -w -3: -c -6:" ); | ||
230 | is($res->return_code, 1, "Negative integer as string, WARNING" ); | ||
231 | is($res->output, 'SNMP WARNING - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4 ', "Negative integer as string, WARNING output" ); | ||
232 | |||
233 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.17 -w -2: -c -3:" ); | ||
234 | is($res->return_code, 2, "Negative integer as string, CRITICAL" ); | ||
235 | is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4 ', "Negative integer as string, CRITICAL output" ); | ||
236 | |||
237 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.18 -c ~:-6.5" ); | ||
238 | is($res->return_code, 0, "Negative float OK" ); | ||
239 | is($res->output, 'SNMP OK - -6.6 | iso.3.6.1.4.1.8072.3.2.67.18=-6.6 ', "Negative float OK output" ); | ||
240 | |||
241 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.18 -w ~:-6.65 -c ~:-6.55" ); | ||
242 | is($res->return_code, 1, "Negative float WARNING" ); | ||
243 | is($res->output, 'SNMP WARNING - *-6.6* | iso.3.6.1.4.1.8072.3.2.67.18=-6.6 ', "Negative float WARNING output" ); | ||
244 | |||