Debian Codegraph @

src/centreon/common/cisco/standard/snmp/mode/ipsla.pm

raw
1 #
2 # Copyright 2024 Centreon (http://www.centreon.com/)
3 #
4 # Centreon is a full-fledged industry-strength solution that meets
5 # the needs in IT infrastructure and application monitoring for
6 # service performance.
7 #
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 # http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 #
20
21 package centreon::common::cisco::standard::snmp::mode::ipsla;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27 use Digest::MD5 qw(md5_hex);
28 use Math::Complex;
29
30 sub set_counters {
31 my ($self, %options) = @_;
32
33 $self->{maps_counters_type} = [
34 { name => 'tag', type => 1, cb_prefix_output => 'prefix_tag_output', message_multiple => 'All RTT controls are ok',
35 skipped_code => { -2 => 1, -3 => 1, -10 => 1 } }
36 ];
37 $self->{maps_counters}->{tag} = [
38 { label => 'status', threshold => 0, set => {
39 key_values => [
40 { name => 'rttMonCtrlAdminStatus' },
41 { name => 'rttMonCtrlAdminTag' },
42 { name => 'rttMonCtrlAdminRttType' },
43 { name => 'rttMonCtrlAdminThreshold' },
44 { name => 'rttMonEchoAdminPrecision' },
45 { name => 'rttMonLatestRttOperCompletionTime' },
46 { name => 'rttMonLatestRttOperSense' },
47 { name => 'rttMonLatestRttOperApplSpecificSense' },
48 ],
49 closure_custom_calc => $self->can('custom_status_calc'),
50 closure_custom_output => $self->can('custom_status_output'),
51 closure_custom_perfdata => sub { return 0; },
52 closure_custom_threshold_check => $self->can('custom_status_threshold'),
53 }
54 },
55 { label => 'CompletionTime', set => {
56 key_values => [
57 { name => 'rttMonLatestRttOperCompletionTime' }, { name => 'rttMonEchoAdminPrecision' }, { name => 'rttMonCtrlAdminTag' }
58 ],
59 output_template => 'Completion Time : %s',
60 perfdatas => [
61 { label => 'completion_time', value => 'rttMonLatestRttOperCompletionTime', template => '%s',
62 min => 0, label_extra_instance => 1 },
63 ],
64 }
65 },
66 { label => 'NumberOverThresholds', set => {
67 key_values => [
68 { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
69 { name => 'OverThresholds_1' }, { name => 'OverThresholds_2' }, { name => 'OverThresholds_times' },
70 ],
71 closure_custom_calc => $self->can('custom_NumberOverThresholds_calc'),
72 closure_custom_output => $self->can('custom_generic_output'),
73 output_template => 'Number Over Thresholds : %s',
74 threshold_use => 'value',
75 perfdatas => [
76 { label => 'number_over_thresholds', value => 'value', template => '%s',
77 label_extra_instance => 1 },
78 ],
79 }
80 },
81 { label => 'AverageDelaySD', set => {
82 key_values => [
83 { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
84 { name => 'OWSumSD_1' }, { name => 'OWSumSD_2' }, { name => 'OWSumSD_times' },
85 { name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' },
86 ],
87 closure_custom_calc => $self->can('custom_AverageDelaySD_calc'),
88 closure_custom_output => $self->can('custom_generic_output'),
89 output_template => 'Average Delay SD : %.2f ms',
90 threshold_use => 'value',
91 perfdatas => [
92 { label => 'average_delay_sd', value => 'value', template => '%.2f', unit => 'ms',
93 label_extra_instance => 1 },
94 ],
95 }
96 },
97 { label => 'AverageDelayDS', set => {
98 key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
99 { name => 'OWSumDS_1' }, { name => 'OWSumDS_2' }, { name => 'OWSumDS_times' },
100 { name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' },
101 ],
102 closure_custom_calc => $self->can('custom_AverageDelayDS_calc'),
103 closure_custom_output => $self->can('custom_generic_output'),
104 output_template => 'Average Delay DS : %.2f ms',
105 threshold_use => 'value',
106 perfdatas => [
107 { label => 'average_delay_ds', value => 'value', template => '%.2f', unit => 'ms',
108 label_extra_instance => 1 },
109 ],
110 }
111 },
112 { label => 'PacketLossRatio', set => {
113 key_values => [
114 { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
115 { name => 'PacketLossDS_1' }, { name => 'PacketLossDS_2' }, { name => 'PacketLossDS_times' },
116 { name => 'PacketLossSD_1' }, { name => 'PacketLossSD_2' }, { name => 'PacketLossSD_times' },
117 { name => 'PacketMIA_1' }, { name => 'PacketMIA_2' }, { name => 'PacketMIA_times' },
118 { name => 'PacketLateArrival_1' }, { name => 'PacketLateArrival_2' }, { name => 'PacketLateArrival_times' },
119 { name => 'PacketOutOfSequence_1' }, { name => 'PacketOutOfSequence_2' }, { name => 'PacketOutOfSequence_times' },
120 { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' },
121 ],
122 closure_custom_calc => $self->can('custom_PacketLossRatio_calc'),
123 closure_custom_output => $self->can('custom_generic_output'),
124 output_template => 'Packet Loss Ratio : %.2f %%',
125 threshold_use => 'value',
126 perfdatas => [
127 { label => 'packet_loss_ratio', value => 'value', template => '%.2f', unit => '%',
128 label_extra_instance => 1, min => 0, max => 100 },
129 ],
130 }
131 },
132 { label => 'PercentagePacketsPositiveJitter', set => {
133 key_values => [
134 { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
135 { name => 'NumOfPositivesSD_1' }, { name => 'NumOfPositivesSD_2' }, { name => 'NumOfPositivesSD_times' },
136 { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' },
137 ],
138 closure_custom_calc => $self->can('custom_PercentagePacketsPositiveJitter_calc'),
139 closure_custom_output => $self->can('custom_generic_output'),
140 output_template => 'Percentage of Packets that had Positive Jitter : %.2f',
141 threshold_use => 'value',
142 perfdatas => [
143 { label => 'prct_jitter_per_packet_positive_jitter', value => 'value', template => '%.2f',
144 label_extra_instance => 1, },
145 ],
146 }
147 },
148 { label => 'AverageJitterPerPacketPositiveJitter', set => {
149 key_values => [
150 { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
151 { name => 'SumOfPositivesSD_1' }, { name => 'SumOfPositivesSD_2' }, { name => 'SumOfPositivesSD_times' },
152 { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' },
153 ],
154 closure_custom_calc => $self->can('custom_AverageJitterPerPacketPositiveJitter_calc'),
155 closure_custom_output => $self->can('custom_generic_output'),
156 output_template => 'Average Jitter per Packet that had Positive Jitter : %.2f',
157 threshold_use => 'value',
158 perfdatas => [
159 { label => 'average_jitter_per_packet_positive_jitter', value => 'value', template => '%.2f',
160 label_extra_instance => 1 },
161 ],
162 }
163 },
164 { label => 'PercentagePacketsNegativeJitter', set => {
165 key_values => [
166 { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
167 { name => 'NumOfNegativesSD_1' }, { name => 'NumOfNegativesSD_2' }, { name => 'NumOfNegativesSD_times' },
168 { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' },
169 ],
170 closure_custom_calc => $self->can('custom_PercentagePacketsNegativeJitter_calc'),
171 closure_custom_output => $self->can('custom_generic_output'),
172 output_template => 'Percentage of Packets that had Negative Jitter : %.2f',
173 threshold_use => 'value',
174 perfdatas => [
175 { label => 'prct_jitter_per_packet_negative_jitter', value => 'value', template => '%.2f',
176 label_extra_instance => 1, },
177 ],
178 }
179 },
180 { label => 'AverageJitterPerPacketNegativeJitter', set => {
181 key_values => [
182 { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
183 { name => 'SumOfNegativesSD_1' }, { name => 'SumOfNegativesSD_2' }, { name => 'SumOfNegativesSD_times' },
184 { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' },
185 ],
186 closure_custom_calc => $self->can('custom_AverageJitterPerPacketNegativeJitter_calc'),
187 closure_custom_output => $self->can('custom_generic_output'),
188 output_template => 'Average Jitter per Packet that had Negative Jitter : %.2f',
189 threshold_use => 'value',
190 perfdatas => [
191 { label => 'average_jitter_per_packet_negative_jitter', value => 'value', template => '%.2f',
192 label_extra_instance => 1 },
193 ],
194 }
195 },
196 { label => 'AverageJitter', set => {
197 key_values => [
198 { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
199 { name => 'SumOfPositivesDS_1' }, { name => 'SumOfPositivesDS_2' }, { name => 'SumOfPositivesDS_times' },
200 { name => 'SumOfNegativesDS_1' }, { name => 'SumOfNegativesDS_2' }, { name => 'SumOfNegativesDS_times' },
201 { name => 'SumOfPositivesSD_1' }, { name => 'SumOfPositivesSD_2' }, { name => 'SumOfPositivesSD_times' },
202 { name => 'SumOfNegativesSD_1' }, { name => 'SumOfNegativesSD_2' }, { name => 'SumOfNegativesSD_times' },
203 { name => 'NumOfPositivesDS_1' }, { name => 'NumOfPositivesDS_2' }, { name => 'NumOfPositivesDS_times' },
204 { name => 'NumOfNegativesDS_1' }, { name => 'NumOfNegativesDS_2' }, { name => 'NumOfNegativesDS_times' },
205 { name => 'NumOfPositivesSD_1' }, { name => 'NumOfPositivesSD_2' }, { name => 'NumOfPositivesSD_times' },
206 { name => 'NumOfNegativesSD_1' }, { name => 'NumOfNegativesSD_2' }, { name => 'NumOfNegativesSD_times' },
207 ],
208 closure_custom_calc => $self->can('custom_AverageJitter_calc'),
209 closure_custom_output => $self->can('custom_generic_output'),
210 output_template => 'Average Jitter : %.2f ms',
211 threshold_use => 'value',
212 perfdatas => [
213 { label => 'average_jitter', value => 'value', template => '%.2f', unit => 'ms',
214 label_extra_instance => 1 },
215 ],
216 }
217 },
218 { label => 'RTTStandardDeviation', set => {
219 key_values => [
220 { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
221 { name => 'RTTSum2High_1' }, { name => 'RTTSum2High_2' }, { name => 'RTTSum2High_times' },
222 { name => 'RTTSum2Low_1' }, { name => 'RTTSum2Low_2' }, { name => 'RTTSum2Low_times' },
223 { name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' },
224 { name => 'RTTSum_1' }, { name => 'RTTSum_2' }, { name => 'RTTSum_times' },
225 ],
226 closure_custom_calc => $self->can('custom_RTTStandardDeviation_calc'),
227 closure_custom_output => $self->can('custom_generic_output'),
228 output_template => 'Round-Trip Time Standard Deviation : %.2f ms',
229 threshold_use => 'value',
230 perfdatas => [
231 { label => 'rtt_standard_deviation', value => 'value', template => '%.2f', unit => 'ms',
232 label_extra_instance => 1 },
233 ],
234 }
235 },
236 { label => 'DelaySource2DestinationStandardDeviation', set => {
237 key_values => [
238 { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
239 { name => 'OWSum2SDHigh_1' }, { name => 'OWSum2SDHigh_2' }, { name => 'OWSum2SDHigh_times' },
240 { name => 'OWSum2SDLow_1' }, { name => 'OWSum2SDLow_2' }, { name => 'OWSum2SDLow_times' },
241 { name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' },
242 { name => 'OWSumSD_1' }, { name => 'OWSumSD_2' }, { name => 'OWSumSD_times' },
243 ],
244 closure_custom_calc => $self->can('custom_DelaySource2DestinationStandardDeviation_calc'),
245 closure_custom_output => $self->can('custom_generic_output'),
246 output_template => 'One-Way Delay Source to Destination Standard Deviation : %.2f ms',
247 threshold_use => 'value',
248 perfdatas => [
249 { label => 'delay_src2dest_stdev', value => 'value', template => '%.2f', unit => 'ms',
250 label_extra_instance => 1 },
251 ],
252 }
253 },
254 { label => 'DelayDestination2SourceStandardDeviation', set => {
255 key_values => [
256 { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
257 { name => 'OWSum2DSHigh_1' }, { name => 'OWSum2DSHigh_2' }, { name => 'OWSum2DSHigh_times' },
258 { name => 'OWSum2DSLow_1' }, { name => 'OWSum2DSLow_2' }, { name => 'OWSum2DSLow_times' },
259 { name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' },
260 { name => 'OWSumDS_1' }, { name => 'OWSumDS_2' }, { name => 'OWSumDS_times' },
261 ],
262 closure_custom_calc => $self->can('custom_DelayDestination2SourceStandardDeviation_calc'),
263 closure_custom_output => $self->can('custom_generic_output'),
264 output_template => 'One-Way Delay Destination to Source Standard Deviation : %.2f ms',
265 threshold_use => 'value',
266 perfdatas => [
267 { label => 'delay_dest2src_stdev', value => 'value', template => '%.2f', unit => 'ms',
268 label_extra_instance => 1 },
269 ],
270 }
271 },
272 { label => 'JitterSource2DestinationStandardDeviation', set => {
273 key_values => [
274 { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
275 { name => 'Sum2PositivesSDHigh_1' }, { name => 'Sum2PositivesSDHigh_2' }, { name => 'Sum2PositivesSDHigh_times' },
276 { name => 'Sum2PositivesSDLow_1' }, { name => 'Sum2PositivesSDLow_2' }, { name => 'Sum2PositivesSDLow_times' },
277 { name => 'Sum2NegativesSDHigh_1' }, { name => 'Sum2NegativesSDHigh_2' }, { name => 'Sum2NegativesSDHigh_times' },
278 { name => 'Sum2NegativesSDLow_1' }, { name => 'Sum2NegativesSDLow_2' }, { name => 'Sum2NegativesSDLow_times' },
279 { name => 'SumOfPositivesSD_1' }, { name => 'SumOfPositivesSD_2' }, { name => 'SumOfPositivesSD_times' },
280 { name => 'SumOfNegativesSD_1' }, { name => 'SumOfNegativesSD_2' }, { name => 'SumOfNegativesSD_times' },
281 { name => 'NumOfPositivesSD_1' }, { name => 'NumOfPositivesSD_2' }, { name => 'NumOfPositivesSD_times' },
282 { name => 'NumOfNegativesSD_1' }, { name => 'NumOfNegativesSD_2' }, { name => 'NumOfNegativesSD_times' },
283 ],
284 closure_custom_calc => $self->can('custom_JitterSource2DestinationStandardDeviation_calc'),
285 closure_custom_output => $self->can('custom_generic_output'),
286 output_template => 'One-Way Jitter Source to Destination Standard Deviation : %.2f ms',
287 threshold_use => 'value',
288 perfdatas => [
289 { label => 'jitter_src2dest_stdev', value => 'value', template => '%.2f', unit => 'ms',
290 label_extra_instance => 1 },
291 ],
292 }
293 },
294 { label => 'JitterDestination2SourceStandardDeviation', set => {
295 key_values => [
296 { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
297 { name => 'Sum2PositivesDSHigh_1' }, { name => 'Sum2PositivesDSHigh_2' }, { name => 'Sum2PositivesDSHigh_times' },
298 { name => 'Sum2PositivesDSLow_1' }, { name => 'Sum2PositivesDSLow_2' }, { name => 'Sum2PositivesDSLow_times' },
299 { name => 'Sum2NegativesDSHigh_1' }, { name => 'Sum2NegativesDSHigh_2' }, { name => 'Sum2NegativesDSHigh_times' },
300 { name => 'Sum2NegativesDSLow_1' }, { name => 'Sum2NegativesDSLow_2' }, { name => 'Sum2NegativesDSLow_times' },
301 { name => 'SumOfPositivesDS_1' }, { name => 'SumOfPositivesDS_2' }, { name => 'SumOfPositivesDS_times' },
302 { name => 'SumOfNegativesDS_1' }, { name => 'SumOfNegativesDS_2' }, { name => 'SumOfNegativesDS_times' },
303 { name => 'NumOfPositivesDS_1' }, { name => 'NumOfPositivesDS_2' }, { name => 'NumOfPositivesDS_times' },
304 { name => 'NumOfNegativesDS_1' }, { name => 'NumOfNegativesDS_2' }, { name => 'NumOfNegativesDS_times' },
305 ],
306 closure_custom_calc => $self->can('custom_JitterDestination2SourceStandardDeviation_calc'),
307 closure_custom_output => $self->can('custom_generic_output'),
308 output_template => 'One-Way Jitter Destination to Source Standard Deviation : %.2f ms',
309 threshold_use => 'value',
310 perfdatas => [
311 { label => 'jitter_dest2src_stdev', value => 'value', template => '%.2f', unit => 'ms',
312 label_extra_instance => 1 },
313 ],
314 }
315 },
316 ];
317 }
318
319 sub prefix_tag_output {
320 my ($self, %options) = @_;
321
322 return "RTT '" . $options{instance_value}->{rttMonCtrlAdminTag} . "' ";
323 }
324
325 my $ipsla;
326 my $thresholds = {
327 opersense => [
328 ['ok', 'OK'],
329 ['.*', 'CRITICAL'],
330 ],
331 applspecificsense => [
332 ['.*', 'OK'],
333 ],
334 };
335
336 ###### Common func ######
337
338 sub get_my_delta {
339 my ($self, %options) = @_;
340
341 my $value;
342 my ($old_time1, $old_time2) = split /_/, $options{old_datas}->{$self->{instance} . '_' . $options{name} . '_times'};
343 my ($new_time1, $new_time2) = split /_/, $options{new_datas}->{$self->{instance} . '_' . $options{name} . '_times'};
344 if (defined($old_time1) && defined($new_time1) && $old_time1 == $new_time1) {
345 $value = $options{new_datas}->{$self->{instance} . '_' . $options{name} . '_1'} - $options{old_datas}->{$self->{instance} . '_' . $options{name} . '_1'} +
346 $options{new_datas}->{$self->{instance} . '_' . $options{name} . '_2'} - $options{old_datas}->{$self->{instance} . '_' . $options{name} . '_2'};
347 } else {
348 $value = $options{new_datas}->{$self->{instance} . '_' . $options{name} . '_1'} - $options{old_datas}->{$self->{instance} . '_' . $options{name} . '_2'} +
349 $options{new_datas}->{$self->{instance} . '_' . $options{name} . '_2'};
350 }
351 return $value;
352 }
353
354 sub custom_generic_output {
355 my ($self, %options) = @_;
356
357 return sprintf($self->{output_template}, $self->{result_values}->{value});
358 }
359
360 sub check_buffer_creation {
361 my ($self, %options) = @_;
362
363 if (!defined($options{old_datas}->{$self->{instance} . '_' . $options{name} . '_1'})) {
364 $self->{error_msg} = "Buffer creation";
365 return 1;
366 }
367 return 0;
368 }
369
370 ###### STATUS ######
371
372 sub custom_status_threshold {
373 my ($self, %options) = @_;
374 my $status = 'ok';
375
376 if ($self->{result_values}->{rttMonCtrlAdminStatus} !~ /active/) {
377 return $status;
378 }
379
380 $status = $ipsla->get_severity(section => $self->{result_values}->{section}, value => $self->{result_values}->{opersense});
381 return $status;
382 }
383
384 sub custom_status_output {
385 my ($self, %options) = @_;
386 my $msg = 'Status : ';
387
388 if ($self->{result_values}->{rttMonCtrlAdminStatus} !~ /active/) {
389 $msg .= 'not active (' . $self->{result_values}->{rttMonCtrlAdminStatus} . ')';
390 return $msg;
391 }
392 $msg .= "operation sense is '" . $self->{result_values}->{opersense} . "'";
393 return $msg;
394 }
395
396 sub custom_status_calc {
397 my ($self, %options) = @_;
398
399 $self->{result_values}->{rttMonCtrlAdminStatus} = $options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminStatus'};
400 $self->{result_values}->{rttMonCtrlAdminTag} = $options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminTag'};
401 $self->{result_values}->{rttMonCtrlAdminRttType} = $options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminRttType'};
402 $self->{result_values}->{rttMonCtrlAdminThreshold} = $options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminThreshold'};
403 $self->{result_values}->{rttMonEchoAdminPrecision} = $options{new_datas}->{$self->{instance} . '_rttMonEchoAdminPrecision'};
404 $self->{result_values}->{rttMonLatestRttOperCompletionTime} = $options{new_datas}->{$self->{instance} . '_rttMonLatestRttOperCompletionTime'};
405 $self->{result_values}->{rttMonLatestRttOperSense} = $options{new_datas}->{$self->{instance} . '_rttMonLatestRttOperSense'};
406 $self->{result_values}->{rttMonLatestRttOperApplSpecificSense} = $options{new_datas}->{$self->{instance} . '_rttMonLatestRttOperApplSpecificSense'};
407 $self->{result_values}->{opersense} = $self->{result_values}->{rttMonLatestRttOperSense};
408 $self->{result_values}->{section} = 'opersense';
409 if ($self->{result_values}->{opersense} =~ /applicationSpecific/i) {
410 $self->{result_values}->{opersense} = $self->{result_values}->{rttMonLatestRttOperApplSpecificSense};
411 $self->{result_values}->{section} = 'applspecificsense';
412 }
413 return 0;
414 }
415
416 ####### 1 - Number Over Thresholds #######
417 sub custom_NumberOverThresholds_calc {
418 my ($self, %options) = @_;
419
420 if ($options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminStatus'} !~ /active/ &&
421 $options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminRttType'} !~ /jitter/) {
422 return -2;
423 }
424 return -1 if (check_buffer_creation($self, %options, name => 'OverThresholds'));
425
426 $self->{result_values}->{value} = get_my_delta($self, %options, name => 'OverThresholds');
427 return 0;
428 }
429
430 ####### 2 - Average Delay SD #######
431 sub custom_AverageDelaySD_calc {
432 my ($self, %options) = @_;
433
434 if ($options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminStatus'} !~ /active/ &&
435 $options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminRttType'} !~ /jitter/) {
436 return -2;
437 }
438 return -1 if (check_buffer_creation($self, %options, name => 'OWSumSD'));
439 my $num_of_ow = get_my_delta($self, %options, name => 'NumOfOW');
440 if ($num_of_ow == 0) {
441 $self->{error_msg} = "wait new values";
442 return -3;
443 }
444
445 $self->{result_values}->{value} = get_my_delta($self, %options, name => 'OWSumSD') / $num_of_ow;
446 return 0;
447 }
448
449 ####### 3 - Average Delay DS #######
450 sub custom_AverageDelayDS_calc {
451 my ($self, %options) = @_;
452
453 if ($options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminStatus'} !~ /active/ &&
454 $options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminRttType'} !~ /jitter/) {
455 return -2;
456 }
457 return -1 if (check_buffer_creation($self, %options, name => 'OWSumDS'));
458 my $num_of_ow = get_my_delta($self, %options, name => 'NumOfOW');
459 if ($num_of_ow == 0) {
460 $self->{error_msg} = "wait new values";
461 return -3;
462 }
463
464 $self->{result_values}->{value} = get_my_delta($self, %options, name => 'OWSumDS') / $num_of_ow;
465 return 0;
466 }
467
468 ####### 4 - Packet Loss Ratio #######
469 sub custom_PacketLossRatio_calc {
470 my ($self, %options) = @_;
471
472 if ($options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminStatus'} !~ /active/ &&
473 $options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminRttType'} !~ /jitter/) {
474 return -2;
475 }
476 return -1 if (check_buffer_creation($self, %options, name => 'PacketLossDS'));
477 my $divide = (get_my_delta($self, %options, name => 'PacketLossSD') + get_my_delta($self, %options, name => 'PacketLossDS') + get_my_delta($self, %options, name => 'PacketMIA') +
478 get_my_delta($self, %options, name => 'PacketLateArrival') + get_my_delta($self, %options, name => 'PacketOutOfSequence') + get_my_delta($self, %options, name => 'NumOfRTT'));
479 if ($divide == 0) {
480 $self->{error_msg} = "wait new values";
481 return -3;
482 }
483
484 $self->{result_values}->{value} = ((get_my_delta($self, %options, name => 'PacketLossDS') + get_my_delta($self, %options, name => 'PacketLossSD') + get_my_delta($self, %options, name => 'PacketMIA')) * 100 ) /
485 $divide;
486 return 0;
487 }
488
489 ####### 5 - Percentage of Packets that had Positive Jitter #######
490 sub custom_PercentagePacketsPositiveJitter_calc {
491 my ($self, %options) = @_;
492
493 if ($options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminStatus'} !~ /active/ &&
494 $options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminRttType'} !~ /jitter/) {
495 return -2;
496 }
497 return -1 if (check_buffer_creation($self, %options, name => 'NumOfPositivesSD'));
498 my $num_of_rtt = get_my_delta($self, %options, name => 'NumOfRTT');
499 if ($num_of_rtt == 0) {
500 $self->{error_msg} = "wait new values";
501 return -3;
502 }
503
504 $self->{result_values}->{value} = get_my_delta($self, %options, name => 'NumOfPositivesSD') / $num_of_rtt;
505 return 0;
506 }
507
508 ####### 6 - Average Jitter per Packet that had Positive Jitter #######
509 sub custom_AverageJitterPerPacketPositiveJitter_calc {
510 my ($self, %options) = @_;
511
512 if ($options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminStatus'} !~ /active/ &&
513 $options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminRttType'} !~ /jitter/) {
514 return -2;
515 }
516 return -1 if (check_buffer_creation($self, %options, name => 'SumOfPositivesSD'));
517 my $num_of_rtt = get_my_delta($self, %options, name => 'NumOfRTT');
518 if ($num_of_rtt == 0) {
519 $self->{error_msg} = "wait new values";
520 return -3;
521 }
522
523 $self->{result_values}->{value} = get_my_delta($self, %options, name => 'SumOfPositivesSD') / $num_of_rtt;
524 return 0;
525 }
526
527 ####### 7 - Percentage of Packets that had Negative Jitter #######
528 sub custom_PercentagePacketsNegativeJitter_calc {
529 my ($self, %options) = @_;
530
531 if ($options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminStatus'} !~ /active/ &&
532 $options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminRttType'} !~ /jitter/) {
533 return -2;
534 }
535 return -1 if (check_buffer_creation($self, %options, name => 'NumOfNegativesSD'));
536 my $num_of_rtt = get_my_delta($self, %options, name => 'NumOfRTT');
537 if ($num_of_rtt == 0) {
538 $self->{error_msg} = "wait new values";
539 return -3;
540 }
541
542 $self->{result_values}->{value} = get_my_delta($self, %options, name => 'NumOfNegativesSD') / $num_of_rtt;
543 return 0;
544 }
545
546 ####### 8 - Average Jitter per Packet that had Negative Jitter #######
547 sub custom_AverageJitterPerPacketNegativeJitter_calc {
548 my ($self, %options) = @_;
549
550 if ($options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminStatus'} !~ /active/ &&
551 $options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminRttType'} !~ /jitter/) {
552 return -2;
553 }
554 return -1 if (check_buffer_creation($self, %options, name => 'SumOfNegativesSD'));
555 my $num_of_rtt = get_my_delta($self, %options, name => 'NumOfRTT');
556 if ($num_of_rtt == 0) {
557 $self->{error_msg} = "wait new values";
558 return -3;
559 }
560
561 $self->{result_values}->{value} = get_my_delta($self, %options, name => 'SumOfNegativesSD') / $num_of_rtt;
562 return 0;
563 }
564
565 ####### 9 - Average Jitter #######
566 sub custom_AverageJitter_calc {
567 my ($self, %options) = @_;
568
569 if ($options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminStatus'} !~ /active/ &&
570 $options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminRttType'} !~ /jitter/) {
571 return -2;
572 }
573 return -1 if (check_buffer_creation($self, %options, name => 'SumOfPositivesDS'));
574 my $divide = (get_my_delta($self, %options, name => 'NumOfPositivesDS') + get_my_delta($self, %options, name => 'NumOfNegativesDS') + get_my_delta($self, %options, name => 'NumOfPositivesSD') + get_my_delta($self, %options, name => 'NumOfNegativesSD'));
575 if ($divide == 0) {
576 $self->{error_msg} = "wait new values";
577 return -3;
578 }
579
580 $self->{result_values}->{value} = (
581 get_my_delta($self, %options, name => 'SumOfPositivesDS') +
582 get_my_delta($self, %options, name => 'SumOfNegativesDS') +
583 get_my_delta($self, %options, name => 'SumOfPositivesSD') +
584 get_my_delta($self, %options, name => 'SumOfNegativesSD')) / $divide;
585 return 0;
586 }
587
588 ####### 10 - Round-Trip Time Standard Deviation #######
589 sub custom_RTTStandardDeviation_calc {
590 my ($self, %options) = @_;
591
592 if ($options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminStatus'} !~ /active/ &&
593 $options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminRttType'} !~ /jitter/) {
594 return -2;
595 }
596 return -1 if (check_buffer_creation($self, %options, name => 'NumOfRTT'));
597 my $num_of_rtt = get_my_delta($self, %options, name => 'NumOfRTT');
598 if ($num_of_rtt == 0) {
599 $self->{error_msg} = "wait new values";
600 return -3;
601 }
602
603 $self->{result_values}->{value} = sqrt(
604 ((get_my_delta($self, %options, name => 'RTTSum2High') * 2 ** 32 + get_my_delta($self, %options, name => 'RTTSum2Low')) / $num_of_rtt) -
605 (get_my_delta($self, %options, name => 'RTTSum') / $num_of_rtt) ** 2
606 );
607 return 0;
608 }
609
610 ####### 11 - One-Way Delay Source to Destination Standard Deviation #######
611 sub custom_DelaySource2DestinationStandardDeviation_calc {
612 my ($self, %options) = @_;
613
614 if ($options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminStatus'} !~ /active/ &&
615 $options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminRttType'} !~ /jitter/) {
616 return -2;
617 }
618 return -1 if (check_buffer_creation($self, %options, name => 'NumOfOW'));
619 my $num_of_ow = get_my_delta($self, %options, name => 'NumOfOW');
620 if ($num_of_ow == 0) {
621 $self->{error_msg} = "wait new values";
622 return -3;
623 }
624
625 $self->{result_values}->{value} = sqrt(
626 ((get_my_delta($self, %options, name => 'OWSum2SDHigh') * 2 ** 32 + get_my_delta($self, %options, name => 'OWSum2SDLow')) / $num_of_ow) -
627 (get_my_delta($self, %options, name => 'OWSumSD') / $num_of_ow) ** 2
628 );
629 return 0;
630 }
631
632 ####### 12 - One-Way Delay Destination to Source Standard Deviation #######
633 sub custom_DelayDestination2SourceStandardDeviation_calc {
634 my ($self, %options) = @_;
635
636 if ($options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminStatus'} !~ /active/ &&
637 $options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminRttType'} !~ /jitter/) {
638 return -2;
639 }
640 return -1 if (check_buffer_creation($self, %options, name => 'NumOfOW'));
641 my $num_of_ow = get_my_delta($self, %options, name => 'NumOfOW');
642 if ($num_of_ow == 0) {
643 $self->{error_msg} = "wait new values";
644 return -3;
645 }
646
647 $self->{result_values}->{value} = sqrt(
648 ((get_my_delta($self, %options, name => 'OWSum2DSHigh') * 2 ** 32 + get_my_delta($self, %options, name => 'OWSum2DSLow')) / $num_of_ow) -
649 (get_my_delta($self, %options, name => 'OWSumDS') / $num_of_ow) ** 2
650 );
651 return 0;
652 }
653
654 ####### 13 - One-Way Jitter Source to Destination Standard Deviation #######
655 sub custom_JitterSource2DestinationStandardDeviation_calc {
656 my ($self, %options) = @_;
657
658 if ($options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminStatus'} !~ /active/ &&
659 $options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminRttType'} !~ /jitter/) {
660 return -2;
661 }
662 return -1 if (check_buffer_creation($self, %options, name => 'NumOfPositivesSD'));
663 my $divide = (get_my_delta($self, %options, name => 'NumOfPositivesSD') + get_my_delta($self, %options, name => 'NumOfNegativesSD'));
664 if ($divide == 0) {
665 $self->{error_msg} = "wait new values";
666 return -3;
667 }
668
669 $self->{result_values}->{value} = sqrt(
670 ((get_my_delta($self, %options, name => 'Sum2PositivesSDHigh') * 2 ** 32 + get_my_delta($self, %options, name => 'Sum2PositivesSDLow') + get_my_delta($self, %options, name => 'Sum2NegativesSDHigh') * 2 ** 32 + get_my_delta($self, %options, name => 'Sum2NegativesSDLow')) / $divide) -
671 ((get_my_delta($self, %options, name => 'SumOfPositivesSD') + get_my_delta($self, %options, name => 'SumOfNegativesSD')) / $divide) ** 2
672 );
673 return 0;
674 }
675
676 ####### 14 - JitterDestination2SourceStandardDeviation #######
677 sub custom_JitterDestination2SourceStandardDeviation_calc {
678 my ($self, %options) = @_;
679
680 if ($options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminStatus'} !~ /active/ &&
681 $options{new_datas}->{$self->{instance} . '_rttMonCtrlAdminRttType'} !~ /jitter/) {
682 return -2;
683 }
684 return -1 if (check_buffer_creation($self, %options, name => 'NumOfPositivesDS'));
685 my $divide = (get_my_delta($self, %options, name => 'NumOfPositivesDS') + get_my_delta($self, %options, name => 'NumOfNegativesDS'));
686 if ($divide == 0) {
687 $self->{error_msg} = "wait new values";
688 return -3;
689 }
690
691 $self->{result_values}->{value} = sqrt(
692 ((get_my_delta($self, %options, name => 'Sum2PositivesDSHigh') * 2 ** 32 + get_my_delta($self, %options, name => 'Sum2PositivesDSLow') + get_my_delta($self, %options, name => 'Sum2NegativesDSHigh') * 2 ** 32 + get_my_delta($self, %options, name => 'Sum2NegativesDSLow')) / $divide) -
693 ((get_my_delta($self, %options, name => 'SumOfPositivesDS') + get_my_delta($self, %options, name => 'SumOfNegativesDS')) / $divide) ** 2
694 );
695 return 0;
696 }
697
698 my $oid_rttMonCtrlAdminEntry = '.1.3.6.1.4.1.9.9.42.1.2.1.1';
699 my $oid_rttMonEchoAdminPrecision = '.1.3.6.1.4.1.9.9.42.1.2.2.1.37';
700
701 my $oid_rttMonLatestRttOperEntry = '.1.3.6.1.4.1.9.9.42.1.2.10.1';
702
703 # Packet Loss Ratio (unit: %):
704 # [(RttMonJitterStatsPacketLossDS + RttMonJitterStatsPacketLossSD + RttMonJitterStatsPacketMIA) * 100 ] /
705 # [RttMonJitterStatsPacketLossSD + RttMonJitterStatsPacketLossDS + RttMonJitterStatsPacketMIA +
706 # RttMonJitterStatsPacketLateArrival + RttMonJitterStatsPacketOutOfSequence + RttMonJitterStatsNumOfRTT ]
707
708 # Percentage (unit: %):
709 # NumOfPositiveSD/NumOfRTT (Percentage of Packets that had Positive Jitter)
710 # SumOfPositiveSD/NumOfRTT (Average Jitter per Packet that had Positive Jitter)
711 # NumOfNegativeSD/NumOfRTT (Percentage of Packets that had Negative Jitter)
712 # SumOfNegativeSD/NumOfRTT (Average Jitter per Packet that had Negative Jitter)
713 #
714 # Average Jitter (unit: ms):
715 # jitterSum = sumOfPositivesDS + sumOfNegativesDS + sumOfPositivesSD + sumOfNegativesSD;
716 # jitterNum = numOfPositivesDS + numOfNegativesDS + numOfPositivesSD + numOfNegativesSD;
717 # avgJitter = jitterSum/jitterNum;
718
719 # Delays (unit: ms):
720 # RttMonJitterStatsOWSumSD / RttMonJitterStatsNumOfOW
721 # RttMonJitterStatsOWSumDS / RttMonJitterStatsNumOfOW
722
723 # Round-Trip Time Standard Deviation (unit: ms):
724 # Square Root of [ ((RttMonJitterStatsRTTSum2High * 2^32 + RttMonJitterStatsRTTSum2Low) / RttMonJitterStatsNumOfRTT) - (RttMonJitterStatsRTTSum / RttMonJitterStatsNumOfRTT)^2 ]
725 # One-Way Delay Source to Destination Standard Deviation (unit: ms):
726 # Square Root of [ ((RttMonJitterStatsOWSum2SDHigh * 2^32 + RttMonJitterStatsOWSum2SDLow) / RttMonJitterStatsNumOfOW) - (RttMonJitterStatsOWSumSD / RttMonJitterStatsNumOfOW)^2 ]
727 # One-Way Delay Destination to Source Standard Deviation (unit: ms):
728 # Square Root of [ ((RttMonJitterStatsOWSum2DSHigh * 2^32 + RttMonJitterStatsOWSum2DSLow) / RttMonJitterStatsNumOfOW) - (RttMonJitterStatsOWSumDS / RttMonJitterStatsNumOfOW)^2 ]
729 # One-Way Jitter Source to Destination Standard Deviation (unit: ms):
730 # Square Root of [ ((RttMonJitterStatsSum2PositivesSDHigh * 2^32 + RttMonJitterStatsSum2PositivesSDLow + RttMonJitterStatsSum2NegativesSDHigh * 2^32 + RttMonJitterStatsSum2NegativesSDLow) / (RttMonJitterStatsNumOfPositivesSD + RttMonJitterStatsNumOfNegativesSD)) - ((RttMonJitterStatsSumOfPositivesSD + RttMonJitterStatsSumOfNegativesSD) / (RttMonJitterStatsNumOfPositivesSD + RttMonJitterStatsNumOfNegativesSD))^2 ]
731 # One-Way Jitter Destination to Source Standard Deviation (unit: ms):
732 # Square Root of [ ((RttMonJitterStatsSum2PositivesDSHigh * 2^32 + RttMonJitterStatsSum2PositivesDSLow + RttMonJitterStatsSum2NegativesDSHigh * 2^32 + RttMonJitterStatsSum2NegativesDSLow) / (RttMonJitterStatsNumOfPositivesDS + RttMonJitterStatsNumOfNegativesDS)) - ((RttMonJitterStatsSumOfPositivesDS + RttMonJitterStatsSumOfNegativesDS) / (RttMonJitterStatsNumOfPositivesDS + RttMonJitterStatsNumOfNegativesDS))^2 ]
733
734 my $oid_rttMonJitterStatsEntry = '.1.3.6.1.4.1.9.9.42.1.3.5.1';
735 my $oids_jitter_stats = {
736 NumOfRTT => '.1.3.6.1.4.1.9.9.42.1.3.5.1.4',
737 OverThresholds => '.1.3.6.1.4.1.9.9.42.1.3.5.1.3',
738 RTTSum => '.1.3.6.1.4.1.9.9.42.1.3.5.1.5',
739 RTTSum2Low => '.1.3.6.1.4.1.9.9.42.1.3.5.1.6',
740 RTTSum2High => '.1.3.6.1.4.1.9.9.42.1.3.5.1.7',
741 NumOfOW => '.1.3.6.1.4.1.9.9.42.1.3.5.1.51',
742 OWSumSD => '.1.3.6.1.4.1.9.9.42.1.3.5.1.41', # low
743 OWSumSDHigh => '.1.3.6.1.4.1.9.9.42.1.3.5.1.67', # high
744 OWSumDS => '.1.3.6.1.4.1.9.9.42.1.3.5.1.46', # low
745 OWSumDSHigh => '.1.3.6.1.4.1.9.9.42.1.3.5.1.68', # high
746 SumOfPositivesSD => '.1.3.6.1.4.1.9.9.42.1.3.5.1.13',
747 SumOfNegativesSD => '.1.3.6.1.4.1.9.9.42.1.3.5.1.19',
748 SumOfPositivesDS => '.1.3.6.1.4.1.9.9.42.1.3.5.1.25',
749 SumOfNegativesDS => '.1.3.6.1.4.1.9.9.42.1.3.5.1.31',
750 NumOfNegativesSD => '.1.3.6.1.4.1.9.9.42.1.3.5.1.18',
751 Sum2NegativesSDLow => '.1.3.6.1.4.1.9.9.42.1.3.5.1.20',
752 Sum2NegativesSDHigh => '.1.3.6.1.4.1.9.9.42.1.3.5.1.21',
753 NumOfNegativesDS => '.1.3.6.1.4.1.9.9.42.1.3.5.1.30',
754 Sum2NegativesDSLow => '.1.3.6.1.4.1.9.9.42.1.3.5.1.32',
755 Sum2NegativesDSHigh => '.1.3.6.1.4.1.9.9.42.1.3.5.1.33',
756 NumOfPositivesSD => '.1.3.6.1.4.1.9.9.42.1.3.5.1.12',
757 Sum2PositivesSDLow => '.1.3.6.1.4.1.9.9.42.1.3.5.1.14',
758 Sum2PositivesSDHigh => '.1.3.6.1.4.1.9.9.42.1.3.5.1.15',
759 NumOfPositivesDS => '.1.3.6.1.4.1.9.9.42.1.3.5.1.24',
760 Sum2PositivesDSLow => '.1.3.6.1.4.1.9.9.42.1.3.5.1.26',
761 Sum2PositivesDSHigh => '.1.3.6.1.4.1.9.9.42.1.3.5.1.27',
762 PacketLossSD => '.1.3.6.1.4.1.9.9.42.1.3.5.1.34',
763 PacketLossDS => '.1.3.6.1.4.1.9.9.42.1.3.5.1.35',
764 PacketOutOfSequence => '.1.3.6.1.4.1.9.9.42.1.3.5.1.36',
765 PacketMIA => '.1.3.6.1.4.1.9.9.42.1.3.5.1.37',
766 PacketLateArrival => '.1.3.6.1.4.1.9.9.42.1.3.5.1.38',
767 OWSum2SDLow => '.1.3.6.1.4.1.9.9.42.1.3.5.1.42',
768 OWSum2SDHigh => '.1.3.6.1.4.1.9.9.42.1.3.5.1.43',
769 OWSum2DSLow => '.1.3.6.1.4.1.9.9.42.1.3.5.1.47',
770 OWSum2DSHigh => '.1.3.6.1.4.1.9.9.42.1.3.5.1.48',
771 MaxOfICPIF => '.1.3.6.1.4.1.9.9.42.1.3.5.1.59',
772 MaxOfMOS => '.1.3.6.1.4.1.9.9.42.1.3.5.1.57',
773 };
774
775 my %map_admin_rtt_type = (
776 1 => 'echo1', 2 => 'pathEcho', 3 => 'fileIO', 4 => 'script', 5 => 'udpEcho', 6 => 'tcpConnect',
777 7 => 'http', 8 => 'dns', 9 => 'jitter', 10 => 'dlsw', 11 => 'dhcp', 12 => 'ftp',
778 13 => 'voip', 14 => 'rtp', 15 => 'lspGroup', 16 => 'icmpjitter', 17 => 'lspPing',
779 18 => 'lspTrace', 19 => 'ethernetPing', 20 => 'ethernetJitter',
780 21 => 'lspPingPseudowire', 22 => 'video', 23 => 'y1731Delay', 24 => 'y1731Loss', 25 => 'mcastJitter',
781 );
782 my %map_admin_status = (
783 1 => 'active', 2 => 'notInService', 3 => 'notReady', 4 => 'createAndGo', 5 => 'createAndWait', 6 => 'destroy',
784 );
785 my %map_admin_precision = (
786 1 => 'ms',
787 2 => 'us',
788 );
789 my %map_rtt_oper_sense = (
790 0 => 'other', 1 => 'ok', 2 => 'disconnected', 3 => 'overThreshold', 4 => 'timeout', 5 => 'busy',
791 6 => 'notConnected', 7 => 'dropped', 8 => 'sequenceError', 9 => 'verifyError', 10 => 'applicationSpecific',
792 11 => 'dnsServerTimeout', 12 => 'tcpConnectTimeout', 13 => 'httpTransactionTimeout', 14 => 'dnsQueryError',
793 15 => 'httpError', 16 => 'error', 17 => 'mplsLspEchoTxError', 18 => 'mplsLspUnreachable',
794 19 => 'mplsLspMalformedReq', 20 => 'mplsLspReachButNotFEC', 21 => 'enableOk', 22 => 'enableNoConnect',
795 23 => 'enableVersionFail', 24 => 'enableInternalError', 25 => 'enableAbort', 26 => 'enableFail',
796 27 => 'enableAuthFail', 28 => 'enableFormatError', 29 => 'enablePortInUse', 30 => 'statsRetrieveOk',
797 31 => 'statsRetrieveNoConnect', 32 => 'statsRetrieveVersionFail', 33 => 'statsRetrieveInternalError',
798 34 => 'statsRetrieveAbort', 35 => 'statsRetrieveFail', 36 => 'statsRetrieveAuthFail',
799 37 => 'statsRetrieveFormatError', 38 => 'statsRetrievePortInUse',
800 );
801
802 my $mapping = {
803 rttMonCtrlAdminTag => { oid => '.1.3.6.1.4.1.9.9.42.1.2.1.1.3' },
804 rttMonCtrlAdminRttType => { oid => '.1.3.6.1.4.1.9.9.42.1.2.1.1.4', map => \%map_admin_rtt_type },
805 rttMonCtrlAdminThreshold => { oid => '.1.3.6.1.4.1.9.9.42.1.2.1.1.5' },
806 rttMonCtrlAdminStatus => { oid => '.1.3.6.1.4.1.9.9.42.1.2.1.1.9', map => \%map_admin_status },
807 };
808 my $mapping2 = {
809 rttMonEchoAdminPrecision => { oid => '.1.3.6.1.4.1.9.9.42.1.2.2.1.37', map => \%map_admin_precision },
810 };
811 my $mapping3 = {
812 rttMonLatestRttOperCompletionTime => { oid => '.1.3.6.1.4.1.9.9.42.1.2.10.1.1' },
813 rttMonLatestRttOperSense => { oid => '.1.3.6.1.4.1.9.9.42.1.2.10.1.2', map => \%map_rtt_oper_sense },
814 rttMonLatestRttOperApplSpecificSense => { oid => '.1.3.6.1.4.1.9.9.42.1.2.10.1.3' },
815 };
816
817 sub new {
818 my ($class, %options) = @_;
819 my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
820 bless $self, $class;
821
822 $options{options}->add_options(arguments => {
823 'filter-tag:s' => { name => 'filter_tag', default => '.*' },
824 'threshold-overload:s@' => { name => 'threshold_overload' },
825 });
826
827 return $self;
828 }
829
830 sub check_options {
831 my ($self, %options) = @_;
832 $self->SUPER::check_options(%options);
833
834 $self->{overload_th} = {};
835 foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
836 if ($val !~ /^(.*?),(.*?),(.*)$/) {
837 $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
838 $self->{output}->option_exit();
839 }
840 my ($section, $status, $filter) = ($1, $2, $3);
841 if ($self->{output}->is_litteral_status(status => $status) == 0) {
842 $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'.");
843 $self->{output}->option_exit();
844 }
845 $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
846 push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status};
847 }
848
849 # to be used on custom function
850 $ipsla = $self;
851 }
852
853 sub manage_selection {
854 my ($self, %options) = @_;
855
856 $self->{cache_name} = "cache_cisco_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
857 (defined($self->{option_results}->{filter_tag}) ? md5_hex($self->{option_results}->{filter_tag}) : md5_hex('all')) . '_' .
858 (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
859
860 $self->{results} = $options{snmp}->get_multiple_table(
861 oids => [
862 { oid => $oid_rttMonCtrlAdminEntry, end => $mapping->{rttMonCtrlAdminStatus}->{oid} },
863 { oid => $oid_rttMonEchoAdminPrecision },
864 { oid => $oid_rttMonLatestRttOperEntry, end => $mapping3->{rttMonLatestRttOperApplSpecificSense}->{oid} },
865 { oid => $oid_rttMonJitterStatsEntry },
866 ],
867 nothing_quit => 1
868 );
869
870 $self->{tag} = {};
871 foreach my $oid ($options{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rttMonCtrlAdminEntry}})) {
872 next if ($oid !~ /^$mapping->{rttMonCtrlAdminTag}->{oid}\.(.*)$/);
873 my $instance = $1;
874 my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rttMonCtrlAdminEntry}, instance => $instance);
875 $result->{rttMonCtrlAdminTag} = defined($result->{rttMonCtrlAdminTag}) && $result->{rttMonCtrlAdminTag} ne '' ? $result->{rttMonCtrlAdminTag} : $instance;
876 my $tag_name = $result->{rttMonCtrlAdminTag};
877 if (!defined($tag_name) || $tag_name eq '') {
878 $self->{output}->output_add(long_msg => "skipping: please set a tag name");
879 next;
880 }
881 if (defined($self->{tag}->{$tag_name})) {
882 $self->{output}->output_add(long_msg => "skipping '" . $tag_name . "': duplicate (please change the tag name).");
883 next;
884 }
885 if (defined($self->{option_results}->{filter_tag}) && $self->{option_results}->{filter_tag} ne '' &&
886 $tag_name !~ /$self->{option_results}->{filter_tag}/) {
887 $self->{output}->output_add(long_msg => "skipping '" . $tag_name . "': no matching filter.");
888 next;
889 }
890 $self->{tag}->{$tag_name} = { %{$result} };
891 $result = $options{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_rttMonEchoAdminPrecision}, instance => $instance);
892 $self->{tag}->{$tag_name} = { %{$result}, %{$self->{tag}->{$tag_name}} };
893 $result = $options{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$oid_rttMonLatestRttOperEntry}, instance => $instance);
894 $self->{tag}->{$tag_name} = { %{$result}, %{$self->{tag}->{$tag_name}} };
895
896 # there are two entries with rotation: 1 -> last hour, 2 -> current hour.
897 foreach my $key (keys %{$oids_jitter_stats}) {
898 $self->{tag}->{$tag_name}->{$key . '_1'} = 0;
899 $self->{tag}->{$tag_name}->{$key . '_2'} = 0;
900 my $i = 1;
901 my $instances = [];
902 foreach my $oid2 ($options{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rttMonJitterStatsEntry}})) {
903 next if ($oid2 !~ /^$oids_jitter_stats->{$key}\.$instance.(\d+)/);
904 push @{$instances}, $1;
905 $self->{tag}->{$tag_name}->{$key . '_' . $i} = $self->{results}->{$oid_rttMonJitterStatsEntry}->{$oid2};
906 $i++;
907 }
908 $self->{tag}->{$tag_name}->{$key . '_times'} = join('_', @{$instances});
909 }
910 }
911
912 if (scalar(keys %{$self->{tag}}) <= 0) {
913 $self->{output}->add_option_msg(short_msg => "No entry found.");
914 $self->{output}->option_exit();
915 }
916 }
917
918 sub get_severity {
919 my ($self, %options) = @_;
920 my $status = 'UNKNOWN'; # default
921
922 if (defined($self->{overload_th}->{$options{section}})) {
923 foreach (@{$self->{overload_th}->{$options{section}}}) {
924 if ($options{value} =~ /$_->{filter}/i) {
925 $status = $_->{status};
926 return $status;
927 }
928 }
929 }
930 foreach (@{$thresholds->{$options{section}}}) {
931 if ($options{value} =~ /$$_[0]/i) {
932 $status = $$_[1];
933 return $status;
934 }
935 }
936
937 return $status;
938 }
939
940 1;
941
942 __END__
943
944 =head1 MODE
945
946 Check RTT Controls (CISCO-RTT-MON)
947
948 =over 8
949
950 =item B<--filter-tag>
951
952 Filter tag (default: '.*')
953
954 =item B<--threshold-overload>
955
956 Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,status,regexp).
957 Example: --threshold-overload='opersense,CRITICAL,^(?!(ok)$)'
958
959 =item B<--warning-*>
960
961 Warning threshold.
962 Can be: 'CompletionTime', 'NumberOverThresholds', 'AverageDelaySD', 'AverageDelayDS', 'PacketLossRatio',
963 'PercentagePacketsPositiveJitter', 'AverageJitterPerPacketPositiveJitter', 'PercentagePacketsNegativeJitter', 'AverageJitterPerPacketNegativeJitter',
964 'AverageJitter', 'RTTStandardDeviation', 'DelaySource2DestinationStandardDeviation', 'DelayDestination2SourceStandardDeviation',
965 'JitterSource2DestinationStandardDeviation', 'JitterDestination2SourceStandardDeviation'.
966
967 =item B<--critical-*>
968
969 Critical threshold.
970 Can be: 'CompletionTime', 'NumberOverThresholds', 'AverageDelaySD', 'AverageDelayDS', 'PacketLossRatio',
971 'PercentagePacketsPositiveJitter', 'AverageJitterPerPacketPositiveJitter', 'PercentagePacketsNegativeJitter', 'AverageJitterPerPacketNegativeJitter',
972 'AverageJitter', 'RTTStandardDeviation', 'DelaySource2DestinationStandardDeviation', 'DelayDestination2SourceStandardDeviation',
973 'JitterSource2DestinationStandardDeviation', 'JitterDestination2SourceStandardDeviation'.
974
975 =back
976
977 =cut
978