diff options
author | Ton Voon <ton.voon@opsera.com> | 2010-06-17 10:16:43 +0100 |
---|---|---|
committer | tonvoon <ton.voon@opsera.com> | 2010-06-23 13:30:34 +0000 |
commit | 18f6835edaf7d640a2c9e476cb1babdbdadbfd9b (patch) | |
tree | ae11f40e48dc34658445c99012726f32bfb45c56 /plugins/tests/check_snmp.t | |
parent | f61412478ceb7c821793c8356b936f64066508bf (diff) | |
download | monitoring-plugins-18f6835edaf7d640a2c9e476cb1babdbdadbfd9b.tar.gz |
Added state retention APIs. Implemented for check_snmp with --rate option.
See http://nagiosplugin.org/c-api-private for more details on the API.
Also updated check_snmp -l option to change the perfdata label.
Diffstat (limited to 'plugins/tests/check_snmp.t')
-rwxr-xr-x | plugins/tests/check_snmp.t | 39 |
1 files changed, 38 insertions, 1 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 | ||
54 | my $tests = 9; | 54 | my $tests = 21; |
55 | if (-x "./check_snmp") { | 55 | if (-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:\\\\\" |
107 | because we\'re not done yet!"').'/m', "Attempt to confuse parser No.3"); | 107 | because we\'re not done yet!"').'/m', "Attempt to confuse parser No.3"); |
108 | 108 | ||
109 | system("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" ); | ||
111 | is($res->return_code, 0, "Returns OK"); | ||
112 | is($res->output, "No previous data to calculate rate - assume okay"); | ||
113 | |||
114 | # Need to sleep, otherwise duration=0 | ||
115 | sleep 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" ); | ||
118 | is($res->return_code, 1, "WARNING - due to going above rate calculation" ); | ||
119 | is($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" ); | ||
122 | is($res->return_code, 3, "UNKNOWN - basically the divide by zero error" ); | ||
123 | is($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" ); | ||
127 | is($res->return_code, 0, "OK for first call" ); | ||
128 | is($res->output, "No previous data to calculate rate - assume okay" ); | ||
129 | |||
130 | # Need to sleep, otherwise duration=0 | ||
131 | sleep 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" ); | ||
134 | is($res->return_code, 0, "OK as no thresholds" ); | ||
135 | is($res->output, "SNMP RATE OK - inoctets 666 | inoctets-rate=666 ", "Check label"); | ||
136 | |||
137 | sleep 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" ); | ||
140 | is($res->return_code, 0, "OK as no thresholds" ); | ||
141 | is($res->output, "SNMP RATE OK - inoctets 333 | inoctets-rate=333 ", "Check rate decreases due to longer interval"); | ||
142 | |||
143 | |||
144 | |||
145 | |||