This commit is contained in:
garnier-quentin 2020-05-05 14:09:04 +02:00
parent 78d1f592fc
commit f56986ae54
4 changed files with 586 additions and 0 deletions

View File

@ -0,0 +1,247 @@
#
# 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 network::ruckus::smartzone::snmp::mode::accesspoints;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
sub custom_status_output {
my ($self, %options) = @_;
return sprintf(
"connection status is '%s' [config status: '%s'] [registration status: '%s']",
$self->{result_values}->{connection_status},
$self->{result_values}->{config_status},
$self->{result_values}->{registration_status}
);
}
sub ap_long_output {
my ($self, %options) = @_;
return "checking access point '" . $options{instance_value}->{display} . "'";
}
sub prefix_ap_output {
my ($self, %options) = @_;
return "access point '" . $options{instance_value}->{display} . "' ";
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'accesspoints', type => 3, cb_prefix_output => 'prefix_ap_output', cb_long_output => 'ap_long_output',
indent_long_output => ' ', message_multiple => 'All access points are ok',
group => [
{ name => 'status', type => 0, skipped_code => { -10 => 1 } },
{ name => 'connection', type => 0, skipped_code => { -10 => 1 } },
{ name => 'traffic', type => 0, skipped_code => { -10 => 1 } }
]
}
];
$self->{maps_counters}->{status} = [
{ label => 'status', threshold => 0, set => {
key_values => [
{ name => 'connection_status' }, { name => 'config_status' },
{ name => 'registration_status' }, { name => 'display' }
],
closure_custom_calc => \&catalog_status_calc,
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold
}
}
];
$self->{maps_counters}->{connection} = [
{ label => 'connection-client-devices-authorized', nlabel => 'accesspoint.connection.client.devices.authorized.count', set => {
key_values => [ { name => 'authorized_clients' }, { name => 'display' } ],
output_template => 'client devices authorized connections: %d',
perfdatas => [
{ value => 'authorized_clients_absolute', template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }
]
}
}
];
$self->{maps_counters}->{traffic} = [
{ label => 'traffic-in', nlabel => 'accesspoint.traffic.in.bitspersecond', set => {
key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ],
output_template => 'traffic in: %s%s/s',
per_second => 1, output_change_bytes => 2,
perfdatas => [
{ value => 'traffic_in_per_second', template => '%s',
min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }
]
}
},
{ label => 'traffic-out', nlabel => 'accesspoint.traffic.out.bitspersecond', set => {
key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ],
output_template => 'traffic in: %s%s/s',
per_second => 1, output_change_bytes => 2,
perfdatas => [
{ value => 'traffic_out_per_second', template => '%s',
min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }
]
}
}
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
'filter-name:s' => { name => 'filter_name' },
'unknown-status:s' => { name => 'unknown_status', default => '' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '' }
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']);
}
my $mapping = {
authorized_clients => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.15' }, # ruckusSZAPNumSta
connection_status => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.16' }, # ruckusSZAPConnStatus
registration_status => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.17' }, # ruckusSZAPRegStatus
config_status => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.18' }, # ruckusSZAPConfigStatus
traffic_out => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.57' }, # ruckusSZAPIpsecTXBytes
traffic_in => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.58' }, # ruckusSZAPIpsecRXBytes
};
sub manage_selection {
my ($self, %options) = @_;
my $oid_ruckusSZAPName = '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.5';
my $oid_ruckusSZAPSerial = '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.9';
my $snmp_result = $options{snmp}->get_multiple_table(
oids => [
{ oid => $oid_ruckusSZAPName },
{ oid => $oid_ruckusSZAPSerial }
],
return_type => 1,
nothing_quit => 1
);
$self->{accesspoints} = {};
foreach (keys %$snmp_result) {
next if (! /^$oid_ruckusSZAPName\.(.*)/);
my $instance = $1;
my $name = defined($snmp_result->{$_}) && $snmp_result->{$_} ne '' ?
$snmp_result->{$_} : $snmp_result->{$oid_ruckusSZAPSerial . '.' . $instance};
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 access point '" . $name . "'.", debug => 1);
next;
}
$self->{accesspoints}->{$instance} = {
display => $name,
status => { display => $name },
connection => { display => $name },
traffic => { display => $name }
};
}
return if (scalar(keys %{$self->{accesspoints}}) <= 0);
$options{snmp}->load(
oids => [ map($_->{oid}, values(%$mapping)) ],
instances => [ keys %{$self->{accesspoints}} ],
instance_regexp => '^(.*)$'
);
$snmp_result = $options{snmp}->get_leef();
foreach (keys %{$self->{accesspoints}}) {
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_);
$self->{accesspoints}->{$_}->{status}->{connection_status} = $result->{connection_status};
$self->{accesspoints}->{$_}->{status}->{registration_status} = $result->{registration_status};
$self->{accesspoints}->{$_}->{status}->{config_status} = $result->{config_status};
$self->{accesspoints}->{$_}->{connection}->{authorized_clients} = $result->{authorized_clients};
$self->{accesspoints}->{$_}->{traffic}->{traffic_in} = $result->{traffic_in} * 8;
$self->{accesspoints}->{$_}->{traffic}->{traffic_out} = $result->{traffic_out} * 8;
}
$self->{cache_name} = 'ruckus_smartzone_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_counters_block}) ? md5_hex($self->{option_results}->{filter_counters_block}) : md5_hex('all')) . '_' .
(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 access points.
=over 8
=item B<--filter-name>
Filter by access point name (can be a regexp).
=item B<--unknown-status>
Set unknown threshold for status.
Can used special variables like: %{config_status}, %{connection_status}, %{registration_status}
=item B<--warning-status>
Set warning threshold for status.
Can used special variables like: %{config_status}, %{connection_status}, %{registration_status}
=item B<--critical-status>
Set critical threshold for status.
Can used special variables like: %{config_status}, %{connection_status}, %{registration_status}
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'memory-usage', 'usage-free', 'usage-prct', 'traffic-in', 'traffic-out',
'cpu-utilization', 'connection-accesspoints', 'connection-client-devices-authorized',
'connection-rogue-devices'.
=back
=cut

View File

@ -0,0 +1,130 @@
#
# 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 network::ruckus::smartzone::snmp::mode::listaccesspoints;
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 $mapping = {
name => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.5' }, # ruckusSZAPName
model => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.8' }, # ruckusSZAPModel
serial_number => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.9' }, # ruckusSZAPSerial
connection_status => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.16' }, # ruckusSZAPConnStatus
registration_status => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.17' }, # ruckusSZAPRegStatus
config_status => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.18' }, # ruckusSZAPConfigStatus
};
my $oid_ruckusSZAPEntry = '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1';
sub manage_selection {
my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_table(
oid => $oid_ruckusSZAPEntry,
start => $mapping->{name}->{oid},
end => $mapping->{config_status}->{oid},
nothing_quit => 1
);
my $accesspoints = {};
foreach my $oid (keys %$snmp_result) {
next if ($oid !~ /^$mapping->{name}->{oid}\.(.*)$/);
my $instance = $1;
$accesspoints->{$instance} = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
}
return $accesspoints;
}
sub run {
my ($self, %options) = @_;
my $accesspoints = $self->manage_selection(%options);
foreach (sort keys %$accesspoints) {
$self->{output}->output_add(
long_msg => sprintf(
'[name: %s] [serial number: %s] [model: %s] [connection status: %s] [config status: %s] [registration status: %s]',
$accesspoints->{$_}->{name},
$accesspoints->{$_}->{serial_number},
$accesspoints->{$_}->{model},
$accesspoints->{$_}->{connection_status},
$accesspoints->{$_}->{config_status},
$accesspoints->{$_}->{registration_status}
)
);
}
$self->{output}->output_add(
severity => 'OK',
short_msg => 'List acess points:'
);
$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 => [keys %$mapping]);
}
sub disco_show {
my ($self, %options) = @_;
my $accesspoints = $self->manage_selection(%options);
foreach (sort keys %$accesspoints) {
$self->{output}->add_disco_entry(
%{$accesspoints->{$_}}
);
}
}
1;
__END__
=head1 MODE
List acess points.
=over 8
=back
=cut

