Debian Codegraph @

src/network/huawei/wlc/snmp/mode/apradio.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 network::huawei::wlc::snmp::mode::apradio;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27 use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
28
29 sub prefix_global_output {
30 my ($self, %options) = @_;
31
32 return 'Access points ';
33 }
34
35 sub ap_long_output {
36 my ($self, %options) = @_;
37
38 return "checking access point '" . $options{instance_value}->{display} . "'";
39 }
40
41 sub prefix_ap_output {
42 my ($self, %options) = @_;
43
44 return "access point '" . $options{instance_value}->{display} . "' ";
45 }
46
47 sub custom_status_output {
48 my ($self, %options) = @_;
49
50 my $msg = 'run state: ' . $self->{result_values}->{runstate};
51 return $msg;
52 }
53
54 sub set_counters {
55 my ($self, %options) = @_;
56
57 $self->{maps_counters_type} = [
58 { name => 'ap',
59 type => 3,
60 cb_prefix_output => 'prefix_ap_output',
61 cb_long_output => 'ap_long_output',
62 indent_long_output => ' ',
63 message_multiple => 'All access points are ok',
64 group => [
65 { name => 'ap_radio', type => 0 }
66 ]
67 }
68 ];
69
70 $self->{maps_counters}->{ap_radio} = [
71 {
72 label => 'status',
73 type => 2,
74 critical_default => '%{runstate} ne "up"',
75 set =>
76 {
77 key_values =>
78 [ { name => 'runstate' }, { name => 'display' } ],
79 closure_custom_output =>
80 $self->can('custom_status_output'),
81 closure_custom_perfdata =>
82 sub {return 0;},
83 closure_custom_threshold_check =>
84 \&catalog_status_threshold_ng
85 }
86 },
87 { label => 'package-error-rate', nlabel => 'ap.radio.packageerror.percentage', set => {
88 key_values => [ { name => 'package_error_rate' }, { name => 'display' } ],
89 output_template => 'radio package error rate: %.2f%%',
90 perfdatas => [
91 { template => '%.2f', unit => '%', label_extra_instance => 1, instance_use => 'display' }
92 ]
93 }
94 },
95 { label => 'noise', nlabel => 'ap.radio.noise.dbm', set => {
96 key_values => [ { name => 'noise' }, { name => 'display' } ],
97 output_template => 'radio noise: %d dBm',
98 perfdatas => [
99 { template => '%d', unit => 'dBm', label_extra_instance => 1, instance_use => 'display' }
100 ]
101 }
102 },
103 { label => 'channel-utilization-rate', nlabel => 'ap.radio.channel.utilization.percentage', set => {
104 key_values => [ { name => 'channel_utilization_rate' }, { name => 'display' } ],
105 output_template => 'radio channel utilization rate: %.2f%%',
106 perfdatas => [
107 { template => '%.2f', unit => '%', label_extra_instance => 1, instance_use => 'display' }
108 ]
109 }
110 },
111 { label => 'channel-interference-rate', nlabel => 'ap.radio.channel.interference.percentage', set => {
112 key_values => [ { name => 'channel_interference_rate' }, { name => 'display' } ],
113 output_template => 'radio channel interference rate: %.2f%%',
114 perfdatas => [
115 { template => '%.2f', unit => '%', label_extra_instance => 1, instance_use => 'display' }
116 ]
117 }
118 },
119 { label => 'receive-rate', nlabel => 'ap.radio.receive.bitspersecond', set => {
120 key_values => [ { name => 'receive_rate' }, { name => 'display' } ],
121 output_template => 'radio channel receive rate: %d b/s',
122 perfdatas => [
123 { template => '%d', unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }
124 ]
125 }
126 },
127 { label => 'send-rate', nlabel => 'ap.radio.send.bitspersecond', set => {
128 key_values => [ { name => 'send_rate' }, { name => 'display' } ],
129 output_template => 'radio channel send rate: %d b/s',
130 perfdatas => [
131 { template => '%d', unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }
132 ]
133 }
134 }
135 ];
136 }
137
138 sub new {
139 my ($class, %options) = @_;
140 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
141 bless $self, $class;
142
143 $options{options}->add_options(arguments => {
144 "filter-name:s" => { name => 'filter_name' },
145 "filter-address:s" => { name => 'filter_address' },
146 "filter-group:s" => { name => 'filter_group' }
147 });
148
149 return $self;
150 }
151
152 my $map_runstate = {
153 1 => 'up',
154 2 => 'down',
155 255 => 'invalid'
156 };
157
158 my $mapping = {
159 name => { oid => '.1.3.6.1.4.1.2011.6.139.16.1.2.1.3' },# hwWlanApName
160 };
161
162 my $mapping_stat = {
163 ap_group => { oid => '.1.3.6.1.4.1.2011.6.139.16.1.2.1.55' },# hwWlanRadioApGroup
164 runstate => {
165 oid => '.1.3.6.1.4.1.2011.6.139.16.1.2.1.6', map => $map_runstate
166 },# hwWlanRadioRunState
167 package_error_rate => { oid => '.1.3.6.1.4.1.2011.6.139.16.1.2.1.23' },# hwWlanRadioPER
168 noise => { oid => '.1.3.6.1.4.1.2011.6.139.16.1.2.1.24' },# hwWlanRadioNoise
169 channel_utilization_rate => { oid => '.1.3.6.1.4.1.2011.6.139.16.1.2.1.25' },# hwWlanRadioChUtilizationRate
170 channel_interference_rate => { oid => '.1.3.6.1.4.1.2011.6.139.16.1.2.1.29' },# hwWlanRadioChInterferenceRate
171 receive_rate => { oid => '.1.3.6.1.4.1.2011.6.139.16.1.2.1.32' },# hwWlanRadioRecvRate
172 send_rate => { oid => '.1.3.6.1.4.1.2011.6.139.16.1.2.1.37' },# hwWlanRadioSendRate
173 };
174
175 sub manage_selection {
176 my ($self, %options) = @_;
177
178 $self->{ap} = {};
179
180 my $request = [ { oid => $mapping->{name}->{oid} } ];
181 push @$request, { oid => $mapping->{ap_group}->{oid} }
182 if (defined($self->{option_results}->{filter_group}) && $self->{option_results}->{filter_group} ne '');
183
184 my $snmp_result = $options{snmp}->get_multiple_table(
185 oids => $request,
186 return_type => 1,
187 nothing_quit => 1
188 );
189
190 foreach (sort keys %$snmp_result) {
191 next if (!/^$mapping->{name}->{oid}\.(.*)/);
192 my $instance = $1;
193
194 my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
195 if (!defined($result->{name}) || $result->{name} eq '') {
196 $self->{output}->output_add(long_msg =>
197 "skipping WLC '$instance': cannot get a name. please set it.",
198 debug =>
199 1);
200 next;
201 }
202
203 if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
204 $result->{name} !~ /$self->{option_results}->{filter_name}/) {
205 $self->{output}->output_add(long_msg =>
206 "skipping '" . $result->{name} . "': no matching name filter.",
207 debug =>
208 1);
209 next;
210 }
211
212 if (defined($self->{option_results}->{filter_group}) && $self->{option_results}->{filter_group} ne '' &&
213 $result->{group} !~ /$self->{option_results}->{filter_group}/) {
214 $self->{output}->output_add(long_msg =>
215 "skipping '" . $result->{group} . "': no matching group filter.",
216 debug =>
217 1);
218 next;
219 }
220
221 $self->{ap}->{ $result->{name} } = {
222 instance => $instance,
223 display => $result->{name},
224 ap_radio => {
225 display => $result->{name}
226 }
227 };
228 }
229
230 if (scalar(keys %{$self->{ap}}) <= 0) {
231 $self->{output}->output_add(long_msg => 'no AP associated');
232 return;
233 }
234
235 $options{snmp}->load(
236 oids => [ map($_->{oid}, values(%$mapping_stat)) ],
237 instances => [ map($_->{instance}, values %{$self->{ap}}) ],
238 instance_regexp => '^(.*)$'
239 );
240 $snmp_result = $options{snmp}->get_leef();
241
242 foreach (sort keys %{$self->{ap}}) {
243 my $result = $options{snmp}->map_instance(
244 mapping => $mapping_stat,
245 results => $snmp_result,
246 instance => $self->{ap}->{$_}->{instance}
247 );
248
249 $self->{ap}->{$_}->{ap_radio}->{runstate} = $result->{runstate};
250 $self->{ap}->{$_}->{ap_radio}->{package_error_rate} = $result->{package_error_rate};
251 $self->{ap}->{$_}->{ap_radio}->{noise} = $result->{noise};
252 $self->{ap}->{$_}->{ap_radio}->{channel_utilization_rate} = $result->{channel_utilization_rate};
253 $self->{ap}->{$_}->{ap_radio}->{channel_interference_rate} = $result->{channel_interference_rate};
254 $self->{ap}->{$_}->{ap_radio}->{receive_rate} = $result->{receive_rate} * 1000;
255 $self->{ap}->{$_}->{ap_radio}->{send_rate} = $result->{send_rate} * 1000;
256 }
257 }
258
259 1;
260
261 __END__
262
263 =head1 MODE
264
265 Check AP radio status.
266
267 =over 8
268
269 =item B<--filter-counters>
270
271 Only display some counters (regexp can be used).
272 Example: --filter-counters='^temperature|onlinetime$'
273
274 =item B<--filter-name>
275
276 Filter access point radio name (can be a regexp)
277
278 =item B<--filter-address>
279
280 Filter access point radio IP address (can be a regexp).
281
282 =item B<--filter-group>
283
284 Filter access point group (can be a regexp).
285
286 =item B<--warning-status>
287
288 Define the conditions to match for the status to be WARNING.
289 You can use the following variables: %{runstate}, %{display}
290
291 =item B<--critical-status>
292
293 Define the conditions to match for the status to be CRITICAL (default: '%{runstate} ne "up"').
294 You can use the following variables: %{runstate}, %{display}
295
296 =item B<--warning-package-error-rate>
297
298 Thresholds.
299
300 =item B<--critical-package-error-rate>
301
302 Thresholds.
303
304 =item B<--warning-noise>
305
306 Thresholds.
307
308 =item B<--critical-noise>
309
310 Thresholds.
311
312 =item B<--warning-channel-utilization-rate>
313
314 Thresholds.
315
316 =item B<--critical-channel-utilization-rate>
317
318 Thresholds.
319
320 =item B<--warning-channel-interference-rate>
321
322 Thresholds.
323
324 =item B<--critical-channel-interference-rate>
325
326 Thresholds.
327
328 =item B<--warning-receive-rate>
329
330 Thresholds.
331
332 =item B<--critical-receive-rate>
333
334 Thresholds.
335
336 =item B<--warning-send-rate>
337
338 Thresholds.
339
340 =item B<--critical-send-rate>
341
342 Thresholds.
343
344 =back
345
346 =cut