diff options
Diffstat (limited to 'plugins/tests/check_snmp.t')
| -rwxr-xr-x | plugins/tests/check_snmp.t | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t index aace9bcc..73a68b20 100755 --- a/plugins/tests/check_snmp.t +++ b/plugins/tests/check_snmp.t | |||
| @@ -20,7 +20,16 @@ if ($@) { | |||
| 20 | plan skip_all => "Missing required module for test: $@"; | 20 | plan skip_all => "Missing required module for test: $@"; |
| 21 | } else { | 21 | } else { |
| 22 | if (-x "./check_snmp") { | 22 | if (-x "./check_snmp") { |
| 23 | plan tests => $tests; | 23 | # check if snmpd has perl support |
| 24 | my $test = `snmpd -c tests/conf/snmpd.conf -C -r -H 2>&1`; | ||
| 25 | if(!defined $test) { | ||
| 26 | plan skip_all => "snmpd required"; | ||
| 27 | } | ||
| 28 | elsif($test =~ m/Warning: Unknown token: perl/) { | ||
| 29 | plan skip_all => "snmpd has no perl support"; | ||
| 30 | } else { | ||
| 31 | plan tests => $tests; | ||
| 32 | } | ||
| 24 | } else { | 33 | } else { |
| 25 | plan skip_all => "No check_snmp compiled"; | 34 | plan skip_all => "No check_snmp compiled"; |
| 26 | } | 35 | } |
| @@ -119,7 +128,7 @@ sleep 1; | |||
| 119 | 128 | ||
| 120 | $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" ); | 129 | $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" ); |
| 121 | is($res->return_code, 1, "WARNING - due to going above rate calculation" ); | 130 | is($res->return_code, 1, "WARNING - due to going above rate calculation" ); |
| 122 | is($res->output, "SNMP RATE WARNING - *666* | iso.3.6.1.4.1.8072.3.2.67.10=666 "); | 131 | is($res->output, "SNMP RATE WARNING - *666* | iso.3.6.1.4.1.8072.3.2.67.10=666;600 "); |
| 123 | 132 | ||
| 124 | $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" ); | 133 | $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" ); |
| 125 | is($res->return_code, 3, "UNKNOWN - basically the divide by zero error" ); | 134 | is($res->return_code, 3, "UNKNOWN - basically the divide by zero error" ); |
| @@ -200,7 +209,7 @@ is($res->output, 'SNMP OK - "stringtests" | ', "OK as inverted string no match" | |||
| 200 | 209 | ||
| 201 | $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.12 -w 4:5" ); | 210 | $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.12 -w 4:5" ); |
| 202 | is($res->return_code, 1, "Numeric in string test" ); | 211 | is($res->return_code, 1, "Numeric in string test" ); |
| 203 | is($res->output, 'SNMP WARNING - *3.5* | iso.3.6.1.4.1.8072.3.2.67.12=3.5 ', "WARNING threshold checks for string masquerading as number" ); | 212 | is($res->output, 'SNMP WARNING - *3.5* | iso.3.6.1.4.1.8072.3.2.67.12=3.5;4:5 ', "WARNING threshold checks for string masquerading as number" ); |
| 204 | 213 | ||
| 205 | $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.13" ); | 214 | $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.13" ); |
| 206 | is($res->return_code, 0, "Not really numeric test" ); | 215 | is($res->return_code, 0, "Not really numeric test" ); |
| @@ -216,29 +225,29 @@ is($res->output, 'SNMP OK - "CUSTOM CHECK OK: foo is 12345" | ', "String check w | |||
| 216 | 225 | ||
| 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:" ); | 226 | $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" ); | 227 | 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" ); | 228 | is($res->output, 'SNMP OK - -2 | iso.3.6.1.4.1.8072.3.2.67.16=-2;-2:;-3: ', "Negative integer check OK output" ); |
| 220 | 229 | ||
| 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:" ); | 230 | $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" ); | 231 | 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" ); | 232 | is($res->output, 'SNMP WARNING - *-3* | iso.3.6.1.4.1.8072.3.2.67.16=-3;-2:;-3: ', "Negative integer check WARNING output" ); |
| 224 | 233 | ||
| 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:" ); | 234 | $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" ); | 235 | 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" ); | 236 | is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.16=-4;-2:;-3: ', "Negative integer check CRITICAL output" ); |
| 228 | 237 | ||
| 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:" ); | 238 | $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" ); | 239 | 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" ); | 240 | is($res->output, 'SNMP WARNING - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4;-3:;-6: ', "Negative integer as string, WARNING output" ); |
| 232 | 241 | ||
| 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:" ); | 242 | $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" ); | 243 | 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" ); | 244 | is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4;-2:;-3: ', "Negative integer as string, CRITICAL output" ); |
| 236 | 245 | ||
| 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" ); | 246 | $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" ); | 247 | 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" ); | 248 | is($res->output, 'SNMP OK - -6.6 | iso.3.6.1.4.1.8072.3.2.67.18=-6.6;;~:-6.5 ', "Negative float OK output" ); |
| 240 | 249 | ||
| 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" ); | 250 | $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" ); | 251 | 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" ); | 252 | is($res->output, 'SNMP WARNING - *-6.6* | iso.3.6.1.4.1.8072.3.2.67.18=-6.6;~:-6.65;~:-6.55 ', "Negative float WARNING output" ); |
| 244 | 253 | ||
