summaryrefslogtreecommitdiffstats
path: root/plugins/tests
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/tests')
-rwxr-xr-xplugins/tests/check_snmp.t39
-rw-r--r--plugins/tests/check_snmp_agent.pl6
2 files changed, 41 insertions, 4 deletions
diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t
index b5f3f89e..17420792 100755
--- a/plugins/tests/check_snmp.t
+++ b/plugins/tests/check_snmp.t
@@ -51,7 +51,7 @@ if ($ARGV[0] && $ARGV[0] eq "-d") {
51 } 51 }
52} 52}
53 53
54my $tests = 9; 54my $tests = 21;
55if (-x "./check_snmp") { 55if (-x "./check_snmp") {
56 plan tests => $tests; 56 plan tests => $tests;
57} else { 57} else {
@@ -106,3 +106,40 @@ like($res->output, '/'.quotemeta('SNMP OK - And now have fun with with this: \"C
106"And now have fun with with this: \"C:\\\\\" 106"And now have fun with with this: \"C:\\\\\"
107because we\'re not done yet!"').'/m', "Attempt to confuse parser No.3"); 107because we\'re not done yet!"').'/m', "Attempt to confuse parser No.3");
108 108
109system("rm /usr/local/nagios/var/check_snmp/*");
110$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" );
111is($res->return_code, 0, "Returns OK");
112is($res->output, "No previous data to calculate rate - assume okay");
113
114# Need to sleep, otherwise duration=0
115sleep 1;
116
117$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" );
118is($res->return_code, 1, "WARNING - due to going above rate calculation" );
119is($res->output, "SNMP RATE WARNING - *666* | iso.3.6.1.4.1.8072.3.2.67.10-rate=666 ");
120
121$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" );
122is($res->return_code, 3, "UNKNOWN - basically the divide by zero error" );
123is($res->output, "Time duration between plugin calls is invalid");
124
125
126$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 -l inoctets" );
127is($res->return_code, 0, "OK for first call" );
128is($res->output, "No previous data to calculate rate - assume okay" );
129
130# Need to sleep, otherwise duration=0
131sleep 1;
132
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 -l inoctets" );
134is($res->return_code, 0, "OK as no thresholds" );
135is($res->output, "SNMP RATE OK - inoctets 666 | inoctets-rate=666 ", "Check label");
136
137sleep 2;
138
139$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 -l inoctets" );
140is($res->return_code, 0, "OK as no thresholds" );
141is($res->output, "SNMP RATE OK - inoctets 333 | inoctets-rate=333 ", "Check rate decreases due to longer interval");
142
143
144
145
diff --git a/plugins/tests/check_snmp_agent.pl b/plugins/tests/check_snmp_agent.pl
index 302ba6e7..425caeb3 100644
--- a/plugins/tests/check_snmp_agent.pl
+++ b/plugins/tests/check_snmp_agent.pl
@@ -33,9 +33,9 @@ ends with with this: C:\\';
33my $multilin5 = 'And now have fun with with this: "C:\\" 33my $multilin5 = 'And now have fun with with this: "C:\\"
34because we\'re not done yet!'; 34because we\'re not done yet!';
35 35
36my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED); 36my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER);
37my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32))); 37my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000);
38my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef); 38my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666);
39 39
40# Number of elements in our OID 40# Number of elements in our OID
41my $oidelts; 41my $oidelts;