wip new cisco wlc mode (#2353)

This commit is contained in:
qgarnier 2020-11-19 11:56:46 +01:00 committed by GitHub
parent ee2bde5be1
commit 80c0a75cba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 666 additions and 11 deletions

View File

@ -102,7 +102,7 @@ sub disco_show {
foreach my $name (sort keys %$results) {
$self->{output}->add_disco_entry(
name => $name,
status => $results->{$name}->{description}
description => $results->{$name}->{description}
);
}
}

View File

@ -0,0 +1,127 @@
#
# Copyright 2020 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package centreon::common::airespace::snmp::mode::listradiusaccservers;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
my $map_server_status = {
0 => 'disable', 1 => 'enable'
};
my $mapping = {
address => { oid => '.1.3.6.1.4.1.14179.2.5.2.1.2' }, # bsnRadiusAccServerAddress
port => { oid => '.1.3.6.1.4.1.14179.2.5.2.1.3' }, # bsnRadiusAccClientServerPortNumber
status => { oid => '.1.3.6.1.4.1.14179.2.5.2.1.5', map => $map_server_status } # bsnRadiusAccServerStatus
};
my $oid_bsnRadiusAccServerEntry = '.1.3.6.1.4.1.14179.2.5.2.1';
sub manage_selection {
my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_table(
oid => $oid_bsnRadiusAccServerEntry,
start => $mapping->{address}->{oid},
end => $mapping->{status}->{oid}
);
my $results = {};
foreach my $oid (keys %$snmp_result) {
next if ($oid !~ /^$mapping->{address}->{oid}\.(.*)$/);
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $1);
my $name = $result->{address} . ':' . $result->{port};
$results->{$name} = $result;
}
return $results;
}
sub run {
my ($self, %options) = @_;
my $results = $self->manage_selection(snmp => $options{snmp});
foreach my $name (sort keys %$results) {
$self->{output}->output_add(
long_msg => sprintf(
'[name: %s] [status: %s]',
$name,
$results->{$name}->{status}
)
);
}
$self->{output}->output_add(
severity => 'OK',
short_msg => 'List radius accounting servers:'
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
sub disco_format {
my ($self, %options) = @_;
$self->{output}->add_disco_format(elements => ['name', 'status']);
}
sub disco_show {
my ($self, %options) = @_;
my $results = $self->manage_selection(snmp => $options{snmp});
foreach my $name (sort keys %$results) {
$self->{output}->add_disco_entry(
name => $name,
status => $results->{$name}->{status}
);
}
}
1;
__END__
=head1 MODE
List radius accounting servers.
=over 8
=back
=cut

View File

@ -0,0 +1,127 @@
#
# Copyright 2020 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package centreon::common::airespace::snmp::mode::listradiusauthservers;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
my $map_server_status = {
0 => 'disable', 1 => 'enable'
};
my $mapping = {
address => { oid => '.1.3.6.1.4.1.14179.2.5.1.1.2' }, # bsnRadiusAuthServerAddress
port => { oid => '.1.3.6.1.4.1.14179.2.5.1.1.3' }, # bsnRadiusAuthClientServerPortNumber
status => { oid => '.1.3.6.1.4.1.14179.2.5.1.1.5', map => $map_server_status } # bsnRadiusAuthServerStatus
};
my $oid_bsnRadiusAuthServerEntry = '.1.3.6.1.4.1.14179.2.5.1.1';
sub manage_selection {
my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_table(
oid => $oid_bsnRadiusAuthServerEntry,
start => $mapping->{address}->{oid},
end => $mapping->{status}->{oid}
);
my $results = {};
foreach my $oid (keys %$snmp_result) {
next if ($oid !~ /^$mapping->{address}->{oid}\.(.*)$/);
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $1);
my $name = $result->{address} . ':' . $result->{port};
$results->{$name} = $result;
}
return $results;
}
sub run {
my ($self, %options) = @_;
my $results = $self->manage_selection(snmp => $options{snmp});
foreach my $name (sort keys %$results) {
$self->{output}->output_add(
long_msg => sprintf(
'[name: %s] [status: %s]',
$name,
$results->{$name}->{status}
)
);
}
$self->{output}->output_add(
severity => 'OK',
short_msg => 'List radius authentication servers:'
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
sub disco_format {
my ($self, %options) = @_;
$self->{output}->add_disco_format(elements => ['name', 'status']);
}
sub disco_show {
my ($self, %options) = @_;
my $results = $self->manage_selection(snmp => $options{snmp});
foreach my $name (sort keys %$results) {
$self->{output}->add_disco_entry(
name => $name,
status => $results->{$name}->{status}
);
}
}
1;
__END__
=head1 MODE
List radius authentication servers.
=over 8
=back
=cut

View File

@ -0,0 +1,199 @@
#
# Copyright 2020 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package centreon::common::airespace::snmp::mode::radiusaccservers;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
sub prefix_servers_output {
my ($self, %options) = @_;
return "Radius accounting server '" . $options{instance_value}->{name} . "' ";
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 },
{ name => 'servers', type => 1, cb_prefix_output => 'prefix_servers_output', message_multiple => 'All radius accounting servers are ok' }
];
$self->{maps_counters}->{global} = [
{ label => 'accservers-total', nlabel => 'radius.accservers.total.count', display_ok => 0, set => {
key_values => [ { name => 'total' } ],
output_template => 'total accounting servers: %s',
perfdatas => [
{ ltemplate => '%s', min => 0 }
]
}
}
];
$self->{maps_counters}->{servers} = [
{ label => 'accservers-roundtrip-time', nlabel => 'radius.accservers.roundtrip.time.milliseconds', set => {
key_values => [ { name => 'round_trip_time' }, { name => 'name' } ],
output_template => 'round trip time: %s ms',
perfdatas => [
{ template => '%s', min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'name' }
]
}
},
{ label => 'accservers-packets-sent', nlabel => 'radius.accservers.packets.sent.persecond', set => {
key_values => [ { name => 'requests', per_second => 1 }, { name => 'name' } ],
output_template => 'packets sent: %.2f/s',
perfdatas => [
{ template => '%.2f', min => 0, unit => '/s', label_extra_instance => 1, instance_use => 'name' }
]
}
},
{ label => 'accservers-packets-received', nlabel => 'radius.accservers.packets.received.persecond', set => {
key_values => [ { name => 'responses', per_second => 1 }, { name => 'name' } ],
output_template => 'packets received: %.2f/s',
perfdatas => [
{ template => '%.2f', min => 0, unit => '/s', label_extra_instance => 1, instance_use => 'name' }
]
}
},
{ label => 'accservers-clients-timeout', nlabel => 'radius.accservers.clients.timeout.count', set => {
key_values => [ { name => 'timeouts', diff => '1' }, { name => 'name' } ],
output_template => 'clients timeout: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'name' }
]
}
}
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
'filter-name:s' => { name => 'filter_name' }
});
return $self;
}
my $map_server_status = {
0 => 'disable', 1 => 'enable'
};
my $mapping = {
address => { oid => '.1.3.6.1.4.1.14179.2.5.2.1.2' }, # bsnRadiusAccServerAddress
port => { oid => '.1.3.6.1.4.1.14179.2.5.2.1.3' }, # bsnRadiusAccClientServerPortNumber
status => { oid => '.1.3.6.1.4.1.14179.2.5.2.1.5', map => $map_server_status } # bsnRadiusAccServerStatus
};
my $mapping2 = {
round_trip_time => { oid => '.1.3.6.1.4.1.14179.2.5.4.1.6' }, # bsnRadiusAccClientRoundTripTime
requests => { oid => '.1.3.6.1.4.1.14179.2.5.4.1.7' }, # bsnRadiusAccClientRequests
responses => { oid => '.1.3.6.1.4.1.14179.2.5.4.1.9' }, # bsnRadiusAccClientResponses
timeouts => { oid => '.1.3.6.1.4.1.14179.2.5.4.1.13' } # bsnRadiusAccClientTimeouts
};
my $oid_bsnRadiusAccServerEntry = '.1.3.6.1.4.1.14179.2.5.2.1';
sub manage_selection {
my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_table(
oid => $oid_bsnRadiusAccServerEntry,
start => $mapping->{address}->{oid},
end => $mapping->{status}->{oid},
nothing_quit => 1
);
$self->{global} = { total => 0 };
$self->{servers} = {};
foreach my $oid (keys %$snmp_result) {
next if ($oid !~ /^$mapping->{status}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
my $name = $result->{address} . ':' . $result->{port};
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$name !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1);
next;
}
if ($result->{status} eq 'disable') {
$self->{output}->output_add(long_msg => "skipping '" . $name . "': disabled.", debug => 1);
next;
}
$self->{servers}->{$instance} = { name => $name };
$self->{global}->{total}++;
}
return if (scalar(keys %{$self->{servers}}) <= 0);
$options{snmp}->load(
oids => [ map($_->{oid}, values(%$mapping2)) ],
instances => [keys %{$self->{servers}}],
instance_regexp => '^(.*)$'
);
$snmp_result = $options{snmp}->get_leef(nothing_quit => 1);
foreach (keys %{$self->{servers}}) {
my $result = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result, instance => $_);
$self->{servers}->{$_} = { %{$self->{servers}->{$_}}, %$result };
}
$self->{cache_name} = 'cisco_wlc_' . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
}
1;
__END__
=head1 MODE
Check radius accounting servers.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
Example: --filter-counters='^total$'
=item B<--filter-name>
Filter radius servers by name (can be a regexp).
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'accservers-total', 'accservers-roundtrip-time',
'accservers-packets-sent', 'accservers-packets-received',
'accservers-clients-timeout'.
=back
=cut