View File

@ -0,0 +1,152 @@
#
# 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 network::ruckus::smartzone::snmp::mode::system;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
sub system_long_output {
my ($self, %options) = @_;
return 'checking system ';
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'system', type => 3, cb_long_output => 'system_long_output',
indent_long_output => ' ',
group => [
{ name => 'connection', type => 0, skipped_code => { -10 => 1 } },
{ name => 'traffic', type => 0, skipped_code => { -10 => 1 } }
]
}
];
$self->{maps_counters}->{connection} = [
{ label => 'connection-accesspoints', nlabel => 'system.connection.accesspoints.count', set => {
key_values => [ { name => 'ap' } ],
output_template => 'access points connections: %d',
perfdatas => [
{ value => 'ap_absolute', template => '%d', min => 0 }
]
}
},
{ label => 'connection-client-devices-authorized', nlabel => 'system.connection.client.devices.authorized.count', set => {
key_values => [ { name => 'authorized_clients' } ],
output_template => 'client devices authorized connections: %d',
perfdatas => [
{ value => 'authorized_clients_absolute', template => '%d', min => 0 }
]
}
}
];
$self->{maps_counters}->{traffic} = [
{ label => 'traffic-in', nlabel => 'system.traffic.in.bitspersecond', set => {
key_values => [ { name => 'traffic_in', diff => 1 } ],
output_template => 'traffic in: %s%s/s',
per_second => 1, output_change_bytes => 2,
perfdatas => [
{ value => 'traffic_in_per_second', template => '%s',
min => 0, unit => 'b/s' }
]
}
},
{ label => 'traffic-out', nlabel => 'system.traffic.out.bitspersecond', set => {
key_values => [ { name => 'traffic_out', diff => 1 } ],
output_template => 'traffic in: %s%s/s',
per_second => 1, output_change_bytes => 2,
perfdatas => [
{ value => 'traffic_out_per_second', template => '%s',
min => 0, unit => 'b/s' }
]
}
}
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
});
return $self;
}
my $mapping = {
ap => { oid => '.1.3.6.1.4.1.25053.1.4.1.1.1.15.1' }, # ruckusSZSystemStatsNumAP
authorized_clients => { oid => '.1.3.6.1.4.1.25053.1.4.1.1.1.15.2' }, # ruckusSZSystemStatsNumSta
traffic_in => { oid => '.1.3.6.1.4.1.25053.1.4.1.1.1.15.6' }, # ruckusSZSystemStatsWLANTotalRxBytes
traffic_out => { oid => '.1.3.6.1.4.1.25053.1.4.1.1.1.15.9' } # ruckusSZSystemStatsWLANTotalTxBytes
};
sub manage_selection {
my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_leef(
oids => [ map($_->{oid} . '.0', values(%$mapping)) ],
nothing_quit => 1
);
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => 0);
$self->{system}->{global} = {
connection => {
ap => $result->{ap},
authorized_clients => $result->{authorized_clients}
},
traffic => {
traffic_in => $result->{traffic_in} * 8,
traffic_out => $result->{traffic_out} * 8
}
};
$self->{cache_name} = 'ruckus_smartzone_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_counters_block}) ? md5_hex($self->{option_results}->{filter_counters_block}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
}
1;
__END__
=head1 MODE
Check system.
=over 8
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'traffic-in', 'traffic-out', 'connection-accesspoints',
'connection-client-devices-authorized'.
=back
=cut

View File

@ -0,0 +1,57 @@
#
# 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 network::ruckus::smartzone::snmp::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '0.5';
%{$self->{modes}} = (
'access-points' => 'network::ruckus::smartzone::snmp::mode::accesspoints',
'cpu' => 'snmp_standard::mode::cpu',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-access-points' => 'network::ruckus::smartzone::snmp::mode::listaccesspoints',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'list-storages' => 'snmp_standard::mode::liststorages',
'load' => 'snmp_standard::mode::loadaverage',
'memory' => 'snmp_standard::mode::memory',
'storage' => 'snmp_standard::mode::storage',
'system' => 'network::ruckus::smartzone::snmp::mode::system',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Ruckus SmartZone in SNMP.
=cut