Debian Codegraph @

src/network/huawei/wlc/snmp/mode/wlanglobal.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::wlanglobal;
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 custom_normal_output {
30 my ($self, %options) = @_;
31
32 return sprintf(
33 'Access Points normal state %s on %s (%.2f%%)',
34 $self->{result_values}->{normal},
35 $self->{result_values}->{total},
36 $self->{result_values}->{normal_prct},
37 );
38 }
39
40 sub custom_success_auth_user_output {
41 my ($self, %options) = @_;
42
43 return sprintf(
44 'Access Points user authentications %s on %s (%.2f%%)',
45 $self->{result_values}->{current_auth_user},
46 $self->{result_values}->{current_user},
47 $self->{result_values}->{current_auth_user_prct},
48 );
49 }
50
51 sub custom_current_auth_user_prct_output {
52 my ($self, %options) = @_;
53
54 return sprintf(
55 'Access Points user authentications %.2f%% (%s on %s)',
56 $self->{result_values}->{current_auth_user_prct},
57 $self->{result_values}->{current_auth_user},
58 $self->{result_values}->{current_user},
59 );
60 }
61
62 sub custom_normal_prct_output {
63 my ($self, %options) = @_;
64
65 return sprintf(
66 'Access Points normal state %.2f%% (%s on %s)',
67 $self->{result_values}->{normal_prct},
68 $self->{result_values}->{normal},
69 $self->{result_values}->{total},
70 );
71 }
72
73 sub custom_fault_prct_output {
74 my ($self, %options) = @_;
75
76 return sprintf(
77 'Access Points fault state %.2f%% (%s on %s)',
78 $self->{result_values}->{fault_prct},
79 $self->{result_values}->{fault},
80 $self->{result_values}->{total},
81 );
82 }
83
84 sub custom_fault_output {
85 my ($self, %options) = @_;
86
87 return sprintf(
88 'Access Points fault state %s on %s (%.2f%%)',
89 $self->{result_values}->{fault},
90 $self->{result_values}->{total},
91 $self->{result_values}->{fault_prct}
92 );
93 }
94
95 sub set_counters {
96 my ($self, %options) = @_;
97
98 $self->{maps_counters_type} = [
99 { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
100 ];
101
102 $self->{maps_counters}->{global} = [
103 { label => 'total', nlabel => 'accesspoints.total.count', display_ok => 0, set => {
104 key_values => [ { name => 'total' } ],
105 output_template => 'total: %s',
106 perfdatas => [
107 { template => '%s', min => 0 }
108 ]
109 }
110 },
111 { label => 'normal', nlabel => 'accesspoints.normal.count', display_ok => 1, set => {
112 key_values => [ { name => 'normal' }, { name => 'total' }, { name => 'normal_prct' } ],
113 closure_custom_output => $self->can('custom_normal_output'),
114 perfdatas => [
115 { template => '%s', min => 0 }
116 ]
117 }
118 },
119 { label => 'fault', nlabel => 'accesspoints.fault.count', display_ok => 0, set => {
120 key_values => [ { name => 'fault' }, { name => 'total' }, { name => 'fault_prct' } ],
121 closure_custom_output => $self->can('custom_fault_output'),
122 perfdatas => [
123 { template => '%s', min => 0 }
124 ]
125 }
126 },
127 { label => 'normal-prct', nlabel => 'accesspoints.normal.percentage', display_ok => 0, set => {
128 key_values => [ { name => 'normal_prct' }, { name => 'total' }, { name => 'normal' } ],
129 closure_custom_output => $self->can('custom_normal_output_prct'),
130 perfdatas => [
131 { template => '%.2f', unit => '%', min => 0, max => 100 }
132 ]
133 }
134 },
135 { label => 'fault-prct', nlabel => 'accesspoints.fault.percentage', display_ok => 0, set => {
136 key_values => [ { name => 'fault_prct' }, { name => 'total' }, { name => 'fault' } ],
137 closure_custom_output => $self->can('custom_fault_output_prct'),
138 perfdatas => [
139 { template => '%.2f', unit => '%', min => 0, max => 100 }
140 ]
141 }
142 },
143 { label => 'current-user', nlabel => 'accesspoints.user.count', display_ok => 0, set => {
144 key_values => [ { name => 'current_user' } ],
145 output_template => 'current user: %s',
146 perfdatas => [
147 { template => '%s', min => 0 }
148 ]
149 }
150 },
151 { label => 'current-auth-user', nlabel => 'accesspoints.user.auth.count', display_ok => 0, set => {
152 key_values => [ { name => 'current_auth_user' }, { name => 'current_auth_user_prct' }, { name => 'current_user' } ],
153 closure_custom_output => $self->can('custom_success_auth_user_output'),
154 perfdatas => [
155 { template => '%s', min => 0 }
156 ]
157 }
158 },
159 { label => 'current-auth-user-prct', nlabel => 'accesspoints.user.auth.percentage', display_ok => 1, set => {
160 key_values => [ { name => 'current_auth_user_prct' }, { name => 'current_auth_user' }, { name => 'current_user' } ],
161 closure_custom_output => $self->can('custom_current_auth_user_prct_output'),
162 perfdatas => [
163 { template => '%.2f', unit => '%', min => 0, max => 100 }
164 ]
165 }
166 }
167 ];
168 }
169
170 sub new {
171 my ($class, %options) = @_;
172 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
173 bless $self, $class;
174
175 $options{options}->add_options(arguments => {});
176
177 return $self;
178 }
179
180 my $oid_normal = '.1.3.6.1.4.1.2011.6.139.12.1.5.6.0';# hwWlanServiceNormalAPCount
181 my $oid_total = '.1.3.6.1.4.1.2011.6.139.12.1.5.7.0';# hwWlanApCount
182 my $oid_cur_user = '.1.3.6.1.4.1.2011.6.139.12.1.2.2.0';# hwWlanCurAssocStaNum
183 my $oid_cur_auth_user = '.1.3.6.1.4.1.2011.6.139.12.1.2.3.0';# hwWlanCurAuthSuccessStaNum
184
185 sub manage_selection {
186 my ($self, %options) = @_;
187
188 $self->{global} = {
189 total => 0,
190 normal => 0,
191 normal_prct => 0,
192 fault => 0,
193 fault_prct => 0,
194 current_user => 0,
195 current_auth_user => 0
196 };
197
198 my $snmp_result = $options{snmp}->get_leef(
199 oids => [ $oid_normal, $oid_total, $oid_cur_user, $oid_cur_auth_user ],
200 nothing_quit => 0
201 );
202
203 $self->{global} = {
204 total => $snmp_result->{$oid_total},
205 normal => $snmp_result->{$oid_normal},
206 current_user => $snmp_result->{$oid_cur_user},
207 current_auth_user => $snmp_result->{$oid_cur_auth_user}
208 };
209
210 $self->{global}->{fault} = $self->{global}->{total} > 0 && $self->{global}->{normal} > 0 ?
211 $self->{global}->{total} - $self->{global}->{normal} : 0;
212
213 $self->{global}->{normal_prct} = $self->{global}->{total} > 0 ?
214 $self->{global}->{normal} * 100 / $self->{global}->{total} : 0;
215
216 $self->{global}->{fault_prct} = $self->{global}->{total} > 0 ?
217 $self->{global}->{fault} * 100 / $self->{global}->{total} : 0;
218
219 $self->{global}->{current_auth_user_prct} = $self->{global}->{current_user} > 0 ?
220 $self->{global}->{current_auth_user} * 100 / $self->{global}->{current_user} : 0;
221 }
222
223 1;
224
225 __END__
226
227 =head1 MODE
228
229 Check global WLAN access point count and user associated and authenticated.
230
231 =over 8
232
233 =item B<--warning-total>
234
235 Thresholds.
236
237 =item B<--critical-total>
238
239 Thresholds.
240
241 =item B<--warning-normal>
242
243 Thresholds.
244
245 =item B<--critical-normal>
246
247 Thresholds.
248
249 =item B<--warning-normal-prct>
250
251 Thresholds.
252
253 =item B<--critical-normal-prct>
254
255 Thresholds.
256
257 =item B<--warning-fault>
258
259 Thresholds.
260
261 =item B<--critical-fault>
262
263 Thresholds.
264
265 =item B<--warning-fault-prct>
266
267 Thresholds.
268
269 =item B<--critical-fault-prct>
270
271 Thresholds.
272
273 =item B<--warning-current-user>
274
275 Thresholds.
276
277 =item B<--critical-current-user>
278
279 Thresholds.
280
281 =item B<--warning-current-auth-user>
282
283 Thresholds.
284
285 =item B<--critical-current-auth-user>
286
287 Thresholds.
288
289 =item B<--warning-current-auth-user-prct>
290
291 Thresholds.
292
293 =item B<--critical-current-auth-user-prct>
294
295 Thresholds.
296
297 =back
298
299 =cut