Debian Codegraph @

src/centreon/common/cisco/standard/snmp/mode/qosusage.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::qosusage;
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::BigInt;
29 use Math::BigFloat;
30
31 sub custom_traffic_perfdata {
32 my ($self, %options) = @_;
33
34 my ($warning, $critical);
35 if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' &&
36 (defined($self->{result_values}->{total}) && $self->{result_values}->{total} =~ /[0-9]/)) {
37 $warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1);
38 $critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1);
39 } elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') {
40 $warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel});
41 $critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel});
42 }
43
44 $self->{output}->perfdata_add(
45 nlabel => $self->{nlabel},
46 unit => 'b/s',
47 instances => $self->{result_values}->{display},
48 value => sprintf('%.2f', $self->{result_values}->{traffic_per_second}),
49 warning => $warning,
50 critical => $critical,
51 min => 0, max => ($self->{result_values}->{total} =~ /[0-9]/ ? $self->{result_values}->{total} : undef)
52 );
53 }
54
55 sub custom_traffic_threshold {
56 my ($self, %options) = @_;
57
58 my $exit = 'ok';
59 if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' &&
60 (defined($self->{result_values}->{total}) && $self->{result_values}->{total} =~ /[0-9]/)) {
61 $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_prct}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]);
62 } elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') {
63 $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_per_second}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]);
64 }
65 return $exit;
66 }
67
68 sub custom_traffic_output {
69 my ($self, %options) = @_;
70
71 my ($traffic_value, $traffic_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{traffic_per_second}, network => 1);
72 return sprintf(
73 'traffic: %s/s%s',
74 $traffic_value . $traffic_unit,
75 defined($self->{result_values}->{traffic_prct}) ? sprintf(' (%.2f%%)', $self->{result_values}->{traffic_prct}) : ''
76 );
77 }
78
79 sub custom_traffic_calc {
80 my ($self, %options) = @_;
81
82 $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
83 $self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'};
84 $self->{result_values}->{traffic_usage} = Math::BigInt->new($options{new_datas}->{$self->{instance} . '_traffic_usage'});
85
86 my $diff_traffic = Math::BigInt->new('0');
87 $diff_traffic->badd($options{new_datas}->{$self->{instance} . '_traffic_usage'});
88 $diff_traffic->bsub($options{old_datas}->{$self->{instance} . '_traffic_usage'});
89
90 $self->{result_values}->{traffic_per_second} = Math::BigFloat->new('0');
91 $self->{result_values}->{traffic_per_second}->badd($diff_traffic);
92 $self->{result_values}->{traffic_per_second}->bdiv($options{delta_time});
93
94 if (defined($options{new_datas}->{$self->{instance} . '_total'}) && $options{new_datas}->{$self->{instance} . '_total'} =~ /[1-9]/) {
95 $self->{result_values}->{traffic_prct} = $self->{result_values}->{traffic_per_second} * 100 / $options{new_datas}->{$self->{instance} . '_total'};
96 }
97
98 return 0;
99 }
100
101 sub prefix_intcmap_output {
102 my ($self, %options) = @_;
103
104 return "Interface classmap '" . $options{instance_value}->{display} . "' ";
105 }
106
107 sub prefix_cmap_output {
108 my ($self, %options) = @_;
109
110 return "Classmap '" . $options{instance_value}->{display} . "' ";
111 }
112
113 sub set_counters {
114 my ($self, %options) = @_;
115
116 $self->{maps_counters_type} = [
117 { name => 'total', type => 0 },
118 { name => 'interface_classmap', type => 1, cb_prefix_output => 'prefix_intcmap_output', message_multiple => 'All interface classmaps are ok' },
119 { name => 'classmap', type => 1, cb_prefix_output => 'prefix_cmap_output', message_multiple => 'All classmaps are ok' }
120 ];
121
122 $self->{maps_counters}->{interface_classmap} = [
123 { label => 'int-cmap-traffic', nlabel => 'qos.interface.classmap.traffic.bitspersecond', set => {
124 key_values => [ { name => 'traffic_usage', diff => 1 }, { name => 'total' }, { name => 'display' } ],
125 closure_custom_calc => $self->can('custom_traffic_calc'),
126 closure_custom_output => $self->can('custom_traffic_output'),
127 closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
128 closure_custom_threshold_check => $self->can('custom_traffic_threshold')
129 }
130 },
131 { label => 'int-cmap-drop', nlabel => 'qos.interface.classmap.drop.bitspersecond', set => {
132 key_values => [ { name => 'drop_usage', per_second => 1 }, { name => 'display' } ],
133 output_template => 'drop: %s %s/s',
134 output_change_bytes => 2,
135 perfdatas => [
136 { label => 'icmap_drop', template => '%.0f',
137 unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }
138 ]
139 }
140 }
141 ];
142
143 $self->{maps_counters}->{classmap} = [
144 { label => 'cmap-traffic', nlabel => 'qos.classmap.traffic.bitspersecond', set => {
145 key_values => [ { name => 'traffic_usage', diff => 1 }, { name => 'display' } ],
146 closure_custom_calc => $self->can('custom_traffic_calc'),
147 output_template => 'traffic: %s %s/s',
148 output_change_bytes => 2,
149 output_use => 'traffic_per_second',
150 threshold_use => 'traffic_per_second',
151 perfdatas => [
152 { value => 'traffic_per_second', template => '%.0f', unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }
153 ]
154 }
155 },
156 { label => 'cmap-drop', nlabel => 'qos.classmap.drop.bitspersecond', set => {
157 key_values => [ { name => 'drop_usage', per_second => 1 }, { name => 'display' } ],
158 output_change_bytes => 2,
159 output_template => 'drop: %s %s/s',
160 perfdatas => [
161 { template => '%.0f', unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }
162 ]
163 }
164 }
165 ];
166
167 $self->{maps_counters}->{total} = [
168 { label => 'total-traffic', nlabel => 'qos.traffic.bitspersecond', set => {
169 key_values => [ { name => 'traffic_usage', diff => 1 } ],
170 closure_custom_calc => $self->can('custom_traffic_calc'),
171 output_template => 'total traffic: %s %s/s',
172 output_change_bytes => 2,
173 output_use => 'traffic_per_second', threshold_use => 'traffic_per_second',
174 perfdatas => [
175 { value => 'traffic_per_second', template => '%.0f', unit => 'b/s', min => 0 }
176 ]
177 }
178 },
179 { label => 'total-drop', nlabel => 'qos.drop.bitspersecond', set => {
180 key_values => [ { name => 'drop_usage', per_second => 1 } ],
181 output_change_bytes => 2,
182 output_template => 'total drop: %s %s/s',
183 perfdatas => [
184 { template => '%.0f', unit => 'b/s', min => 0 }
185 ]
186 }
187 }
188 ];
189 }
190
191 sub new {
192 my ($class, %options) = @_;
193 my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1);
194 bless $self, $class;
195
196 $options{options}->add_options(arguments => {
197 'filter-source:s' => { name => 'filter_source' },
198 'oid-filter:s' => { name => 'oid_filter', default => 'ifname' },
199 'oid-display:s' => { name => 'oid_display', default => 'ifname' },
200 'units-traffic:s' => { name => 'units_traffic', default => '%' }
201 });
202
203 return $self;
204 }
205
206 sub check_options {
207 my ($self, %options) = @_;
208 $self->SUPER::check_options(%options);
209
210 $self->{oids_label} = {
211 'ifdesc' => '.1.3.6.1.2.1.2.2.1.2',
212 'ifalias' => '.1.3.6.1.2.1.31.1.1.1.18',
213 'ifname' => '.1.3.6.1.2.1.31.1.1.1.1',
214 };
215 $self->check_oids_label();
216 }
217
218 sub check_oids_label {
219 my ($self, %options) = @_;
220
221 foreach (('oid_filter', 'oid_display')) {
222 $self->{option_results}->{$_} = lc($self->{option_results}->{$_}) if (defined($self->{option_results}->{$_}));
223 if (!defined($self->{oids_label}->{$self->{option_results}->{$_}})) {
224 my $label = $_;
225 $label =~ s/_/-/g;
226 $self->{output}->add_option_msg(short_msg => "Unsupported oid in --" . $label . " option.");
227 $self->{output}->option_exit();
228 }
229 }
230 }
231
232 my $mapping = {
233 cbQosCMPostPolicyByteOverflow => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.8' },
234 cbQosCMPostPolicyByte => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.9' },
235 cbQosCMPostPolicyByte64 => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.10' },
236 cbQosCMDropByteOverflow => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.15' },
237 cbQosCMDropByte => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.16' },
238 cbQosCMDropByte64 => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.17' }
239 };
240 my $mapping2 = {
241 cbQosTSCfgRate => { oid => '.1.3.6.1.4.1.9.9.166.1.13.1.1.1' }, # bps
242 cbQosTSCfgRate64 => { oid => '.1.3.6.1.4.1.9.9.166.1.13.1.1.11' } # bps
243 };
244 my $mapping3 = {
245 cbQosQueueingCfgBandwidth => { oid => '.1.3.6.1.4.1.9.9.166.1.9.1.1.1' },
246 cbQosQueueingCfgBandwidthUnits => { oid => '.1.3.6.1.4.1.9.9.166.1.9.1.1.2' }
247 };
248
249 my $oid_cbQosIfIndex = '.1.3.6.1.4.1.9.9.166.1.1.1.1.4';
250 my $oid_cbQosConfigIndex = '.1.3.6.1.4.1.9.9.166.1.5.1.1.2';
251 my $oid_cbQosParentObjectsIndex = '.1.3.6.1.4.1.9.9.166.1.5.1.1.4';
252 # Classmap information
253 my $oid_cbQosCMName = '.1.3.6.1.4.1.9.9.166.1.7.1.1.1';
254 my $oid_cbQosCMStatsEntry = '.1.3.6.1.4.1.9.9.166.1.15.1.1';
255 # Can be linked to a classmap also
256 my $oid_cbQosPolicyMapName = '.1.3.6.1.4.1.9.9.166.1.6.1.1.1';
257 # Shaping : Linked to a classmap
258 my $oid_cbQosTSCfgEntry = '.1.3.6.1.4.1.9.9.166.1.13.1.1';
259 # Linked to a classmap
260 my $oid_cbQosQueueingCfgEntry = '.1.3.6.1.4.1.9.9.166.1.9.1.1';
261
262 sub build_qos_information {
263 my ($self, %options) = @_;
264
265 my $qos_data = { complete_name => $options{class_name} };
266 # Need to try and find the queueing (it's a child)
267 $qos_data->{queueing} = $options{link_queueing}->{$options{policy_index} . '.' . $options{object_index}}
268 if (defined($options{link_queueing}->{$options{policy_index} . '.' . $options{object_index}}));
269 $qos_data->{shaping} = $options{link_shaping}->{$options{policy_index} . '.' . $options{object_index}}
270 if (!defined($qos_data->{shaping}) && defined($options{link_shaping}->{$options{policy_index} . '.' . $options{object_index}}));
271
272 while (($options{object_index} = $self->{results}->{$oid_cbQosParentObjectsIndex}->{$oid_cbQosParentObjectsIndex . '.' . $options{policy_index} . '.' . $options{object_index}}) != 0) {
273 my $config_index = $self->{results}->{$oid_cbQosConfigIndex}->{$oid_cbQosConfigIndex . '.' . $options{policy_index} . '.' . $options{object_index}};
274
275 my $tmp_name = '';
276 # try to find policy_map or class_map
277 if (defined($self->{results}->{$oid_cbQosCMName}->{$oid_cbQosCMName . '.' . $config_index})) {
278 $tmp_name = $self->{results}->{$oid_cbQosCMName}->{$oid_cbQosCMName . '.' . $config_index};
279 } elsif (defined($self->{results}->{$oid_cbQosPolicyMapName}->{$oid_cbQosPolicyMapName . '.' . $config_index})) {
280 $tmp_name = $self->{results}->{$oid_cbQosPolicyMapName}->{$oid_cbQosPolicyMapName . '.' . $config_index};
281 }
282
283 $qos_data->{shaping} = $options{link_shaping}->{$options{policy_index} . '.' . $options{object_index}}
284 if (!defined($qos_data->{shaping}) && defined($options{link_shaping}->{$options{policy_index} . '.' . $options{object_index}}));
285
286 $qos_data->{complete_name} = $tmp_name . ':' . $qos_data->{complete_name};
287 }
288
289 return $qos_data;
290 }
291
292 sub manage_selection {
293 my ($self, %options) = @_;
294
295 $self->{interface_classmap} = {};
296 $self->{classmap} = {};
297 $self->{total} = { drop_usage => Math::BigInt->new('0'), traffic_usage => Math::BigInt->new('0') };
298
299 my $request_oids = [
300 { oid => $self->{oids_label}->{$self->{option_results}->{oid_filter}} },
301 { oid => $oid_cbQosPolicyMapName },
302 { oid => $oid_cbQosIfIndex },
303 { oid => $oid_cbQosConfigIndex },
304 { oid => $oid_cbQosCMName },
305 { oid => $oid_cbQosQueueingCfgEntry, end => $mapping3->{cbQosQueueingCfgBandwidthUnits}->{oid} },
306 { oid => $oid_cbQosCMStatsEntry, start => $mapping->{cbQosCMPostPolicyByteOverflow}->{oid}, end => $mapping->{cbQosCMDropByte64}->{oid} },
307 { oid => $oid_cbQosParentObjectsIndex },
308 { oid => $oid_cbQosTSCfgEntry, end => $mapping2->{cbQosTSCfgRate64}->{oid} }
309 ];
310 push @$request_oids, { oid => $self->{oids_label}->{$self->{option_results}->{oid_display}} }
311 if ($self->{option_results}->{oid_filter} ne $self->{option_results}->{oid_display});
312 $self->{results} = $options{snmp}->get_multiple_table(oids => $request_oids);
313
314 my %classmap_name = ();
315 foreach (keys %{$self->{results}->{$oid_cbQosConfigIndex}}) {
316 if (defined($self->{results}->{$oid_cbQosCMName}->{$oid_cbQosCMName . '.' . $self->{results}->{$oid_cbQosConfigIndex}->{$_}})) {
317 /(\d+\.\d+)$/;
318 $classmap_name{$1} = $self->{results}->{$oid_cbQosCMName}->{$oid_cbQosCMName . '.' . $self->{results}->{$oid_cbQosConfigIndex}->{$_}};
319 }
320 }
321 my ($link_queueing, $link_shaping) = ({}, {});
322 foreach (keys %{$self->{results}->{$oid_cbQosParentObjectsIndex}}) {
323 /(\d+)\.(\d+)$/;
324 my $config_index = $self->{results}->{$oid_cbQosConfigIndex}->{$oid_cbQosConfigIndex . '.' . $1 . '.' . $2};
325 if (defined($self->{results}->{$oid_cbQosQueueingCfgEntry}->{$mapping3->{cbQosQueueingCfgBandwidth}->{oid} . '.' . $config_index})) {
326 $link_queueing->{$1 . '.' . $self->{results}->{$oid_cbQosParentObjectsIndex}->{$_}} = $config_index;
327 } elsif (defined($self->{results}->{$oid_cbQosTSCfgEntry}->{$mapping2->{cbQosTSCfgRate}->{oid} . '.' . $config_index})) {
328 $link_shaping->{$1 . '.' . $self->{results}->{$oid_cbQosParentObjectsIndex}->{$_}} = $config_index;
329 }
330 }
331
332 foreach (keys %{$self->{results}->{$oid_cbQosCMStatsEntry}}) {
333 next if (!/$mapping->{cbQosCMPostPolicyByteOverflow}->{oid}\.(\d+)\.(\d+)/);
334
335 my ($policy_index, $qos_object_index) = ($1, $2);
336
337 my $class_name = $classmap_name{$policy_index . '.' . $qos_object_index};
338 my $if_index = $self->{results}->{$oid_cbQosIfIndex}->{$oid_cbQosIfIndex . '.' . $policy_index};
339 if (!defined($self->{results}->{$self->{oids_label}->{$self->{option_results}->{oid_display}}}->{$self->{oids_label}->{$self->{option_results}->{oid_display}} . '.' . $if_index})) {
340 $self->{output}->output_add(long_msg => "skipping interface index '" . $if_index . "': no display name.", debug => 1);
341 next;
342 }
343 my $interface_display = $self->{results}->{$self->{oids_label}->{$self->{option_results}->{oid_display}}}->{$self->{oids_label}->{$self->{option_results}->{oid_display}} . '.' . $if_index};
344
345 if (!defined($self->{results}->{$self->{oids_label}->{$self->{option_results}->{oid_filter}}}->{$self->{oids_label}->{$self->{option_results}->{oid_filter}} . '.' . $if_index})) {
346 $self->{output}->output_add(long_msg => "skipping interface index '" . $if_index . "': no filter name.", debug => 1);
347 next;
348 }
349
350 my $qos_data = $self->build_qos_information(
351 class_name => $class_name,
352 policy_index => $policy_index,
353 object_index => $qos_object_index,
354 link_queueing => $link_queueing,
355 link_shaping => $link_shaping
356 );
357
358 my $interface_filter = $self->{results}->{$self->{oids_label}->{$self->{option_results}->{oid_filter}}}->{$self->{oids_label}->{$self->{option_results}->{oid_filter}} . '.' . $if_index};
359 my $name = $interface_filter . ':' . $qos_data->{complete_name};
360
361 if (defined($self->{option_results}->{filter_source}) && $self->{option_results}->{filter_source} ne '' &&
362 $name !~ /$self->{option_results}->{filter_source}/) {
363 $self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter source.", debug => 1);
364 next;
365 }
366
367 # Same hash key but only for disco context
368 if (defined($options{disco})) {
369 $self->{interface_classmap}->{$policy_index . '.' . $qos_object_index} = $name;
370 next;
371 }
372
373 my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cbQosCMStatsEntry}, instance => $policy_index . '.' . $qos_object_index);
374 my $traffic_usage = Math::BigInt->new(0);
375 if (defined($result->{cbQosCMPostPolicyByte64}) && $result->{cbQosCMPostPolicyByte64} =~ /[1-9]/) {
376 $traffic_usage = Math::BigInt->new("$result->{cbQosCMPostPolicyByte64}");
377 } elsif ($result->{cbQosCMPostPolicyByteOverflow} != 4294967295) {
378 $traffic_usage = Math::BigInt->new("$result->{cbQosCMPostPolicyByteOverflow}");
379 $traffic_usage->bmuladd(Math::BigInt->new("4294967295"), Math::BigInt->new("$result->{cbQosCMPostPolicyByte}"));
380 }
381 $traffic_usage->bmul(Math::BigInt->new('8'));
382
383 my $drop_usage = Math::BigInt->new('0');
384 if (defined($result->{cbQosCMDropByte64}) && $result->{cbQosCMDropByte64} =~ /[1-9]/) {
385 $drop_usage = Math::BigInt->new("$result->{cbQosCMDropByte64}");
386 } elsif ($result->{cbQosCMDropByteOverflow} != 4294967295) {
387 $drop_usage = Math::BigInt->new("$result->{cbQosCMDropByteOverflow}");
388 $drop_usage->bmuladd("4294967295", "$result->{cbQosCMDropByte}");
389 }
390 $drop_usage->bmul(Math::BigInt->new('8'));
391
392 my $total = 'unknown';
393 if (defined($qos_data->{shaping})) {
394 my $result_shaping = $options{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_cbQosTSCfgEntry}, instance => $qos_data->{shaping});
395 $total = defined($result_shaping->{cbQosTSCfgRate64}) ? $result_shaping->{cbQosTSCfgRate64} : $result_shaping->{cbQosTSCfgRate};
396 }
397
398 $self->{interface_classmap}->{$policy_index . '.' . $qos_object_index} = {
399 display => $name,
400 traffic_usage => $traffic_usage->bstr(),
401 drop_usage => $drop_usage->bstr(),
402 total => $total
403 };
404
405 my @tabname = split /:/, $name;
406 if (defined($tabname[3])) {
407 $class_name = $tabname[3] . '-' . $class_name;
408 }
409
410 $self->{classmap}->{$class_name} = { display => $class_name, drop_usage => Math::BigInt->new('0'), traffic_usage => Math::BigInt->new('0') }
411 if (!defined($self->{classmap}->{$class_name}));
412 $self->{classmap}->{$class_name}->{traffic_usage}->badd($traffic_usage);
413 $self->{classmap}->{$class_name}->{drop_usage}->badd($drop_usage);
414
415 if (!defined($tabname[3])){
416 $self->{total}->{traffic_usage}->badd($traffic_usage);
417 $self->{total}->{drop_usage}->badd($drop_usage);
418 }
419 }
420
421 foreach (keys %{$self->{classmap}}) {
422 $self->{classmap}->{$_}->{traffic_usage} = $self->{classmap}->{$_}->{traffic_usage}->bstr();
423 $self->{classmap}->{$_}->{drop_usage} = $self->{classmap}->{$_}->{drop_usage}->bstr();
424 }
425
426 $self->{total}->{traffic_usage} = $self->{total}->{traffic_usage}->bstr();
427 $self->{total}->{drop_usage} = $self->{total}->{drop_usage}->bstr();
428
429 $self->{cache_name} = 'cisco_qos_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
430 (defined($self->{option_results}->{filter_source}) ? md5_hex($self->{option_results}->{filter_source}) : md5_hex('all')) . '_' .
431 (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
432
433 if (scalar(keys %{$self->{interface_classmap}}) <= 0 && !defined($options{disco})) {
434 $self->{output}->add_option_msg(short_msg => 'Cannot find classmap.');
435 $self->{output}->option_exit();
436 }
437 }
438
439 sub disco_format {
440 my ($self, %options) = @_;
441
442 $self->{output}->add_disco_format(elements => ['name']);
443 }
444
445 sub disco_show {
446 my ($self, %options) = @_;
447
448 $self->manage_selection(disco => 1, %options);
449 foreach (keys %{$self->{interface_classmap}}) {
450 $self->{output}->add_disco_entry(name => $self->{interface_classmap}->{$_});
451 }
452 }
453
454 1;
455
456 __END__
457
458 =head1 MODE
459
460 Check QoS.
461
462 =over 8
463
464 =item B<--filter-source>
465
466 Filter interface name and class-map (can be a regexp).
467 Example of a source (interfacename:servicepolicy:classmap:...): FastEthernet1:Visioconference
468
469 =item B<--filter-counters>
470
471 Only display some counters (regexp can be used).
472 Example: --filter-counters='^(total-traffic)$'
473
474 =item B<--warning-*>
475
476 Warning threshold.
477 Can be: 'int-cmap-traffic', 'int-cmap-drop',
478 'cmap-traffic', 'cmap-drop', 'total-traffic', 'total-drop'.
479
480 =item B<--critical-*>
481
482 Critical threshold.
483 Can be: 'int-cmap-traffic', 'int-cmap-drop',
484 'cmap-traffic', 'cmap-drop', 'total-traffic', 'total-drop'.
485
486 =item B<--units-traffic>
487
488 Units of thresholds for the traffic (default: '%') ('%', 'b/s').
489 Only for --warning-int-traffic and --critical-int-traffic options.
490
491 =item B<--oid-filter>
492
493 Define the OID to be used to filter interfaces (default: ifName) (values: ifDesc, ifAlias, ifName).
494
495 =item B<--oid-display>
496
497 Define the OID that will be used to name the interfaces (default: ifName) (values: ifDesc, ifAlias, ifName).
498
499 =back
500
501 =cut