View File

@ -0,0 +1,198 @@
#
# Copyright 2020 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package centreon::common::airespace::snmp::mode::radiusauthservers;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
sub prefix_servers_output {
my ($self, %options) = @_;
return "Radius authentication server '" . $options{instance_value}->{name} . "' ";
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 },
{ name => 'servers', type => 1, cb_prefix_output => 'prefix_servers_output', message_multiple => 'All radius authentication servers are ok' }
];
$self->{maps_counters}->{global} = [
{ label => 'authservers-total', nlabel => 'radius.authservers.total.count', display_ok => 0, set => {
key_values => [ { name => 'total' } ],
output_template => 'total authentication servers: %s',
perfdatas => [
{ ltemplate => '%s', min => 0 }
]
}
}
];
$self->{maps_counters}->{servers} = [
{ label => 'authserver-roundtrip-time', nlabel => 'radius.authserver.roundtrip.time.milliseconds', set => {
key_values => [ { name => 'round_trip_time' }, { name => 'name' } ],
output_template => 'round trip time: %s ms',
perfdatas => [
{ template => '%s', min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'name' }
]
}
},
{ label => 'authserver-packets-access-requests', nlabel => 'radius.authserver.packets.access.requests.persecond', set => {
key_values => [ { name => 'access_requests', per_second => 1 }, { name => 'name' } ],
output_template => 'access requests: %.2f/s',
perfdatas => [
{ template => '%.2f', min => 0, unit => '/s', label_extra_instance => 1, instance_use => 'name' }
]
}
},
{ label => 'authserver-packets-access-accepts', nlabel => 'radius.authserver.packets.access.accepts.persecond', set => {
key_values => [ { name => 'access_accepts', per_second => 1 }, { name => 'name' } ],
output_template => 'access accepts: %.2f/s',
perfdatas => [
{ template => '%.2f', min => 0, unit => '/s', label_extra_instance => 1, instance_use => 'name' }
]
}
},
{ label => 'authserver-clients-timeout', nlabel => 'radius.authserver.clients.timeout.count', set => {
key_values => [ { name => 'timeouts', diff => '1' }, { name => 'name' } ],
output_template => 'clients timeout: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'name' }
]
}
}
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
'filter-name:s' => { name => 'filter_name' }
});
return $self;
}
my $map_server_status = {
0 => 'disable', 1 => 'enable'
};
my $mapping = {
address => { oid => '.1.3.6.1.4.1.14179.2.5.1.1.2' }, # bsnRadiusAuthServerAddress
port => { oid => '.1.3.6.1.4.1.14179.2.5.1.1.3' }, # bsnRadiusAuthClientServerPortNumber
status => { oid => '.1.3.6.1.4.1.14179.2.5.1.1.5', map => $map_server_status } # bsnRadiusAuthServerStatus
};
my $mapping2 = {
round_trip_time => { oid => '.1.3.6.1.4.1.14179.2.5.3.1.6' }, # bsnRadiusAuthClientRoundTripTime
access_requests => { oid => '.1.3.6.1.4.1.14179.2.5.3.1.7' }, # bsnRadiusAuthClientAccessRequests
access_accepts => { oid => '.1.3.6.1.4.1.14179.2.5.3.1.9' }, # bsnRadiusAuthClientAccessAccepts
timeouts => { oid => '.1.3.6.1.4.1.14179.2.5.3.1.15' } # bsnRadiusAuthClientTimeouts
};
my $oid_bsnRadiusAuthServerEntry = '.1.3.6.1.4.1.14179.2.5.1.1';
sub manage_selection {
my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_table(
oid => $oid_bsnRadiusAuthServerEntry,
start => $mapping->{address}->{oid},
end => $mapping->{status}->{oid},
nothing_quit => 1
);
$self->{global} = { total => 0 };
$self->{servers} = {};
foreach my $oid (keys %$snmp_result) {
next if ($oid !~ /^$mapping->{status}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
my $name = $result->{address} . ':' . $result->{port};
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$name !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1);
next;
}
if ($result->{status} eq 'disable') {
$self->{output}->output_add(long_msg => "skipping '" . $name . "': disabled.", debug => 1);
next;
}
$self->{servers}->{$instance} = { name => $name };
$self->{global}->{total}++;
}
return if (scalar(keys %{$self->{servers}}) <= 0);
$options{snmp}->load(
oids => [ map($_->{oid}, values(%$mapping2)) ],
instances => [keys %{$self->{servers}}],
instance_regexp => '^(.*)$'
);
$snmp_result = $options{snmp}->get_leef(nothing_quit => 1);
foreach (keys %{$self->{servers}}) {
my $result = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result, instance => $_);
$self->{servers}->{$_} = { %{$self->{servers}->{$_}}, %$result };
}
$self->{cache_name} = 'cisco_wlc_' . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
}
1;
__END__
=head1 MODE
Check radius authentication servers.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
Example: --filter-counters='^total$'
=item B<--filter-name>
Filter radius servers by name (can be a regexp).
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'authservers-total', 'authserver-roundtrip-time', 'authserver-packets-access-requests',
'authserver-packets-access-accepts', 'authserver-clients-timeout'.
=back
=cut

