aboutsummaryrefslogtreecommitdiff
path: root/plugins/tests/check_snmp.t
diff options
context:
space:
mode:
authorGravatar Thomas Guyot-Sionnest <dermoth@aei.ca> 2014-01-31 00:04:50 -0500
committerGravatar Thomas Guyot-Sionnest <dermoth@aei.ca> 2014-01-31 00:48:49 -0500
commitc4e3cd6efd5aef8665db103a66996e619526ab3b (patch)
tree5b19b9085a84c2d7fb666c8e33d42f3ab0694b79 /plugins/tests/check_snmp.t
parentbc92b9392009766441c67b06398e6925cc45c2aa (diff)
downloadmonitoring-plugins-c4e3cd6efd5aef8665db103a66996e619526ab3b.tar.gz
Add tests for negative thresholds in check_snmp
Next commit will work on fixing these!
Diffstat (limited to 'plugins/tests/check_snmp.t')
-rwxr-xr-xplugins/tests/check_snmp.t30
1 files changed, 29 insertions, 1 deletions
diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t
index dafc34fa..258c5a05 100755
--- a/plugins/tests/check_snmp.t
+++ b/plugins/tests/check_snmp.t
@@ -8,7 +8,7 @@ use Test::More;
use NPTest;
use FindBin qw($Bin);
-my $tests = 53;
+my $tests = 67;
# Check that all dependent modules are available
eval {
require NetSNMP::OID;
@@ -214,3 +214,31 @@ $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1
is($res->return_code, 0, "String check should check whole string, not a parsed number" );
is($res->output, 'SNMP OK - "CUSTOM CHECK OK: foo is 12345" | ', "String check witn numbers returns whole string");
+$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:" );
+is($res->return_code, 0, "Negative integer check OK" );
+is($res->output, 'SNMP OK - -2 | iso.3.6.1.4.1.8072.3.2.67.16=-2 ', "Negative integer check OK output" );
+
+$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:" );
+is($res->return_code, 1, "Negative integer check WARNING" );
+is($res->output, 'SNMP WARNING - *-3* | iso.3.6.1.4.1.8072.3.2.67.16=-3 ', "Negative integer check WARNING output" );
+
+$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:" );
+is($res->return_code, 2, "Negative integer check CRITICAL" );
+is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.16=-4 ', "Negative integer check CRITICAL output" );
+
+$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:" );
+is($res->return_code, 1, "Negative integer as string, WARNING" );
+is($res->output, 'SNMP WARNING - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4 ', "Negative integer as string, WARNING output" );
+
+$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:" );
+is($res->return_code, 2, "Negative integer as string, CRITICAL" );
+is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4 ', "Negative integer as string, CRITICAL output" );
+
+$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" );
+is($res->return_code, 0, "Negative float OK" );
+is($res->output, 'SNMP OK - -6.6 | iso.3.6.1.4.1.8072.3.2.67.18=-6.6 ', "Negative float OK output" );
+
+$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" );
+is($res->return_code, 1, "Negative float WARNING" );
+is($res->output, 'SNMP WARNING - *-6.6* | iso.3.6.1.4.1.8072.3.2.67.18=-6.6 ', "Negative float WARNING output" );
+