Debian Codegraph @

src/centreon/common/aruba/snmp/mode/apssidstatistics.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::apssidstatistics;
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 => 'ap', type => 3, cb_prefix_output => 'prefix_output_ap', cb_long_output => 'long_output',
33 message_multiple => 'All AP BSSID are ok', indent_long_output => ' ',
34 group => [
35 { name => 'global', type => 0 },
36 { name => 'essid', display_long => 1, cb_prefix_output => 'prefix_output_essid',
37 message_multiple => 'All ESSID are ok', type => 1 },
38 { name => 'bssid', display_long => 1, cb_prefix_output => 'prefix_output_bssid',
39 message_multiple => 'All BSSID are ok', type => 1 },
40 ]
41 }
42 ];
43
44 $self->{maps_counters}->{global} = [
45 { label => 'stations-associated', nlabel => 'stations.associated.count', set => {
46 key_values => [ { name => 'total' } ],
47 output_template => 'Stations Associated: %d',
48 perfdatas => [
49 { value => 'total', template => '%d', min => 0 },
50 ],
51 }
52 },
53 ];
54
55 $self->{maps_counters}->{essid} = [
56 { label => 'essid-stations-associated', nlabel => 'essid.stations.associated.count', set => {
57 key_values => [ { name => 'wlanAPEssidNumAssociatedStations' }, { name => 'wlanAPESSID' } ],
58 output_template => 'Associated Stations: %d',
59 perfdatas => [
60 { value => 'wlanAPEssidNumAssociatedStations', template => '%d',
61 label_extra_instance => 1 },
62 ],
63 }
64 },
65 ];
66
67 $self->{maps_counters}->{bssid} = [
68 { label => 'bssid-stations-associated', nlabel => 'bssid.stations.associated.count', set => {
69 key_values => [ { name => 'wlanAPBssidNumAssociatedStations' }, { name => 'wlanAPBSSID' },
70 { name => 'wlanAPESSID' } ],
71 output_template => 'Associated Stations: %d',
72 perfdatas => [
73 { value => 'wlanAPBssidNumAssociatedStations', template => '%d',
74 label_extra_instance => 1 },
75 ],
76 }
77 },
78 { label => 'channel-noise', nlabel => 'bssid.channel.noise.count', set => {
79 key_values => [ { name => 'apChannelNoise' }, { name => 'wlanAPBSSID' },
80 { name => 'wlanAPESSID' } ],
81 output_template => 'Channel Noise: %d',
82 perfdatas => [
83 { value => 'apChannelNoise', template => '%d',
84 label_extra_instance => 1 },
85 ],
86 }
87 },
88 { label => 'signal-noise-ratio', nlabel => 'bssid.signal.noise.ratio.count', set => {
89 key_values => [ { name => 'apSignalToNoiseRatio' }, { name => 'wlanAPBSSID' },
90 { name => 'wlanAPESSID' } ],
91 output_template => 'Signal To Noise Ratio: %d',
92 perfdatas => [
93 { value => 'apSignalToNoiseRatio', template => '%d',
94 label_extra_instance => 1 },
95 ],
96 }
97 },
98 ];
99 }
100
101 sub prefix_output_ap {
102 my ($self, %options) = @_;
103
104 return "AP '" . $options{instance_value}->{wlanAPName} . "' [Mac: " . $options{instance_value}->{wlanAPMacAddress} . "] ";
105 }
106
107 sub prefix_output_essid {
108 my ($self, %options) = @_;
109
110 return "ESSID '" . $options{instance_value}->{wlanAPESSID} . "' ";
111 }
112
113 sub prefix_output_bssid {
114 my ($self, %options) = @_;
115
116 return "BSSID '" . $options{instance_value}->{wlanAPBSSID} . "' [ESSID: " .
117 $options{instance_value}->{wlanAPESSID} . "][Protocol: " . $options{instance_value}->{wlanAPBssidPhyType} . "] ";
118 }
119
120 sub long_output {
121 my ($self, %options) = @_;
122
123 return "Checking AP '" . $options{instance_value}->{wlanAPName} . "' [Mac: " . $options{instance_value}->{wlanAPMacAddress} . "] ";
124 }
125
126 sub new {
127 my ($class, %options) = @_;
128 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
129 bless $self, $class;
130
131 $options{options}->add_options(arguments => {
132 "filter-ap:s" => { name => 'filter_ap' },
133 "filter-essid:s" => { name => 'filter_essid' },
134 "filter-protocol:s" => { name => 'filter_protocol' },
135 "filter-bssid:s" => { name => 'filter_bssid' },
136 });
137
138 return $self;
139 }
140
141 my %map_type = (
142 1 => '802.11a', 2 => '802.11b', 3 => '802.11g',
143 4 => '802.11ag', 5 => 'wired'
144 );
145
146 my $oid_wlsxSwitchAccessPointTable = '.1.3.6.1.4.1.14823.2.2.1.1.3.3.1';
147
148 my $mapping_switch = {
149 apChannelNoise => { oid => '.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.13' },
150 apSignalToNoiseRatio => { oid => '.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.14' },
151 };
152
153 my $oid_wlsxWlanAPBssidTable = '.1.3.6.1.4.1.14823.2.2.1.5.2.1.7.1';
154
155 my $mapping_wlan = {
156 wlanAPESSID => { oid => '.1.3.6.1.4.1.14823.2.2.1.5.2.1.7.1.2' },
157 wlanAPBssidPhyType => { oid => '.1.3.6.1.4.1.14823.2.2.1.5.2.1.7.1.5', map => \%map_type },
158 wlanAPBssidUpTime => { oid => '.1.3.6.1.4.1.14823.2.2.1.5.2.1.7.1.9' },
159 wlanAPBssidInactiveTime => { oid => '.1.3.6.1.4.1.14823.2.2.1.5.2.1.7.1.10' },
160 wlanAPBssidNumAssociatedStations => { oid => '.1.3.6.1.4.1.14823.2.2.1.5.2.1.7.1.12' },
161 };
162
163 my $oid_wlanAPName = '.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.3';
164
165 sub manage_selection {
166 my ($self, %options) = @_;
167
168 my $snmp_result = $options{snmp}->get_multiple_table(
169 oids => [
170 { oid => $oid_wlsxSwitchAccessPointTable,
171 start => $mapping_switch->{apChannelNoise}->{oid},
172 end => $mapping_switch->{apSignalToNoiseRatio}->{oid} },
173 { oid => $oid_wlsxWlanAPBssidTable,
174 start => $mapping_wlan->{wlanAPESSID}->{oid},
175 end => $mapping_wlan->{wlanAPBssidNumAssociatedStations}->{oid} },
176 { oid => $oid_wlanAPName },
177 ],
178 nothing_quit => 1
179 );
180
181 $self->{ap} = {};
182
183 foreach my $oid (keys %{$snmp_result->{$oid_wlsxWlanAPBssidTable}}) {
184 next if ($oid !~ /^$mapping_wlan->{wlanAPESSID}->{oid}\.(.*)/);
185 my $instance = $1;
186
187 my $result = $options{snmp}->map_instance(
188 mapping => $mapping_wlan,
189 results => $snmp_result->{$oid_wlsxWlanAPBssidTable},
190 instance => $instance
191 );
192
193 my @digits = split /\./, $instance;
194 $result->{wlanAPMacAddress} = join(':', unpack("(A2)*", unpack('H*', pack('C*', @digits[0..5]))));
195 $result->{wlanAPBSSID} = join(':', unpack("(A2)*", unpack('H*', pack('C*', @digits[7..12]))));
196 $result->{wlanAPName} = $snmp_result->{$oid_wlanAPName}->{$oid_wlanAPName . '.' . join('.', @digits[0..5])};
197 $result->{apChannelNoise} = $snmp_result->{$oid_wlsxSwitchAccessPointTable}->{$mapping_switch->{apChannelNoise}->{oid} . '.' . join('.', @digits[7..12])};
198 $result->{apSignalToNoiseRatio} = $snmp_result->{$oid_wlsxSwitchAccessPointTable}->{$mapping_switch->{apSignalToNoiseRatio}->{oid} . '.' . join('.', @digits[7..12])};
199
200 if (defined($self->{option_results}->{filter_ap}) && $self->{option_results}->{filter_ap} ne '' &&
201 $result->{wlanAPName} !~ /$self->{option_results}->{filter_ap}/) {
202 $self->{output}->output_add(long_msg => "skipping '" . $result->{wlanAPName} . "': no matching filter name.", debug => 1);
203 next;
204 }
205 if (defined($self->{option_results}->{filter_essid}) && $self->{option_results}->{filter_essid} ne '' &&
206 $result->{wlanAPESSID} !~ /$self->{option_results}->{filter_essid}/) {
207 $self->{output}->output_add(long_msg => "skipping '" . $result->{wlanAPESSID} . "': no matching filter essid.", debug => 1);
208 next;
209 }
210 if (defined($self->{option_results}->{filter_bssid}) && $self->{option_results}->{filter_bssid} ne '' &&
211 $result->{wlanAPBSSID} !~ /$self->{option_results}->{filter_bssid}/) {
212 $self->{output}->output_add(long_msg => "skipping '" . $result->{wlanAPESSID} . "': no matching filter bssid.", debug => 1);
213 next;
214 }
215 if (defined($self->{option_results}->{filter_protocol}) && $self->{option_results}->{filter_protocol} ne '' &&
216 $result->{wlanAPBssidPhyType} !~ /$self->{option_results}->{filter_protocol}/) {
217 $self->{output}->output_add(long_msg => "skipping '" . $result->{wlanAPBssidPhyType} . "': no matching filter protocol.", debug => 1);
218 next;
219 }
220
221 $self->{ap}->{$result->{wlanAPName}}->{global}->{total} += $result->{wlanAPBssidNumAssociatedStations};
222 $self->{ap}->{$result->{wlanAPName}}->{wlanAPName} = $result->{wlanAPName};
223 $self->{ap}->{$result->{wlanAPName}}->{wlanAPMacAddress} = $result->{wlanAPMacAddress};
224 $self->{ap}->{$result->{wlanAPName}}->{essid}->{$result->{wlanAPESSID}}->{wlanAPEssidNumAssociatedStations} += $result->{wlanAPBssidNumAssociatedStations};
225 $self->{ap}->{$result->{wlanAPName}}->{essid}->{$result->{wlanAPESSID}}->{wlanAPESSID} = $result->{wlanAPESSID};
226 $self->{ap}->{$result->{wlanAPName}}->{bssid}->{$result->{wlanAPBSSID}} = { %{$result} };
227 }
228
229 if (scalar(keys %{$self->{ap}}) <= 0) {
230 $self->{output}->add_option_msg(short_msg => "No AP found.");
231 $self->{output}->option_exit();
232 }
233 }
234
235 1;
236
237 __END__
238
239 =head1 MODE
240
241 Check AP ESSID and BSSID statistics (WLSX-WLAN-MIB, WLSX-SWITCH-MIB).
242
243 =over 8
244
245 =item B<--warning-*>
246
247 Warning threshold.
248 Can be: 'stations-associated' (ESSID and BSSID),
249 'channel-noise', 'signal-noise-ratio' (BSSID).
250
251 =item B<--critical-*>
252
253 Critical threshold.
254 Can be: 'stations-associated' (ESSID and BSSID),
255 'channel-noise', 'signal-noise-ratio' (BSSID).
256
257 =item B<--filter-*>
258
259 Filter by 'ap', 'essid', 'protocol', 'bssid' (regexp can be used).
260
261 =back
262
263 =cut