diff --git a/network/ruckus/scg/snmp/mode/apstatus.pm b/network/ruckus/scg/snmp/mode/apstatus.pm new file mode 100644 index 000000000..9582a3e9f --- /dev/null +++ b/network/ruckus/scg/snmp/mode/apstatus.pm @@ -0,0 +1,205 @@ +# +# Copyright 2018 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::scg::snmp::mode::apstatus; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +my $instance_mode; + +sub custom_status_threshold { + my ($self, %options) = @_; + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' && + eval "$instance_mode->{option_results}->{critical_status}") { + $status = 'critical'; + } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && + eval "$instance_mode->{option_results}->{warning_status}") { + $status = 'warning'; + } + }; + if (defined($message)) { + $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); + } + + return $status; +} + +sub custom_status_output { + my ($self, %options) = @_; + + my $msg = "connection status is '" . $self->{result_values}->{connection_status} . "'"; + $msg .= ", registration status is '" . $self->{result_values}->{registration_status} . "'"; + $msg .= ", configuration status is '" . $self->{result_values}->{configuration_status} . "'"; + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{connection_status} = $options{new_datas}->{$self->{instance} . '_ruckusSCGAPConnStatus'}; + $self->{result_values}->{registration_status} = $options{new_datas}->{$self->{instance} . '_ruckusSCGAPRegStatus'}; + $self->{result_values}->{configuration_status} = $options{new_datas}->{$self->{instance} . '_ruckusSCGAPConfigStatus'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'ap', type => 1, cb_prefix_output => 'prefix_ap_output', message_multiple => 'All APs are ok' } + ]; + + $self->{maps_counters}->{ap} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'ruckusSCGAPConnStatus' }, { name => 'ruckusSCGAPRegStatus' }, + { name => 'ruckusSCGAPConfigStatus' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => $self->can('custom_status_threshold'), + } + }, + ]; +} + +sub prefix_ap_output { + my ($self, %options) = @_; + + return "AP '" . $options{instance_value}->{display} . "' "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "filter-name:s" => { name => 'filter_name' }, + "warning-status:s" => { name => 'warning_status', default => '%{configuration_status} !~ /^Up-to-date$/i' }, + "critical-status:s" => { name => 'critical_status', default => '%{connection_status} =~ /^Disconnect$/i' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; + $self->change_macros(); +} + +sub change_macros { + my ($self, %options) = @_; + + foreach (('warning_status', 'critical_status')) { + if (defined($self->{option_results}->{$_})) { + $self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + } + } +} + +my $oid_ruckusSCGAPName = '.1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.5', +my $mapping = { + ruckusSCGAPConnStatus => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.16' }, + ruckusSCGAPRegStatus => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.17' }, + ruckusSCGAPConfigStatus => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.18' }, +}; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{ap} = {}; + my $snmp_result = $options{snmp}->get_table(oid => $oid_ruckusSCGAPName, nothing_quit => 1); + foreach my $oid (keys %{$snmp_result}) { + $oid =~ /^$oid_ruckusSCGAPName\.(.*)$/; + my $instance = $1; + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $snmp_result->{$oid} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $snmp_result->{$oid} . "'.", debug => 1); + next; + } + + $self->{ap}->{$instance} = { display => $snmp_result->{$oid} }; + } + + $options{snmp}->load(oids => [ $mapping->{ruckusSCGAPConnStatus}->{oid}, + $mapping->{ruckusSCGAPRegStatus}->{oid}, + $mapping->{ruckusSCGAPConfigStatus}->{oid} ], + instances => [ keys %{$self->{ap}} ], + instance_regexp => '^(.*)$'); + $snmp_result = $options{snmp}->get_leef(nothing_quit => 1); + + foreach (keys %{$self->{ap}}) { + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_); + + foreach my $name (keys %$mapping) { + $self->{ap}->{$_}->{$name} = $result->{$name}; + } + } + + if (scalar(keys %{$self->{ap}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No AP found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check AP status. + +=over 8 + +=item B<--filter-name> + +Filter by AP name (can be a regexp). + +=item B<--warning-status> + +Set warning threshold for status (Default: '%{configuration_status} !~ /^Up-to-date$/i'). +Can used special variables like: %{connection_status}, %{registration_status}, %{configuration_status}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{connection_status} =~ /^Disconnect$/i'). +Can used special variables like: %{connection_status}, %{registration_status}, %{configuration_status}, %{display} + +=back + +=cut diff --git a/network/ruckus/scg/snmp/mode/apusage.pm b/network/ruckus/scg/snmp/mode/apusage.pm new file mode 100644 index 000000000..db4318e5d --- /dev/null +++ b/network/ruckus/scg/snmp/mode/apusage.pm @@ -0,0 +1,174 @@ +# +# Copyright 2018 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::scg::snmp::mode::apusage; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'ap', type => 1, cb_prefix_output => 'prefix_ap_output', message_multiple => 'All APs are ok' }, + ]; + + $self->{maps_counters}->{ap} = [ + { label => 'users-count', set => { + key_values => [ { name => 'ruckusSCGAPNumSta' }, { name => 'display' } ], + output_template => 'Users count: %s', + perfdatas => [ + { label => 'users_count', value => 'ruckusSCGAPNumSta_absolute', template => '%s', + unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'traffic-in', set => { + key_values => [ { name => 'ruckusSCGAPRXBytes', diff => 1 }, { name => 'display' } ], + output_template => 'Traffic In: %s %s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { label => 'traffic_in', value => 'ruckusSCGAPRXBytes_absolute', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'traffic-out', set => { + key_values => [ { name => 'ruckusSCGAPTXBytes', diff => 1 }, { name => 'display' } ], + output_template => 'Traffic Out: %s %s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { label => 'traffic_out', value => 'ruckusSCGAPTXBytes_absolute', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +sub prefix_ap_output { + my ($self, %options) = @_; + + return "AP '" . $options{instance_value}->{display} . "' "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "filter-name:s" => { name => 'filter_name' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); +} + +my $oid_ruckusSCGAPName = '.1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.5', +my $mapping = { + ruckusSCGAPNumSta => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.15' }, + ruckusSCGAPRXBytes => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.30' }, + ruckusSCGAPTXBytes => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.31' }, +}; + +sub manage_selection { + my ($self, %options) = @_; + + if ($options{snmp}->is_snmpv1()) { + $self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3."); + $self->{output}->option_exit(); + } + + $self->{ap} = {}; + my $snmp_result = $options{snmp}->get_table(oid => $oid_ruckusSCGAPName, nothing_quit => 1); + foreach my $oid (keys %{$snmp_result}) { + $oid =~ /^$oid_ruckusSCGAPName\.(.*)$/; + my $instance = $1; + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $snmp_result->{$oid} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $snmp_result->{$oid} . "'.", debug => 1); + next; + } + + $self->{ap}->{$instance} = { display => $snmp_result->{$oid} }; + } + + $options{snmp}->load(oids => [ $mapping->{ruckusSCGAPNumSta}->{oid}, + $mapping->{ruckusSCGAPRXBytes}->{oid}, + $mapping->{ruckusSCGAPTXBytes}->{oid} ], + instances => [ keys %{$self->{ap}} ], + instance_regexp => '^(.*)$'); + $snmp_result = $options{snmp}->get_leef(nothing_quit => 1); + + foreach (keys %{$self->{ap}}) { + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_); + + foreach my $name (keys %{$mapping}) { + $self->{ap}->{$_}->{$name} = $result->{$name}; + } + } + + if (scalar(keys %{$self->{ap}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No AP found."); + $self->{output}->option_exit(); + } + + $self->{cache_name} = "ruckus_scg_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . + (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check AP connected users and traffic. + +=over 8 + +=item B<--filter-name> + +Filter by AP name (can be a regexp). + +=item B<--warning-*> + +Threshold warning. +Can be: 'users-count', 'traffic-in', 'traffic-out'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'users-count', 'traffic-in', 'traffic-out'. + +=back + +=cut + diff --git a/network/ruckus/scg/snmp/mode/listaps.pm b/network/ruckus/scg/snmp/mode/listaps.pm new file mode 100644 index 000000000..1cfab462a --- /dev/null +++ b/network/ruckus/scg/snmp/mode/listaps.pm @@ -0,0 +1,158 @@ +# +# Copyright 2018 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::scg::snmp::mode::listaps; + +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; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "filter-name:s" => { name => 'filter_name' }, + }); + $self->{ap} = {}; + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +my $mapping = { + ruckusSCGAPGroup => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.2' }, + ruckusSCGAPZone => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.3' }, + ruckusSCGAPDomain => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.4' }, + ruckusSCGAPName => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.5' }, + ruckusSCGAPModel => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.8' }, + ruckusSCGAPConnStatus => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.16' }, + ruckusSCGAPLocation => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.19' }, + ruckusSCGAPDescription => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.22' }, +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_multiple_table(oids => [ { oid => $mapping->{ruckusSCGAPGroup}->{oid} }, + { oid => $mapping->{ruckusSCGAPZone}->{oid} }, + { oid => $mapping->{ruckusSCGAPDomain}->{oid} }, + { oid => $mapping->{ruckusSCGAPName}->{oid} }, + { oid => $mapping->{ruckusSCGAPModel}->{oid} }, + { oid => $mapping->{ruckusSCGAPConnStatus}->{oid} }, + { oid => $mapping->{ruckusSCGAPLocation}->{oid} }, + { oid => $mapping->{ruckusSCGAPDescription}->{oid} }, + ], + return_type => 1, nothing_quit => 1); + foreach my $oid (keys %$snmp_result) { + next if ($oid !~ /^$mapping->{ruckusSCGAPName}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $result->{ruckusSCGAPName} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $result->{ruckusSCGAPName} . "': no matching filter.", debug => 1); + next; + } + + $self->{ap}->{$instance} = { + name => $result->{ruckusSCGAPName}, + group => $result->{ruckusSCGAPGroup}, + zone => $result->{ruckusSCGAPZone}, + domain => $result->{ruckusSCGAPDomain}, + model => $result->{ruckusSCGAPModel}, + status => $result->{ruckusSCGAPConnStatus}, + location => $result->{ruckusSCGAPLocation}, + description => $result->{ruckusSCGAPDescription} + }; + } +} + +sub run { + my ($self, %options) = @_; + + $self->manage_selection(%options); + foreach my $instance (sort keys %{$self->{ap}}) { + $self->{output}->output_add(long_msg => '[name = ' . $self->{ap}->{$instance}->{name} . + "] [group = " . $self->{ap}->{$instance}->{group} . + "] [zone = " . $self->{ap}->{$instance}->{zone} . + "] [domain = " . $self->{ap}->{$instance}->{domain} . + "] [model = " . $self->{ap}->{$instance}->{model} . + "] [status = " . $self->{ap}->{$instance}->{status} . + "] [location = " . $self->{ap}->{$instance}->{location} . + "] [description = " . $self->{ap}->{$instance}->{description} . "]" + ); + } + + $self->{output}->output_add(severity => 'OK', + short_msg => 'List APs:'); + $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', 'group', 'zone', 'domain', 'model', 'status', 'location', 'description']); +} + +sub disco_show { + my ($self, %options) = @_; + + $self->manage_selection(%options); + foreach my $instance (sort keys %{$self->{ap}}) { + $self->{output}->add_disco_entry( + name => $self->{ap}->{$instance}->{name}, + group => $self->{ap}->{$instance}->{group}, + zone => $self->{ap}->{$instance}->{zone}, + domain => $self->{ap}->{$instance}->{domain}, + model => $self->{ap}->{$instance}->{model}, + status => $self->{ap}->{$instance}->{status}, + location => $self->{ap}->{$instance}->{location}, + description => $self->{ap}->{$instance}->{description}); + } +} + +1; + +__END__ + +=head1 MODE + +List APs. + +=over 8 + +=item B<--filter-name> + +Filter by AP name (can be a regexp). + +=back + +=cut + diff --git a/network/ruckus/scg/snmp/mode/listssids.pm b/network/ruckus/scg/snmp/mode/listssids.pm new file mode 100644 index 000000000..cf5e53ba4 --- /dev/null +++ b/network/ruckus/scg/snmp/mode/listssids.pm @@ -0,0 +1,138 @@ +# +# Copyright 2018 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::scg::snmp::mode::listssids; + +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; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "filter-name:s" => { name => 'filter_name' }, + }); + $self->{ssid} = {}; + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +my $mapping = { + ruckusSCGWLANSSID => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.1.2.1.1' }, + ruckusSCGWLANZone => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.1.2.1.2' }, + ruckusSCGWLANDomain => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.1.2.1.3' }, + ruckusSCGWLANAuthType => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.1.2.1.17' }, +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_multiple_table(oids => [ { oid => $mapping->{ruckusSCGWLANSSID}->{oid} }, + { oid => $mapping->{ruckusSCGWLANZone}->{oid} }, + { oid => $mapping->{ruckusSCGWLANDomain}->{oid} }, + { oid => $mapping->{ruckusSCGWLANAuthType}->{oid} }, + ], + return_type => 1, nothing_quit => 1); + foreach my $oid (keys %$snmp_result) { + next if ($oid !~ /^$mapping->{ruckusSCGWLANSSID}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $result->{ruckusSCGWLANSSID} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $result->{ruckusSCGWLANSSID} . "': no matching filter.", debug => 1); + next; + } + + $self->{ssid}->{$instance} = { + name => $result->{ruckusSCGWLANSSID}, + zone => $result->{ruckusSCGWLANZone}, + domain => $result->{ruckusSCGWLANDomain}, + authentication => $result->{ruckusSCGWLANAuthType} + }; + } +} + +sub run { + my ($self, %options) = @_; + + $self->manage_selection(%options); + foreach my $instance (sort keys %{$self->{ssid}}) { + $self->{output}->output_add(long_msg => '[name = ' . $self->{ssid}->{$instance}->{name} . + "] [zone = " . $self->{ssid}->{$instance}->{zone} . + "] [domain = " . $self->{ssid}->{$instance}->{domain} . + "] [authentication = " . $self->{ssid}->{$instance}->{authentication} . "]" + ); + } + + $self->{output}->output_add(severity => 'OK', + short_msg => 'List SSIDs:'); + $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', 'zone', 'domain', 'authentication']); +} + +sub disco_show { + my ($self, %options) = @_; + + $self->manage_selection(%options); + foreach my $instance (sort keys %{$self->{ssid}}) { + $self->{output}->add_disco_entry( + name => $self->{ssid}->{$instance}->{name}, + zone => $self->{ssid}->{$instance}->{zone}, + domain => $self->{ssid}->{$instance}->{domain}, + authentication => $self->{ssid}->{$instance}->{authentication}); + } +} + +1; + +__END__ + +=head1 MODE + +List SSIDs. + +=over 8 + +=item B<--filter-name> + +Filter by SSID name (can be a regexp). + +=back + +=cut + diff --git a/network/ruckus/scg/snmp/mode/ssidusage.pm b/network/ruckus/scg/snmp/mode/ssidusage.pm new file mode 100644 index 000000000..9e7611423 --- /dev/null +++ b/network/ruckus/scg/snmp/mode/ssidusage.pm @@ -0,0 +1,174 @@ +# +# Copyright 2018 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::scg::snmp::mode::ssidusage; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'ssid', type => 1, cb_prefix_output => 'prefix_ssid_output', message_multiple => 'All SSIDs are ok' }, + ]; + + $self->{maps_counters}->{ssid} = [ + { label => 'users-count', set => { + key_values => [ { name => 'ruckusSCGWLANNumSta' }, { name => 'display' } ], + output_template => 'Users count: %s', + perfdatas => [ + { label => 'users_count', value => 'ruckusSCGWLANNumSta_absolute', template => '%s', + unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'traffic-in', set => { + key_values => [ { name => 'ruckusSCGWLANRxBytes', diff => 1 }, { name => 'display' } ], + output_template => 'Traffic In: %s %s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { label => 'traffic_in', value => 'ruckusSCGWLANRxBytes_absolute', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'traffic-out', set => { + key_values => [ { name => 'ruckusSCGWLANTxBytes', diff => 1 }, { name => 'display' } ], + output_template => 'Traffic Out: %s %s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { label => 'traffic_out', value => 'ruckusSCGWLANTxBytes_absolute', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +sub prefix_ssid_output { + my ($self, %options) = @_; + + return "SSID '" . $options{instance_value}->{display} . "' "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "filter-name:s" => { name => 'filter_name' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); +} + +my $oid_ruckusSCGAPName = '.1.3.6.1.4.1.25053.1.3.2.1.1.1.2.1.1', +my $mapping = { + ruckusSCGWLANNumSta => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.1.2.1.12' }, + ruckusSCGWLANRxBytes => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.1.2.1.14' }, + ruckusSCGWLANTxBytes => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.1.2.1.16' }, +}; + +sub manage_selection { + my ($self, %options) = @_; + + if ($options{snmp}->is_snmpv1()) { + $self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3."); + $self->{output}->option_exit(); + } + + $self->{ssid} = {}; + my $snmp_result = $options{snmp}->get_table(oid => $oid_ruckusSCGAPName, nothing_quit => 1); + foreach my $oid (keys %{$snmp_result}) { + $oid =~ /^$oid_ruckusSCGAPName\.(.*)$/; + my $instance = $1; + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $snmp_result->{$oid} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $snmp_result->{$oid} . "'.", debug => 1); + next; + } + + $self->{ssid}->{$instance} = { display => $snmp_result->{$oid} }; + } + + $options{snmp}->load(oids => [ $mapping->{ruckusSCGWLANNumSta}->{oid}, + $mapping->{ruckusSCGWLANRxBytes}->{oid}, + $mapping->{ruckusSCGWLANTxBytes}->{oid} ], + instances => [ keys %{$self->{ssid}} ], + instance_regexp => '^(.*)$'); + $snmp_result = $options{snmp}->get_leef(nothing_quit => 1); + + foreach (keys %{$self->{ssid}}) { + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_); + + foreach my $name (keys %{$mapping}) { + $self->{ssid}->{$_}->{$name} = $result->{$name}; + } + } + + if (scalar(keys %{$self->{ssid}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No SSID found."); + $self->{output}->option_exit(); + } + + $self->{cache_name} = "ruckus_scg_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . + (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check SSID connected users and traffic. + +=over 8 + +=item B<--filter-name> + +Filter by SSID name (can be a regexp). + +=item B<--warning-*> + +Threshold warning. +Can be: 'users-count', 'traffic-in', 'traffic-out'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'users-count', 'traffic-in', 'traffic-out'. + +=back + +=cut + diff --git a/network/ruckus/scg/snmp/mode/systemstats.pm b/network/ruckus/scg/snmp/mode/systemstats.pm new file mode 100644 index 000000000..c062c5b92 --- /dev/null +++ b/network/ruckus/scg/snmp/mode/systemstats.pm @@ -0,0 +1,226 @@ +# +# Copyright 2018 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::scg::snmp::mode::systemstats; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + ]; + + $self->{maps_counters}->{global} = [ + { label => 'aps-count', set => { + key_values => [ { name => 'ruckusSystemStatsNumAP' } ], + output_template => 'APs count: %s', + perfdatas => [ + { label => 'aps_count', value => 'ruckusSystemStatsNumAP_absolute', template => '%s', + unit => 'aps', min => 0 }, + ], + } + }, + { label => 'users-count', set => { + key_values => [ { name => 'ruckusSystemStatsNumSta' } ], + output_template => 'Users count: %s', + perfdatas => [ + { label => 'users_count', value => 'ruckusSystemStatsNumSta_absolute', template => '%s', + unit => 'users', min => 0 }, + ], + } + }, + { label => 'total-traffic-in', set => { + key_values => [ { name => 'ruckusSystemStatsWLANTotalRxBytes', diff => 1 } ], + output_template => 'Total Traffic In: %s %s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { label => 'total_traffic_in', value => 'ruckusSystemStatsWLANTotalRxBytes_absolute', template => '%s', + min => 0, unit => 'b/s' }, + ], + } + }, + { label => 'total-traffic-out', set => { + key_values => [ { name => 'ruckusSystemStatsWLANTotalTxBytes', diff => 1 } ], + output_template => 'Total Traffic Out: %s %s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { label => 'total_traffic_out', value => 'ruckusSystemStatsWLANTotalTxBytes_absolute', template => '%s', + min => 0, unit => 'b/s' }, + ], + } + }, + { label => 'total-packets-in', set => { + key_values => [ { name => 'ruckusSystemStatsWLANTotalRxPkts', diff => 1 } ], + output_template => 'Total Packets In: %s packets/s', + per_second => 1, + perfdatas => [ + { label => 'total_packets_in', value => 'ruckusSystemStatsWLANTotalRxPkts_absolute', template => '%s', + min => 0, unit => 'packets/s' }, + ], + } + }, + { label => 'total-mcast-packets-in', set => { + key_values => [ { name => 'ruckusSystemStatsWLANTotalRxMulticast', diff => 1 } ], + output_template => 'Total Multicast Packets In: %s packets/s', + per_second => 1, + perfdatas => [ + { label => 'total_mcast_packets_in', value => 'ruckusSystemStatsWLANTotalRxMulticast_absolute', template => '%s', + min => 0, unit => 'packets/s' }, + ], + } + }, + { label => 'total-packets-out', set => { + key_values => [ { name => 'ruckusSystemStatsWLANTotalTxPkts', diff => 1 } ], + output_template => 'Total Packets Out: %s packets/s', + per_second => 1, + perfdatas => [ + { label => 'total_packets_out', value => 'ruckusSystemStatsWLANTotalTxPkts_absolute', template => '%s', + min => 0, unit => 'packets/s' }, + ], + } + }, + { label => 'total-mcast-packets-out', set => { + key_values => [ { name => 'ruckusSystemStatsWLANTotalTxMulticast', diff => 1 } ], + output_template => 'Total Multicast Packets Out: %s packets/s', + per_second => 1, + perfdatas => [ + { label => 'total_mcast_packets_out', value => 'ruckusSystemStatsWLANTotalTxMulticast_absolute', template => '%s', + min => 0, unit => 'packets/s' }, + ], + } + }, + { label => 'total-fail-packets-out', set => { + key_values => [ { name => 'ruckusSystemStatsWLANTotalTxFail', diff => 1 } ], + output_template => 'Total Fail Packets Out: %s packets/s', + per_second => 1, + perfdatas => [ + { label => 'total_fail_packets_out', value => 'ruckusSystemStatsWLANTotalTxFail_absolute', template => '%s', + min => 0, unit => 'packets/s' }, + ], + } + }, + { label => 'total-retry-packets-out', set => { + key_values => [ { name => 'ruckusSystemStatsWLANTotalTxRetry', diff => 1 } ], + output_template => 'Total Retry Packets Out: %s packets/s', + per_second => 1, + perfdatas => [ + { label => 'total_retry_packets_out', value => 'ruckusSystemStatsWLANTotalTxRetry_absolute', template => '%s', + min => 0, unit => 'packets/s' }, + ], + } + }, + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); +} + +my $oid_ruckusSystemStatsNumAP = '.1.3.6.1.4.1.25053.1.3.1.1.1.15.1.0'; +my $oid_ruckusSystemStatsNumSta = '.1.3.6.1.4.1.25053.1.3.1.1.1.15.2.0'; +my $oid_ruckusSystemStatsWLANTotalRxPkts = '.1.3.6.1.4.1.25053.1.3.1.1.1.15.5.0'; +my $oid_ruckusSystemStatsWLANTotalRxBytes = '.1.3.6.1.4.1.25053.1.3.1.1.1.15.6.0'; +my $oid_ruckusSystemStatsWLANTotalRxMulticast = '.1.3.6.1.4.1.25053.1.3.1.1.1.15.7.0'; +my $oid_ruckusSystemStatsWLANTotalTxPkts = '.1.3.6.1.4.1.25053.1.3.1.1.1.15.8.0'; +my $oid_ruckusSystemStatsWLANTotalTxBytes = '.1.3.6.1.4.1.25053.1.3.1.1.1.15.9.0'; +my $oid_ruckusSystemStatsWLANTotalTxMulticast = '.1.3.6.1.4.1.25053.1.3.1.1.1.15.10.0'; +my $oid_ruckusSystemStatsWLANTotalTxFail = '.1.3.6.1.4.1.25053.1.3.1.1.1.15.11.0'; +my $oid_ruckusSystemStatsWLANTotalTxRetry = '.1.3.6.1.4.1.25053.1.3.1.1.1.15.12.0'; + +sub manage_selection { + my ($self, %options) = @_; + + if ($options{snmp}->is_snmpv1()) { + $self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3."); + $self->{output}->option_exit(); + } + + my $result = $options{snmp}->get_leef(oids => [ $oid_ruckusSystemStatsNumAP, $oid_ruckusSystemStatsNumSta, + $oid_ruckusSystemStatsWLANTotalRxPkts, $oid_ruckusSystemStatsWLANTotalRxBytes, + $oid_ruckusSystemStatsWLANTotalRxMulticast, $oid_ruckusSystemStatsWLANTotalTxPkts, + $oid_ruckusSystemStatsWLANTotalTxBytes, $oid_ruckusSystemStatsWLANTotalTxMulticast, + $oid_ruckusSystemStatsWLANTotalTxFail, $oid_ruckusSystemStatsWLANTotalTxRetry ], + nothing_quit => 1); + + $self->{global} = { + ruckusSystemStatsNumAP => $result->{$oid_ruckusSystemStatsNumAP}, + ruckusSystemStatsNumSta => $result->{$oid_ruckusSystemStatsNumSta}, + ruckusSystemStatsWLANTotalRxPkts => $result->{$oid_ruckusSystemStatsWLANTotalRxPkts}, + ruckusSystemStatsWLANTotalRxBytes => $result->{$oid_ruckusSystemStatsWLANTotalRxBytes}, + ruckusSystemStatsWLANTotalRxMulticast => $result->{$oid_ruckusSystemStatsWLANTotalRxMulticast}, + ruckusSystemStatsWLANTotalTxPkts => $result->{$oid_ruckusSystemStatsWLANTotalTxPkts}, + ruckusSystemStatsWLANTotalTxBytes => $result->{$oid_ruckusSystemStatsWLANTotalTxBytes}, + ruckusSystemStatsWLANTotalTxMulticast => $result->{$oid_ruckusSystemStatsWLANTotalTxMulticast}, + ruckusSystemStatsWLANTotalTxFail => $result->{$oid_ruckusSystemStatsWLANTotalTxFail}, + ruckusSystemStatsWLANTotalTxRetry => $result->{$oid_ruckusSystemStatsWLANTotalTxRetry}, + }; + + $self->{cache_name} = "ruckus_scg_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . + (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check system statistics. + +=over 8 + +=item B<--warning-*> + +Threshold warning. +Can be: 'aps-count', 'users-count', 'total-traffic-in', 'total-traffic-out', 'total-packets-in', +'total-mcast-packets-in', 'total-packets-out', 'total-mcast-packets-out', 'total-fail-packets-in', +'total-retry-packets-out'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'aps-count', 'users-count', 'total-traffic-in', 'total-traffic-out', 'total-packets-in', +'total-mcast-packets-in', 'total-packets-out', 'total-mcast-packets-out', 'total-fail-packets-in', +'total-retry-packets-out'. + +=back + +=cut + diff --git a/network/ruckus/scg/snmp/plugin.pm b/network/ruckus/scg/snmp/plugin.pm new file mode 100644 index 000000000..e620b3665 --- /dev/null +++ b/network/ruckus/scg/snmp/plugin.pm @@ -0,0 +1,60 @@ +# +# Copyright 2018 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::scg::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} = '1.0'; + %{$self->{modes}} = ( + 'ap-status' => 'network::ruckus::scg::snmp::mode::apstatus', + 'ap-usage' => 'network::ruckus::scg::snmp::mode::apusage', + 'cpu' => 'snmp_standard::mode::cpu', + 'cpu-detailed' => 'snmp_standard::mode::cpudetailed', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-aps' => 'network::ruckus::scg::snmp::mode::listaps', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'list-ssids' => 'network::ruckus::scg::snmp::mode::listssids', + 'load' => 'snmp_standard::mode::loadaverage', + 'memory' => 'snmp_standard::mode::memory', + 'ssid-usage' => 'network::ruckus::scg::snmp::mode::ssidusage', + 'system-stats' => 'network::ruckus::scg::snmp::mode::systemstats', + 'uptime' => 'snmp_standard::mode::uptime', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Ruckus SmartCell Gateway (SCG) in SNMP. + +=cut