Debian Codegraph @

src/centreon/common/aruba/snmp/mode/apconnections.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::aruba::snmp::mode::apconnections;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27
28 sub set_counters {
29 my ($self, %options) = @_;
30
31 $self->{maps_counters_type} = [
32 { name => 'global', type => 0, skipped_code => { -10 => 1 } },
33 { name => 'ap', type => 1, cb_prefix_output => 'prefix_ap_output', message_multiple => 'All access points are ok' },
34 ];
35
36 $self->{maps_counters}->{global} = [
37 { label => 'total', nlabel => 'accesspoints.connected.current.count', set => {
38 key_values => [ { name => 'total' } ],
39 output_template => 'Total access points connected : %d',
40 perfdatas => [
41 { label => 'total', value => 'total', template => '%d', min => 0 },
42 ],
43 }
44 },
45 ];
46
47 $self->{maps_counters}->{ap} = [
48 { label => 'total-time', nlabel => 'accesspoint.time.connection.current.seconds', set => {
49 key_values => [ { name => 'apTotalTime' }, { name => 'bssid' }, ],
50 output_template => 'Current total connection time : %.3f s',
51 perfdatas => [
52 { label => 'total_time', value => 'apTotalTime', template => '%.3f',
53 min => 0, unit => 's', label_extra_instance => 1, instance_use => 'bssid' },
54 ],
55 }
56 },
57 { label => 'inactive-time', nlabel => 'accesspoint.time.inactive.current.seconds', set => {
58 key_values => [ { name => 'apInactiveTime' }, { name => 'bssid' }, ],
59 output_template => 'Current inactive time : %.3f s',
60 perfdatas => [
61 { label => 'inactive_time', value => 'apInactiveTime', template => '%.3f',
62 min => 0, unit => 's', label_extra_instance => 1, instance_use => 'bssid' },
63 ],
64 }
65 },
66 { label => 'channel-noise', nlabel => 'accesspoint.channel.noise.count', sset => {
67 key_values => [ { name => 'apChannelNoise' }, { name => 'bssid' }, ],
68 output_template => 'Channel noise : %d',
69 perfdatas => [
70 { label => 'channel_noise', value => 'apChannelNoise', template => '%d',
71 label_extra_instance => 1, instance_use => 'bssid' },
72 ],
73 }
74 },
75 { label => 'snr', nlabel => 'accesspoint.signal.noise.ratio.dbm', set => {
76 key_values => [ { name => 'apSignalToNoiseRatio' }, { name => 'bssid' }, ],
77 output_template => 'Signal to noise ratio : %d',
78 perfdatas => [
79 { label => 'snr', value => 'apSignalToNoiseRatio', template => '%d',
80 label_extra_instance => 1, instance_use => 'bssid' },
81 ],
82 }
83 },
84 ];
85 }
86
87 sub new {
88 my ($class, %options) = @_;
89 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
90 bless $self, $class;
91
92 $options{options}->add_options(arguments => {
93 "filter-ip-address:s" => { name => 'filter_ip_address' },
94 "filter-bssid:s" => { name => 'filter_bssid' },
95 "filter-essid:s" => { name => 'filter_essid' },
96 "filter-type:s" => { name => 'filter_type', default => 'ap' },
97 "skip-total" => { name => 'skip_total' },
98 });
99
100 return $self;
101 }
102
103 sub prefix_ap_output {
104 my ($self, %options) = @_;
105
106 return "AP [bssid: '$options{instance_value}->{bssid}', essid: $options{instance_value}->{apESSID}, ip: $options{instance_value}->{apIpAddress}] Usage ";
107 }
108
109 my %map_role = (
110 1 => 'master',
111 2 => 'local',
112 3 => 'standbymaster',
113 );
114 my %map_type = (
115 1 => 'ap',
116 2 => 'am',
117 );
118
119 my $mapping = {
120 apESSID => { oid => '.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.2' },
121 };
122 my $mapping2 = {
123 apIpAddress => { oid => '.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.5' },
124 };
125 my $mapping3 = {
126 apType => { oid => '.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.7', map => \%map_type },
127 };
128 my $mapping4 = {
129 apTotalTime => { oid => '.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.10' },
130 apInactiveTime => { oid => '.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.11' },
131 };
132 my $mapping5 = {
133 apChannelNoise => { oid => '.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.13' },
134 apSignalToNoiseRatio => { oid => '.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.14' },
135 };
136
137 my $oid_wlsxSwitchRole = '.1.3.6.1.4.1.14823.2.2.1.1.1.4';
138 my $oid_wlsxSwitchAccessPointTable = '.1.3.6.1.4.1.14823.2.2.1.1.3.3';
139 my $oid_wlsxSwitchAccessPointEntry = '.1.3.6.1.4.1.14823.2.2.1.1.3.3.1';
140 my $oid_wlsxSwitchTotalNumAccessPoints = '.1.3.6.1.4.1.14823.2.2.1.1.3.1';
141
142 sub manage_selection {
143 my ($self, %options) = @_;
144
145 my $snmp_result = $options{snmp}->get_multiple_table(
146 oids => [
147 { oid => $oid_wlsxSwitchTotalNumAccessPoints },
148 { oid => $oid_wlsxSwitchRole },
149 { oid => $mapping->{apESSID}->{oid} },
150 { oid => $mapping2->{apIpAddress}->{oid} },
151 { oid => $mapping3->{apType}->{oid} },
152 { oid => $oid_wlsxSwitchAccessPointEntry, start => $mapping4->{apTotalTime}->{oid}, end => $mapping4->{apInactiveTime}->{oid} },
153 { oid => $oid_wlsxSwitchAccessPointTable, start => $mapping5->{apChannelNoise}->{oid}, end => $mapping5->{apSignalToNoiseRatio}->{oid} },
154 ],
155 nothing_quit => 1
156 );
157 my $role = $map_role{$snmp_result->{$oid_wlsxSwitchRole}->{$oid_wlsxSwitchRole . '.0'}};
158 if ($role =~ /standbymaster/) {
159 $self->{output}->output_add(severity => 'OK',
160 short_msg => "Cannot get information. Switch role is '" . $role . "'.");
161 $self->{output}->display();
162 $self->{output}->exit();
163 }
164
165 $self->{ap} = {};
166 foreach my $oid (keys %{$snmp_result->{$mapping->{apESSID}->{oid}}}) {
167 next if ($oid !~ /^$mapping->{apESSID}->{oid}\.(.*)$/);
168 my $bssid = $1;
169 my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$mapping->{apESSID}->{oid}}, instance => $bssid);
170 my $result2 = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result->{$mapping2->{apIpAddress}->{oid}}, instance => $bssid);
171 my $result3 = $options{snmp}->map_instance(mapping => $mapping3, results => $snmp_result->{$mapping3->{apType}->{oid}}, instance => $bssid);
172 my $result4 = $options{snmp}->map_instance(mapping => $mapping4, results => $snmp_result->{$oid_wlsxSwitchAccessPointEntry}, instance => $bssid);
173 my $result5 = $options{snmp}->map_instance(mapping => $mapping5, results => $snmp_result->{$oid_wlsxSwitchAccessPointTable}, instance => $bssid);
174
175 if (defined($self->{option_results}->{filter_bssid}) && $self->{option_results}->{filter_bssid} ne '' &&
176 $bssid !~ /$self->{option_results}->{filter_bssid}/) {
177 $self->{output}->output_add(long_msg => "skipping '" . $bssid . "': no matching filter bssid.");
178 next;
179 }
180 if (defined($self->{option_results}->{filter_ip_address}) && $self->{option_results}->{filter_ip_address} ne '' &&
181 $result2->{apIpAddress} !~ /$self->{option_results}->{filter_ip_address}/) {
182 $self->{output}->output_add(long_msg => "skipping '" . $result2->{apIpAddress} . "': no matching filter ip-address.");
183 next;
184 }
185 if (defined($self->{option_results}->{filter_essid}) && $self->{option_results}->{filter_essid} ne '' &&
186 $result->{apESSID} !~ /$self->{option_results}->{filter_essid}/) {
187 $self->{output}->output_add(long_msg => "skipping '" . $result->{apESSID} . "': no matching filter essid.");
188 next;
189 }
190 if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' &&
191 $result3->{apType} !~ /$self->{option_results}->{filter_type}/) {
192 $self->{output}->output_add(long_msg => "skipping '" . $result->{apType} . "': no matching filter type.");
193 next;
194 }
195
196 $self->{ap}->{$bssid} = { bssid => $bssid, %$result2, %$result, %$result4, %$result5};
197 $self->{ap}->{$bssid}->{apInactiveTime} *= 0.01 if (defined($self->{ap}->{$bssid}->{apInactiveTime}));
198 $self->{ap}->{$bssid}->{apTotalTime} *= 0.01 if (defined($self->{ap}->{$bssid}->{apTotalTime}));
199 }
200
201 if (!defined($self->{option_results}->{skip_total}) && defined($snmp_result->{$oid_wlsxSwitchTotalNumAccessPoints}->{$oid_wlsxSwitchTotalNumAccessPoints . '.0'})) {
202 $self->{global} = { total => $snmp_result->{$oid_wlsxSwitchTotalNumAccessPoints}->{$oid_wlsxSwitchTotalNumAccessPoints . '.0'} };
203 }
204 }
205
206 1;
207
208 __END__
209
210 =head1 MODE
211
212 Check AP connections (deprecated).
213
214 =over 8
215
216 =item B<--warning-*>
217
218 Warning threshold.
219 Can be: 'total', 'total-time', 'inactive-time', 'channel-noise', 'snr'.
220
221 =item B<--critical-*>
222
223 Critical threshold.
224 Can be: 'total', 'total-time', 'inactive-time', 'channel-noise', 'snr'.
225
226 =item B<--filter-bssid>
227
228 Filter by physical address (regexp can be used).
229
230 =item B<--filter-ip-address>
231
232 Filter by ip address (regexp can be used).
233
234 =item B<--filter-essid>
235
236 Filter by ESSID (regexp can be used).
237
238 =item B<--filter-type>
239
240 Filter by type (regexp can be used. Can be: 'ap' or 'am'. Default: 'ap').
241
242 =item B<--skip-total>
243
244 Don't display total AP connected (useful when you check each AP).
245
246 =back
247
248 =cut