| 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::apstatus; |
| 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_status_output { |
| 30 |
my ($self, %options) = @_; |
| 31 |
|
| 32 |
my $msg = 'status: ' . $self->{result_values}->{runstate}; |
| 33 |
return $msg; |
| 34 |
} |
| 35 |
|
| 36 |
sub prefix_global_output { |
| 37 |
my ($self, %options) = @_; |
| 38 |
|
| 39 |
return 'Access points '; |
| 40 |
} |
| 41 |
|
| 42 |
sub ap_long_output { |
| 43 |
my ($self, %options) = @_; |
| 44 |
|
| 45 |
return "checking access point '" . $options{instance_value}->{display} . "'"; |
| 46 |
} |
| 47 |
|
| 48 |
sub prefix_ap_output { |
| 49 |
my ($self, %options) = @_; |
| 50 |
|
| 51 |
return "access point '" . $options{instance_value}->{display} . "' "; |
| 52 |
} |
| 53 |
|
| 54 |
sub set_counters { |
| 55 |
my ($self, %options) = @_; |
| 56 |
|
| 57 |
$self->{maps_counters_type} = [ |
| 58 |
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, |
| 59 |
{ name => 'ap', |
| 60 |
type => 3, |
| 61 |
cb_prefix_output => 'prefix_ap_output', |
| 62 |
cb_long_output => 'ap_long_output', |
| 63 |
indent_long_output => ' ', |
| 64 |
message_multiple => 'All access points are ok', |
| 65 |
group => [ |
| 66 |
{ name => 'ap_global', type => 0 } |
| 67 |
] |
| 68 |
} |
| 69 |
]; |
| 70 |
|
| 71 |
$self->{maps_counters}->{global} = [ |
| 72 |
{ label => 'total', nlabel => 'accesspoints.total.count', set => { |
| 73 |
key_values => [ { name => 'total' } ], |
| 74 |
output_template => 'total: %s', |
| 75 |
perfdatas => [ |
| 76 |
{ label => 'total', template => '%s', min => 0 } |
| 77 |
] |
| 78 |
} |
| 79 |
}, |
| 80 |
{ label => 'total-idle', nlabel => 'accesspoints.idle.count', set => { |
| 81 |
key_values => [ { name => 'idle' } ], |
| 82 |
output_template => 'idle: %s', |
| 83 |
perfdatas => [ |
| 84 |
{ label => 'total_idle', template => '%s', min => 0 } |
| 85 |
] |
| 86 |
} |
| 87 |
}, |
| 88 |
{ label => 'total-autofind', nlabel => 'accesspoints.autofind.count', set => { |
| 89 |
key_values => [ { name => 'autofind' } ], |
| 90 |
output_template => 'autofind: %s', |
| 91 |
perfdatas => [ |
| 92 |
{ label => 'total_autofind', template => '%s', min => 0 } |
| 93 |
] |
| 94 |
} |
| 95 |
}, |
| 96 |
{ label => 'total-typeNotMatch', nlabel => 'accesspoints.typenotmatch.count', display_ok => 0, set => { |
| 97 |
key_values => [ { name => 'typeNotMatch' } ], |
| 98 |
output_template => 'type not match: %s', |
| 99 |
perfdatas => [ |
| 100 |
{ label => 'total_type_not_match', template => '%s', min => 0 } |
| 101 |
] |
| 102 |
} |
| 103 |
}, |
| 104 |
{ label => 'total-fault', nlabel => 'accesspoints.fault.count', set => { |
| 105 |
key_values => [ { name => 'fault' } ], |
| 106 |
output_template => 'fault: %s', |
| 107 |
perfdatas => [ |
| 108 |
{ label => 'total_fault', template => '%s', min => 0 } |
| 109 |
] |
| 110 |
} |
| 111 |
}, |
| 112 |
{ label => 'total-config', nlabel => 'accesspoints.config.count', set => { |
| 113 |
key_values => [ { name => 'config' } ], |
| 114 |
output_template => 'config: %s', |
| 115 |
perfdatas => [ |
| 116 |
{ label => 'total_config', template => '%s', min => 0 } |
| 117 |
] |
| 118 |
} |
| 119 |
}, |
| 120 |
{ label => 'total-config-failed', nlabel => 'accesspoints.configfailed.count', set => { |
| 121 |
key_values => [ { name => 'configFailed' } ], |
| 122 |
output_template => 'config failed: %s', |
| 123 |
perfdatas => [ |
| 124 |
{ label => 'total_config_failed', template => '%s', min => 0 } |
| 125 |
] |
| 126 |
} |
| 127 |
}, |
| 128 |
{ label => 'total-download', nlabel => 'accesspoints.download.count', set => { |
| 129 |
key_values => [ { name => 'download' } ], |
| 130 |
output_template => 'download: %s', |
| 131 |
perfdatas => [ |
| 132 |
{ label => 'total_download', template => '%s', min => 0 } |
| 133 |
] |
| 134 |
} |
| 135 |
}, |
| 136 |
{ label => 'total-normal', nlabel => 'accesspoints.normal.count', set => { |
| 137 |
key_values => [ { name => 'normal' } ], |
| 138 |
output_template => 'normal: %s', |
| 139 |
perfdatas => [ |
| 140 |
{ label => 'total_normal', template => '%s', min => 0 } |
| 141 |
] |
| 142 |
} |
| 143 |
}, |
| 144 |
{ label => 'total-committing', nlabel => 'accesspoints.committing.count', set => { |
| 145 |
key_values => [ { name => 'committing' } ], |
| 146 |
output_template => 'committing: %s', |
| 147 |
perfdatas => [ |
| 148 |
{ label => 'total_committing', template => '%s', min => 0 } |
| 149 |
] |
| 150 |
} |
| 151 |
}, |
| 152 |
{ label => 'total-commit-failed', nlabel => 'accesspoints.commitfailed.count', set => { |
| 153 |
key_values => [ { name => 'commitFailed' } ], |
| 154 |
output_template => 'commit failed: %s', |
| 155 |
perfdatas => [ |
| 156 |
{ label => 'total_commit_failed', template => '%s', min => 0 } |
| 157 |
] |
| 158 |
} |
| 159 |
}, |
| 160 |
{ label => 'total-standby', nlabel => 'accesspoints.standby.count', set => { |
| 161 |
key_values => [ { name => 'standby' } ], |
| 162 |
output_template => 'standby: %s', |
| 163 |
perfdatas => [ |
| 164 |
{ label => 'total_standby', template => '%s', min => 0 } |
| 165 |
] |
| 166 |
} |
| 167 |
}, |
| 168 |
{ label => 'total-version-mismatch', nlabel => 'accesspoints.vermismatch.count', set => { |
| 169 |
key_values => [ { name => 'verMismatch' } ], |
| 170 |
output_template => 'version mismatch: %s', |
| 171 |
perfdatas => [ |
| 172 |
{ label => 'total_version_mismatch', template => '%s', min => 0 } |
| 173 |
] |
| 174 |
} |
| 175 |
}, |
| 176 |
{ label => 'total-name-conflicted', nlabel => 'accesspoints.nameconflicted.count', set => { |
| 177 |
key_values => [ { name => 'nameConflicted' } ], |
| 178 |
output_template => 'name conflicted: %s', |
| 179 |
perfdatas => [ |
| 180 |
{ label => 'total_name_conflicted', template => '%s', min => 0 } |
| 181 |
] |
| 182 |
} |
| 183 |
}, |
| 184 |
{ label => 'total-invalid', nlabel => 'accesspoints.invalid.count', set => { |
| 185 |
key_values => [ { name => 'invalid' } ], |
| 186 |
output_template => 'invalid: %s', |
| 187 |
perfdatas => [ |
| 188 |
{ label => 'total_invalid', template => '%s', min => 0 } |
| 189 |
] |
| 190 |
} |
| 191 |
}, |
| 192 |
{ label => 'total-country-code-mismatch', nlabel => 'accesspoints.countrycodemismatch.count', set => { |
| 193 |
key_values => [ { name => 'countryCodeMismatch' } ], |
| 194 |
output_template => 'country code mismatch: %s', |
| 195 |
perfdatas => [ |
| 196 |
{ label => 'total_country_code_mismatch', template => '%s', min => 0 } |
| 197 |
] |
| 198 |
} |
| 199 |
} |
| 200 |
]; |
| 201 |
|
| 202 |
$self->{maps_counters}->{ap_global} = [ |
| 203 |
{ label => 'status', |
| 204 |
type => 2, |
| 205 |
critical_default => '%{runstate} =~ /fault|configFailed|commitFailed|verMismatch|nameConflicted|invalid/', |
| 206 |
warning_default => '%{runstate} =~ /countryCodeMismatch|typeNotMatch/', |
| 207 |
set => |
| 208 |
{ |
| 209 |
key_values => |
| 210 |
[ { name => 'runstate' }, { name => 'display' } ], |
| 211 |
closure_custom_output => |
| 212 |
$self->can('custom_status_output'), |
| 213 |
closure_custom_perfdata => |
| 214 |
sub {return 0;}, |
| 215 |
closure_custom_threshold_check => |
| 216 |
\&catalog_status_threshold_ng |
| 217 |
} |
| 218 |
} |
| 219 |
]; |
| 220 |
} |
| 221 |
|
| 222 |
sub new { |
| 223 |
my ($class, %options) = @_; |
| 224 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 225 |
bless $self, $class; |
| 226 |
|
| 227 |
$options{options}->add_options(arguments => { |
| 228 |
"filter-name:s" => { name => 'filter_name' }, |
| 229 |
"filter-address:s" => { name => 'filter_address' }, |
| 230 |
"filter-group:s" => { name => 'filter_group' } |
| 231 |
}); |
| 232 |
|
| 233 |
return $self; |
| 234 |
} |
| 235 |
|
| 236 |
my $map_run_state = { |
| 237 |
1 => 'idle', |
| 238 |
2 => 'autofind', |
| 239 |
3 => 'typeNotMatch', |
| 240 |
4 => 'fault', |
| 241 |
5 => 'config', |
| 242 |
6 => 'configFailed', |
| 243 |
7 => 'download', |
| 244 |
8 => 'normal', |
| 245 |
9 => 'committing', |
| 246 |
10 => 'commitFailed', |
| 247 |
11 => 'standby', |
| 248 |
12 => 'verMismatch', |
| 249 |
13 => 'nameConflicted', |
| 250 |
14 => 'invalid', |
| 251 |
15 => 'countryCodeMismatch' |
| 252 |
}; |
| 253 |
|
| 254 |
my $mapping = { |
| 255 |
name => { oid => '.1.3.6.1.4.1.2011.6.139.13.3.3.1.4' },# hwWlanApName |
| 256 |
address => { oid => '.1.3.6.1.4.1.2011.6.139.13.3.3.1.13' }# hwWlanApIpAddress |
| 257 |
}; |
| 258 |
|
| 259 |
my $mapping_stat = { |
| 260 |
runtime => { oid => '.1.3.6.1.4.1.2011.6.139.13.3.3.1.18' },# hwWlanApRunTime |
| 261 |
group => { oid => '.1.3.6.1.4.1.2011.6.139.13.3.3.1.5' },# hwWlanApGroup |
| 262 |
runstate => |
| 263 |
{ oid => '.1.3.6.1.4.1.2011.6.139.13.3.3.1.6', map => $map_run_state }# hwWlanApRunState |
| 264 |
}; |
| 265 |
|
| 266 |
sub manage_selection { |
| 267 |
my ($self, %options) = @_; |
| 268 |
|
| 269 |
$self->{ap} = {}; |
| 270 |
$self->{global} = { |
| 271 |
total => 0, |
| 272 |
idle => 0, |
| 273 |
autofind => 0, |
| 274 |
typeNotMatch => 0, |
| 275 |
fault => 0, |
| 276 |
config => 0, |
| 277 |
configFailed => 0, |
| 278 |
download => 0, |
| 279 |
normal => 0, |
| 280 |
committing => 0, |
| 281 |
commitFailed => 0, |
| 282 |
standby => 0, |
| 283 |
verMismatch => 0, |
| 284 |
nameConflicted => 0, |
| 285 |
invalid => 0, |
| 286 |
countryCodeMismatch => 0 |
| 287 |
}; |
| 288 |
|
| 289 |
my $request = [ { oid => $mapping->{name}->{oid} } ]; |
| 290 |
push @$request, { oid => $mapping->{group}->{oid} } |
| 291 |
if (defined($self->{option_results}->{filter_group}) |
| 292 |
&& $self->{option_results}->{filter_group} ne '' |
| 293 |
); |
| 294 |
|
| 295 |
push @$request, { oid => $mapping->{address}->{oid} } |
| 296 |
if (defined($self->{option_results}->{filter_address}) && $self->{option_results}->{filter_address} ne ''); |
| 297 |
|
| 298 |
my $snmp_result = $options{snmp}->get_multiple_table( |
| 299 |
oids => $request, |
| 300 |
return_type => 1, |
| 301 |
nothing_quit => 1 |
| 302 |
); |
| 303 |
|
| 304 |
foreach (sort keys %$snmp_result) { |
| 305 |
next if (!/^$mapping->{name}->{oid}\.(.*)/); |
| 306 |
my $instance = $1; |
| 307 |
|
| 308 |
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); |
| 309 |
if (!defined($result->{name}) || $result->{name} eq '') { |
| 310 |
$self->{output}->output_add( |
| 311 |
long_msg => "skipping WLC '$instance': cannot get a name. please set it.", |
| 312 |
debug => 1 |
| 313 |
); |
| 314 |
next; |
| 315 |
} |
| 316 |
|
| 317 |
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && |
| 318 |
$result->{name} !~ /$self->{option_results}->{filter_name}/) { |
| 319 |
$self->{output}->output_add( |
| 320 |
long_msg => "skipping '" . $result->{name} . "': no matching name filter.", |
| 321 |
debug => 1 |
| 322 |
); |
| 323 |
next; |
| 324 |
} |
| 325 |
|
| 326 |
if (defined($self->{option_results}->{filter_address}) && $self->{option_results}->{filter_address} ne '' && |
| 327 |
$result->{address} !~ /$self->{option_results}->{filter_address}/) { |
| 328 |
$self->{output}->output_add( |
| 329 |
long_msg => "skipping '" . $result->{address} . "': no matching address filter.", |
| 330 |
debug => 1 |
| 331 |
); |
| 332 |
next; |
| 333 |
} |
| 334 |
|
| 335 |
if (defined($self->{option_results}->{filter_group}) && $self->{option_results}->{filter_group} ne '' && |
| 336 |
$result->{group} !~ /$self->{option_results}->{filter_group}/) { |
| 337 |
$self->{output}->output_add( |
| 338 |
long_msg => "skipping '" . $result->{group} . "': no matching group filter.", |
| 339 |
debug => 1 |
| 340 |
); |
| 341 |
next; |
| 342 |
} |
| 343 |
|
| 344 |
$self->{ap}->{ $result->{name} } = { |
| 345 |
instance => $instance, |
| 346 |
display => $result->{name}, |
| 347 |
ap_global => { display => $result->{name} } |
| 348 |
}; |
| 349 |
} |
| 350 |
|
| 351 |
if (scalar(keys %{$self->{ap}}) <= 0) { |
| 352 |
$self->{output}->output_add(long_msg => 'no AP associated'); |
| 353 |
return; |
| 354 |
} |
| 355 |
|
| 356 |
$options{snmp}->load( |
| 357 |
oids => [ map($_->{oid}, values(%$mapping_stat)) ], |
| 358 |
instances => [ map($_->{instance}, values %{$self->{ap}}) ], |
| 359 |
instance_regexp => '^(.*)$' |
| 360 |
); |
| 361 |
$snmp_result = $options{snmp}->get_leef(); |
| 362 |
|
| 363 |
foreach (sort keys %{$self->{ap}}) { |
| 364 |
my $result = $options{snmp}->map_instance( |
| 365 |
mapping => $mapping_stat, |
| 366 |
results => $snmp_result, |
| 367 |
instance => $self->{ap}->{$_}->{instance}); |
| 368 |
|
| 369 |
$self->{global}->{total}++; |
| 370 |
$self->{global}->{ $result->{runstate} }++; |
| 371 |
$self->{ap}->{$_}->{ap_global}->{runstate} = $result->{runstate}; |
| 372 |
} |
| 373 |
} |
| 374 |
|
| 375 |
1; |
| 376 |
|
| 377 |
__END__ |
| 378 |
|
| 379 |
=head1 MODE |
| 380 |
|
| 381 |
Check AP status. |
| 382 |
|
| 383 |
=over 8 |
| 384 |
|
| 385 |
=item B<--filter-counters> |
| 386 |
|
| 387 |
Only display some counters (regexp can be used). |
| 388 |
Example: C<--filter-counters='^total$|^total-normal$'> |
| 389 |
|
| 390 |
=item B<--filter-name> |
| 391 |
|
| 392 |
Filter access point name (can be a regexp) |
| 393 |
|
| 394 |
=item B<--filter-address> |
| 395 |
|
| 396 |
Filter access point IP address (can be a regexp). |
| 397 |
|
| 398 |
=item B<--filter-group> |
| 399 |
|
| 400 |
Filter access point group (can be a regexp). |
| 401 |
|
| 402 |
=item B<--warning-status> |
| 403 |
|
| 404 |
Define the conditions to match for the status to be WARNING. (default: C<'%{runstate} =~ /countryCodeMismatch|typeNotMatch/'>). |
| 405 |
You can use the following variables: C<%{runstate}>, C<%{display}>. |
| 406 |
C<%(runstate)> can have one of these values: C<idle>, C<autofind>, C<typeNotMatch>, C<fault>, C<config>, C<configFailed>, C<download>, C<normal>, C<committing>, C<commitFailed>, C<standby>, C<verMismatch>, C<nameConflicted>, C<invalid>, C<countryCodeMismatch>. |
| 407 |
|
| 408 |
=item B<--critical-status> |
| 409 |
|
| 410 |
Define the conditions to match for the status to be CRITICAL. (default: C<'%{runstate} =~ /fault|configFailed|commitFailed|verMismatch|nameConflicted|invalid/'>). |
| 411 |
You can use the following variables: C<%{runstate}>, C<%{display}>. |
| 412 |
C<%(runstate)> can have one of these values: C<idle>, C<autofind>, C<typeNotMatch>, C<fault>, C<config>, C<configFailed>, C<download>, C<normal>, C<committing>, C<commitFailed>, C<standby>, C<verMismatch>, C<nameConflicted>, C<invalid>, C<countryCodeMismatch>. |
| 413 |
|
| 414 |
=item B<--warning-total> |
| 415 |
|
| 416 |
Thresholds. |
| 417 |
|
| 418 |
=item B<--critical-total> |
| 419 |
|
| 420 |
Thresholds. |
| 421 |
|
| 422 |
=item B<--warning-total-idle> |
| 423 |
|
| 424 |
Thresholds. |
| 425 |
|
| 426 |
=item B<--critical-total-idle> |
| 427 |
|
| 428 |
Thresholds. |
| 429 |
|
| 430 |
=item B<--warning-total-autofind> |
| 431 |
|
| 432 |
Thresholds. |
| 433 |
|
| 434 |
=item B<--critical-total-autofind> |
| 435 |
|
| 436 |
Thresholds. |
| 437 |
|
| 438 |
=item B<--warning-total-typeNotMatch> |
| 439 |
|
| 440 |
Thresholds. |
| 441 |
|
| 442 |
=item B<--critical-total-typeNotMatch> |
| 443 |
|
| 444 |
Thresholds. |
| 445 |
|
| 446 |
=item B<--warning-total-fault> |
| 447 |
|
| 448 |
Thresholds. |
| 449 |
|
| 450 |
=item B<--critical-total-fault> |
| 451 |
|
| 452 |
Thresholds. |
| 453 |
|
| 454 |
=item B<--warning-total-config> |
| 455 |
|
| 456 |
Thresholds. |
| 457 |
|
| 458 |
=item B<--critical-total-config> |
| 459 |
|
| 460 |
Thresholds. |
| 461 |
|
| 462 |
=item B<--warning-total-config-failed> |
| 463 |
|
| 464 |
Thresholds. |
| 465 |
|
| 466 |
=item B<--critical-total-config-failed> |
| 467 |
|
| 468 |
Thresholds. |
| 469 |
|
| 470 |
=item B<--warning-total-download> |
| 471 |
|
| 472 |
Thresholds. |
| 473 |
|
| 474 |
=item B<--critical-total-download> |
| 475 |
|
| 476 |
Thresholds. |
| 477 |
|
| 478 |
=item B<--warning-total-normal> |
| 479 |
|
| 480 |
Thresholds. |
| 481 |
|
| 482 |
=item B<--critical-total-normal> |
| 483 |
|
| 484 |
Thresholds. |
| 485 |
|
| 486 |
=item B<--warning-total-committing> |
| 487 |
|
| 488 |
Thresholds. |
| 489 |
|
| 490 |
=item B<--critical-total-committing> |
| 491 |
|
| 492 |
Thresholds. |
| 493 |
|
| 494 |
=item B<--warning-total-commit-failed> |
| 495 |
|
| 496 |
Thresholds. |
| 497 |
|
| 498 |
=item B<--critical-total-commit-failed> |
| 499 |
|
| 500 |
Thresholds. |
| 501 |
|
| 502 |
=item B<--warning-total-standby> |
| 503 |
|
| 504 |
Thresholds. |
| 505 |
|
| 506 |
=item B<--critical-total-standby> |
| 507 |
|
| 508 |
Thresholds. |
| 509 |
|
| 510 |
=item B<--warning-total-version-mismatch> |
| 511 |
|
| 512 |
Thresholds. |
| 513 |
|
| 514 |
=item B<--critical-total-version-mismatch> |
| 515 |
|
| 516 |
Thresholds. |
| 517 |
|
| 518 |
=item B<--warning-total-name-conflicted> |
| 519 |
|
| 520 |
Thresholds. |
| 521 |
|
| 522 |
=item B<--critical-total-name-conflicted> |
| 523 |
|
| 524 |
Thresholds. |
| 525 |
|
| 526 |
=item B<--warning-total-invalid> |
| 527 |
|
| 528 |
Thresholds. |
| 529 |
|
| 530 |
=item B<--critical-total-invalid> |
| 531 |
|
| 532 |
Thresholds. |
| 533 |
|
| 534 |
=item B<--warning-total-country-code-mismatch> |
| 535 |
|
| 536 |
Thresholds. |
| 537 |
|
| 538 |
=item B<--critical-total-country-code-mismatch> |
| 539 |
|
| 540 |
Thresholds. |
| 541 |
|
| 542 |
=back |
| 543 |
|
| 544 |
=cut |