From 4e3513ee8803de5245db4c7647624837e149f8e5 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 2 Dec 2020 14:59:07 +0100 Subject: [PATCH] add aruba aoscs snmp --- .../aruba/aoscx/snmp/mode/components/fan.pm | 103 ++++++ .../aoscx/snmp/mode/components/fantray.pm | 78 +++++ .../aruba/aoscx/snmp/mode/components/psu.pm | 103 ++++++ .../aoscx/snmp/mode/components/temperature.pm | 103 ++++++ network/aruba/aoscx/snmp/mode/hardware.pm | 107 ++++++ network/aruba/aoscx/snmp/mode/vsx.pm | 305 ++++++++++++++++++ network/aruba/aoscx/snmp/plugin.pm | 51 +++ 7 files changed, 850 insertions(+) create mode 100644 network/aruba/aoscx/snmp/mode/components/fan.pm create mode 100644 network/aruba/aoscx/snmp/mode/components/fantray.pm create mode 100644 network/aruba/aoscx/snmp/mode/components/psu.pm create mode 100644 network/aruba/aoscx/snmp/mode/components/temperature.pm create mode 100644 network/aruba/aoscx/snmp/mode/hardware.pm create mode 100644 network/aruba/aoscx/snmp/mode/vsx.pm create mode 100644 network/aruba/aoscx/snmp/plugin.pm diff --git a/network/aruba/aoscx/snmp/mode/components/fan.pm b/network/aruba/aoscx/snmp/mode/components/fan.pm new file mode 100644 index 000000000..980da5b76 --- /dev/null +++ b/network/aruba/aoscx/snmp/mode/components/fan.pm @@ -0,0 +1,103 @@ +# +# 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::aruba::aoscx::snmp::mode::components::fan; + +use strict; +use warnings; + +my $mapping = { + name => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.11.5.1.1.4' }, # arubaWiredFanName + state => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.11.5.1.1.5' }, # arubaWiredFanState + speed => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.11.5.1.1.8' } # arubaWiredFanRPM +}; +my $oid_arubaWiredFanEntry = '.1.3.6.1.4.1.47196.4.1.1.3.11.5.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_arubaWiredFanEntry, + start => $mapping->{name}->{oid}, + end => $mapping->{speed}->{oid} + }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking fans'); + $self->{components}->{fan} = { name => 'fans', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'fan')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_arubaWiredFanEntry}})) { + next if ($oid !~ /^$mapping->{state}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_arubaWiredFanEntry}, instance => $instance); + + next if ($self->check_filter(section => 'fan', instance => $instance, name => $result->{name})); + $self->{components}->{fan}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "fan '%s' status is %s [instance: %s, speed: %s]", + $result->{name}, + $result->{state}, + $instance, + $result->{speed} + ) + ); + my $exit = $self->get_severity(label => 'default', section => 'fan', value => $result->{state}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "fan '%s' status is %s", + $result->{name}, $result->{state} + ) + ); + } + + next if (!defined($result->{speed})); + + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan.speed', instance => $instance, name => $result->{name}, value => $result->{speed}); + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit2, + short_msg => sprintf( + "fan '%s' speed is %s rpm", + $result->{name}, + $result->{speed} + ) + ); + } + $self->{output}->perfdata_add( + unit => 'rpm', + nlabel => 'hardware.fan.speed.rpm', + instances => $result->{name}, + value => $result->{speed}, + warning => $warn, + critical => $crit, + min => 0 + ); + } +} + +1; diff --git a/network/aruba/aoscx/snmp/mode/components/fantray.pm b/network/aruba/aoscx/snmp/mode/components/fantray.pm new file mode 100644 index 000000000..4318f38a4 --- /dev/null +++ b/network/aruba/aoscx/snmp/mode/components/fantray.pm @@ -0,0 +1,78 @@ +# +# 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::aruba::aoscx::snmp::mode::components::fantray; + +use strict; +use warnings; + +my $mapping = { + name => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.11.4.1.1.3' }, # arubaWiredFanTrayName + state => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.11.4.1.1.4' } # arubaWiredFanTrayState +}; +my $oid_arubaWiredFanTrayEntry = '.1.3.6.1.4.1.47196.4.1.1.3.11.4.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_arubaWiredFanTrayEntry, + start => $mapping->{name}->{oid}, + end => $mapping->{state}->{oid} + }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking fan trays'); + $self->{components}->{fantray} = { name => 'fantray', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'fantray')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_arubaWiredFanTrayEntry}})) { + next if ($oid !~ /^$mapping->{state}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_arubaWiredFanTrayEntry}, instance => $instance); + + next if ($self->check_filter(section => 'fantray', instance => $instance, name => $result->{name})); + $self->{components}->{fantray}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "fan tray '%s' status is %s [instance: %s]", + $result->{name}, + $result->{state}, + $instance + ) + ); + my $exit = $self->get_severity(label => 'default', section => 'fantray', value => $result->{state}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "fan tray '%s' status is %s", + $result->{name}, $result->{state} + ) + ); + } + } +} + +1; diff --git a/network/aruba/aoscx/snmp/mode/components/psu.pm b/network/aruba/aoscx/snmp/mode/components/psu.pm new file mode 100644 index 000000000..fa3b8a29c --- /dev/null +++ b/network/aruba/aoscx/snmp/mode/components/psu.pm @@ -0,0 +1,103 @@ +# +# 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::aruba::aoscx::snmp::mode::components::psu; + +use strict; +use warnings; + +my $mapping = { + name => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.11.2.1.1.3' }, # arubaWiredPSUName + state => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.11.2.1.1.4' }, # arubaWiredPSUState + power => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.11.2.1.1.7' } # arubaWiredPSUInstantaneousPower +}; +my $oid_arubaWiredPowerSupplyEntry = '.1.3.6.1.4.1.47196.4.1.1.3.11.2.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_arubaWiredPowerSupplyEntry, + start => $mapping->{name}->{oid}, + end => $mapping->{power}->{oid} + }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking power supplies'); + $self->{components}->{psu} = { name => 'psu', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'psu')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_arubaWiredPowerSupplyEntry}})) { + next if ($oid !~ /^$mapping->{state}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_arubaWiredPowerSupplyEntry}, instance => $instance); + + next if ($self->check_filter(section => 'psu', instance => $instance, name => $result->{name})); + $self->{components}->{psu}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "power supply '%s' status is %s [instance: %s, power: %s W]", + $result->{name}, + $result->{state}, + $instance, + $result->{power} + ) + ); + my $exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{state}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "power supply '%s' status is %s", + $result->{name}, $result->{state} + ) + ); + } + + next if (!defined($result->{power}) || $result->{power} =~ /^0$/); + + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'psu.power', instance => $instance, name => $result->{name}, value => $result->{power}); + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit2, + short_msg => sprintf( + "power supply consumption '%s' is %s W", + $result->{name}, + $result->{power} + ) + ); + } + $self->{output}->perfdata_add( + unit => 'W', + nlabel => 'hardware.psu.power.watt', + instances => $result->{name}, + value => $result->{power}, + warning => $warn, + critical => $crit, + min => 0 + ); + } +} + +1; diff --git a/network/aruba/aoscx/snmp/mode/components/temperature.pm b/network/aruba/aoscx/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..3da71ca58 --- /dev/null +++ b/network/aruba/aoscx/snmp/mode/components/temperature.pm @@ -0,0 +1,103 @@ +# +# 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::aruba::aoscx::snmp::mode::components::temperature; + +use strict; +use warnings; + +my $mapping = { + name => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.11.3.1.1.5' }, # arubaWiredTempSensorName + state => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.11.3.1.1.6' }, # arubaWiredTempSensorState + temperature => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.11.3.1.1.7' } # arubaWiredTempSensorTemperature +}; +my $oid_arubaWiredTempSensorEntry = '.1.3.6.1.4.1.47196.4.1.1.3.11.3.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_arubaWiredTempSensorEntry, + start => $mapping->{name}->{oid}, + end => $mapping->{temperature}->{oid} + }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking temperatures'); + $self->{components}->{temperature} = { name => 'temperatures', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'temperature')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_arubaWiredTempSensorEntry}})) { + next if ($oid !~ /^$mapping->{state}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_arubaWiredTempSensorEntry}, instance => $instance); + + next if ($self->check_filter(section => 'temperature', instance => $instance, name => $result->{name})); + $self->{components}->{temperature}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "temperature '%s' status is %s [instance: %s, current: %s C]", + $result->{name}, + $result->{state}, + $instance, + $result->{temperature} + ) + ); + my $exit = $self->get_severity(label => 'default', section => 'temperature', value => $result->{state}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "temperature '%s' status is %s", + $result->{name}, $result->{state} + ) + ); + } + + next if (!defined($result->{temperature})); + + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, name => $result->{name}, value => $result->{temperature}); + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit2, + short_msg => sprintf( + "temperature '%s' is %s C", + $result->{name}, + $result->{temperature} + ) + ); + } + $self->{output}->perfdata_add( + unit => 'C', + nlabel => 'hardware.temperature.celsius', + instances => $result->{name}, + value => $result->{temperature}, + warning => $warn, + critical => $crit, + min => 0 + ); + } +} + +1; diff --git a/network/aruba/aoscx/snmp/mode/hardware.pm b/network/aruba/aoscx/snmp/mode/hardware.pm new file mode 100644 index 000000000..9ac20881f --- /dev/null +++ b/network/aruba/aoscx/snmp/mode/hardware.pm @@ -0,0 +1,107 @@ +# +# 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::aruba::aoscx::snmp::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_numeric_check_section_option} = '^(?:fan\.speed|temperature|psu\.power)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + default => [ + ['^ok$', 'OK'], + ['normal', 'OK'], + ['.*', 'CRITICAL'] + ] + }; + + $self->{components_path} = 'network::aruba::aoscx::snmp::mode::components'; + $self->{components_module} = ['psu', 'temperature', 'fan', 'fantray']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, force_new_perfdata => 1); + bless $self, $class; + + $options{options}->add_options(arguments => {}); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'psu', 'temperature', 'fan', 'fantry'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=psu) +Can also exclude specific instance: --filter=fan,1.1 + +=item B<--no-component> + +Return an error if no compenents are checked. +If total (with skipped) is 0. (Default: 'critical' returns). + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='fan,WARNING,string' + +=item B<--warning> + +Set warning threshold for 'temperature', 'fan.speed', 'psu.power' (syntax: section,[instance,]status,regexp) +Example: --warning='temperature,.*,30' --warning='fan.speed,.*,1000' + +=item B<--critical> + +Set critical threshold for 'temperature', 'fan.speed', 'psu.power' (syntax: section,[instance,]status,regexp) +Example: --critical='temperature,.*,40' + +=back + +=cut diff --git a/network/aruba/aoscx/snmp/mode/vsx.pm b/network/aruba/aoscx/snmp/mode/vsx.pm new file mode 100644 index 000000000..e4f1451fd --- /dev/null +++ b/network/aruba/aoscx/snmp/mode/vsx.pm @@ -0,0 +1,305 @@ +# +# 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::aruba::aoscx::snmp::mode::vsx; + +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_ng); + +sub custom_device_status_output { + my ($self, %options) = @_; + + return sprintf( + 'role: %s [config sync: %s]', + $self->{result_values}->{role}, + $self->{result_values}->{config_sync} + ); +} + +sub custom_isl_status_output { + my ($self, %options) = @_; + + return sprintf( + 'status: %s', + $self->{result_values}->{isl_status} + ); +} + +sub custom_keepalive_status_output { + my ($self, %options) = @_; + + return sprintf( + 'status: %s', + $self->{result_values}->{keepalive_status} + ); +} + +sub vsx_long_output { + my ($self, %options) = @_; + + return 'checking virtual switching extension'; +} + +sub prefix_vsx_output { + my ($self, %options) = @_; + + return 'Virtual switching extension '; +} + +sub prefix_isl_output { + my ($self, %options) = @_; + + return 'inter-switch link '; +} + +sub prefix_keepalive_output { + my ($self, %options) = @_; + + return 'keepalive '; +} + +sub prefix_device_output { + my ($self, %options) = @_; + + return 'device '; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'vsx', type => 3, cb_prefix_output => 'prefix_vsx_output', cb_long_output => 'vsx_long_output', indent_long_output => ' ', + group => [ + { name => 'device', type => 0, display_short => 0, cb_prefix_output => 'prefix_device_output', skipped_code => { -10 => 1 } }, + { name => 'isl', type => 0, display_short => 0, cb_prefix_output => 'prefix_isl_output', skipped_code => { -10 => 1 } }, + { name => 'keepalive', type => 0, display_short => 0, cb_prefix_output => 'prefix_keepalive_output', skipped_code => { -10 => 1 } } + ] + } + ]; + + $self->{maps_counters}->{device} = [ + { + label => 'device-status', + type => 2, + set => { + key_values => [ { name => 'role' }, { name => 'config_sync' } ], + closure_custom_output => $self->can('custom_device_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold_ng + } + } + ]; + + $self->{maps_counters}->{isl} = [ + { + label => 'isl-status', + type => 2, + critical_default => '%{isl_status} =~ /outSync/', + set => { + key_values => [ { name => 'isl_status' } ], + closure_custom_output => $self->can('custom_isl_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold_ng + } + }, + { label => 'isl-packets-in', nlabel => 'vsx.isl.packets.in.count', set => { + key_values => [ { name => 'isl_packets_in', diff => 1 } ], + output_template => 'packets in: %s', + perfdatas => [ + { template => '%s', min => 0 } + ] + } + }, + { label => 'isl-packets-out', nlabel => 'vsx.isl.packets.out.count', set => { + key_values => [ { name => 'isl_packets_in', diff => 1 } ], + output_template => 'packets out: %s', + perfdatas => [ + { template => '%s', min => 0 } + ] + } + } + ]; + + $self->{maps_counters}->{keepalive} = [ + { + label => 'keepalive-status', + type => 2, + critical_default => '%{keepalive_status} =~ /outofSyncEstablished|failed/', + set => { + key_values => [ { name => 'keepalive_status' } ], + closure_custom_output => $self->can('custom_keepalive_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold_ng + } + }, + { label => 'keepalive-packets-in', nlabel => 'vsx.keepalive.packets.in.count', set => { + key_values => [ { name => 'keepalive_packets_in', diff => 1 } ], + output_template => 'packets in: %s', + perfdatas => [ + { template => '%s', min => 0 } + ] + } + }, + { label => 'keepalive-packets-out', nlabel => 'vsx.keepalive.packets.out.count', set => { + key_values => [ { name => 'keepalive_packets_in', diff => 1 } ], + output_template => 'packets out: %s', + perfdatas => [ + { template => '%s', min => 0 } + ] + } + } + ]; +} + +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_role = { + 1 => 'primary', 2 => 'secondary', 3 => 'notConfigured' +}; +my $mapping_config_sync = { + 1 => 'enabled', 2 => 'disabled' +}; +my $mapping_isl_state = { + 1 => 'init', 2 => 'outSync', 3 => 'inSync' +}; +my $mapping_keepalive_state = { + 1 => 'init', 2 => 'configured', 3 => 'inSyncEstablished', + 4 => 'outofSyncEstablished', 5 => 'initEstablished', + 6 => 'failed', 7 => 'stopped' +}; + +my $mapping = { + role => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.7.1.4.1', map => $mapping_role }, # arubaWiredVsxDeviceRole + config_sync => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.7.1.4.2', map => $mapping_config_sync }, # arubaWiredVsxConfigSync + isl_status => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.7.2.1.1', map => $mapping_isl_state }, # arubaWiredVsxIslOperState + isl_packets_out => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.7.2.1.2' }, # arubaWiredVsxIslPduTx + isl_packets_in => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.7.2.1.3' }, # arubaWiredVsxIslPduRx + keepalive_status => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.7.2.2.1', map => $mapping_keepalive_state }, # arubaWiredVsxKeepAliveOperState + keepalive_packets_out => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.7.2.2.2' }, # arubaWiredVsxKeepAlivePacketsTx + keepalive_packets_in => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.7.2.2.3' } # arubaWiredVsxKeepAlivePacketsRx +}; + +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->{output}->output_add(short_msg => 'virtual switching extension is ok'); + + $self->{vsx} = { + global => { + device => { + role => $result->{role}, + config_sync => $result->{config_sync} + }, + isl => { + isl_status => $result->{isl_status}, + isl_packets_out => $result->{isl_packets_out}, + isl_packets_in => $result->{isl_packets_in} + }, + keepalive => { + keepalive_status => $result->{keepalive_status}, + keepalive_packets_out => $result->{keepalive_packets_out}, + keepalive_packets_in => $result->{keepalive_packets_in} + } + } + }; + + $self->{cache_name} = 'aruba_aoscx_' . $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')); +} + +1; + +__END__ + +=head1 MODE + +Check virtual switching extension. + +=over 8 + +=item B<--unknown-device-status> + +Set unknown threshold for status. +Can used special variables like: %{role}, %{config_sync} + +=item B<--warning-device-status> + +Set warning threshold for status. +Can used special variables like: %{role}, %{config_sync} + +=item B<--critical-device-status> + +Set critical threshold for status. +Can used special variables like: %{role}, %{config_sync} + +=item B<--unknown-isl-status> + +Set unknown threshold for status. +Can used special variables like: %{isl_status} + +=item B<--warning-isl-status> + +Set warning threshold for status. +Can used special variables like: %{isl_status} + +=item B<--critical-isl-status> + +Set critical threshold for status (Default: '%{isl_status} =~ /outSync/'). +Can used special variables like: %{isl_status} + +=item B<--unknown-keepalive-status> + +Set unknown threshold for status. +Can used special variables like: %{keepalive_status} + +=item B<--warning-keepalive-status> + +Set warning threshold for status. +Can used special variables like: %{keepalive_status} + +=item B<--critical-keepalive-status> + +Set critical threshold for status (Default: '%{keepalive_status} =~ /outofSyncEstablished|failed/'). +Can used special variables like: %{keepalive_status} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'isl-packets-in', 'isl-packets-out', 'keepalive-packets-in', 'keepalive-packets-out'. + +=back + +=cut diff --git a/network/aruba/aoscx/snmp/plugin.pm b/network/aruba/aoscx/snmp/plugin.pm new file mode 100644 index 000000000..853949753 --- /dev/null +++ b/network/aruba/aoscx/snmp/plugin.pm @@ -0,0 +1,51 @@ +# +# 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::aruba::aoscx::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}} = ( + 'hardware' => 'network::aruba::aoscx::snmp::mode::hardware', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'vsx' => 'network::aruba::aoscx::snmp::mode::vsx' + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Aruba CX series in SNMP. + +=cut