View File

@ -31,16 +31,20 @@ sub new {
$self->{version} = '1.0';
$self->{modes} = {
'ap-channel-interference' => 'centreon::common::airespace::snmp::mode::apchannelinterference',
'ap-channel-noise' => 'centreon::common::airespace::snmp::mode::apchannelnoise',
'ap-status' => 'centreon::common::airespace::snmp::mode::apstatus',
'ap-users' => 'centreon::common::airespace::snmp::mode::apusers',
'cpu' => 'centreon::common::airespace::snmp::mode::cpu',
'hardware' => 'centreon::common::airespace::snmp::mode::hardware',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-groups' => 'centreon::common::airespace::snmp::mode::listgroups',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'memory' => 'centreon::common::airespace::snmp::mode::memory'
'ap-channel-interference' => 'centreon::common::airespace::snmp::mode::apchannelinterference',
'ap-channel-noise' => 'centreon::common::airespace::snmp::mode::apchannelnoise',
'ap-status' => 'centreon::common::airespace::snmp::mode::apstatus',
'ap-users' => 'centreon::common::airespace::snmp::mode::apusers',
'cpu' => 'centreon::common::airespace::snmp::mode::cpu',
'hardware' => 'centreon::common::airespace::snmp::mode::hardware',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-groups' => 'centreon::common::airespace::snmp::mode::listgroups',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'list-radius-acc-servers' => 'centreon::common::airespace::snmp::mode::listradiusaccservers',
'list-radius-auth-servers' => 'centreon::common::airespace::snmp::mode::listradiusauthservers',
'memory' => 'centreon::common::airespace::snmp::mode::memory',
'radius-acc-servers' => 'centreon::common::airespace::snmp::mode::radiusaccservers',
'radius-auth-servers' => 'centreon::common::airespace::snmp::mode::radiusauthservers'
};
return $self;