From ae7e30c0b4335315ba326653ce65944c53edf08e Mon Sep 17 00:00:00 2001 From: qgarnier Date: Fri, 31 Dec 2021 13:33:56 +0100 Subject: [PATCH] add(plugin): dell omem snmp (#3359) --- .../dell/omem/snmp/mode/components/chassis.pm | 82 +++++++++++ .../dell/omem/snmp/mode/components/health.pm | 87 ++++++++++++ .../dell/omem/snmp/mode/components/psu.pm | 86 +++++++++++ .../omem/snmp/mode/components/temperature.pm | 75 ++++++++++ .../server/dell/omem/snmp/mode/hardware.pm | 134 ++++++++++++++++++ .../hardware/server/dell/omem/snmp/plugin.pm | 48 +++++++ 6 files changed, 512 insertions(+) create mode 100644 centreon-plugins/hardware/server/dell/omem/snmp/mode/components/chassis.pm create mode 100644 centreon-plugins/hardware/server/dell/omem/snmp/mode/components/health.pm create mode 100644 centreon-plugins/hardware/server/dell/omem/snmp/mode/components/psu.pm create mode 100644 centreon-plugins/hardware/server/dell/omem/snmp/mode/components/temperature.pm create mode 100644 centreon-plugins/hardware/server/dell/omem/snmp/mode/hardware.pm create mode 100644 centreon-plugins/hardware/server/dell/omem/snmp/plugin.pm diff --git a/centreon-plugins/hardware/server/dell/omem/snmp/mode/components/chassis.pm b/centreon-plugins/hardware/server/dell/omem/snmp/mode/components/chassis.pm new file mode 100644 index 000000000..800b0d903 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/omem/snmp/mode/components/chassis.pm @@ -0,0 +1,82 @@ +# +# Copyright 2021 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 hardware::server::dell::omem::snmp::mode::components::chassis; + +use strict; +use warnings; + +my $mapping = { + wattsReading => { oid => '.1.3.6.1.4.1.674.10892.6.4.1.1.9' } # dmmPowerWattsReading +}; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $mapping->{wattsReading}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking chassis"); + $self->{components}->{chassis} = {name => 'chassis', total => 0, skip => 0}; + return if ($self->check_filter(section => 'chassis')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $mapping->{wattsReading}->{oid} }})) { + $oid =~ /^$mapping->{wattsReading}->{oid}\.(.*)$/; + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{ $mapping->{wattsReading}->{oid} }, instance => $instance); + + next if ($self->check_filter(section => 'chassis', instance => $instance)); + $self->{components}->{chassis}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "chassis '%s' power %s W [instance: %s]", + $instance, + $result->{wattsReading}, + $instance + ) + ); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'chassis.power', instance => $instance, value => $result->{wattsReading}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "chassis '%s' power is %s W", + $instance, + $result->{wattsReading} + ) + ); + } + $self->{output}->perfdata_add( + nlabel => 'hardware.chassis.power.watt', + unit => 'W', + instances => $instance, + value => $result->{wattsReading}, + warning => $warn, + critical => $crit + ); + } +} + +1; diff --git a/centreon-plugins/hardware/server/dell/omem/snmp/mode/components/health.pm b/centreon-plugins/hardware/server/dell/omem/snmp/mode/components/health.pm new file mode 100644 index 000000000..d979aab15 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/omem/snmp/mode/components/health.pm @@ -0,0 +1,87 @@ +# +# Copyright 2021 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 hardware::server::dell::omem::snmp::mode::components::health; + +use strict; +use warnings; + +my %map_health_status = ( + 1 => 'other', + 2 => 'unknown', + 3 => 'ok', + 4 => 'nonCritical', + 5 => 'critical', + 6 => 'nonRecoverable' +); + +my $mapping = { + IOMCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.6.3.1.1', map => \%map_health_status, descr => 'IOM' }, + redCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.6.3.1.2', map => \%map_health_status, descr => 'redundancy' }, + powerCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.6.3.1.3', map => \%map_health_status, descr => 'power' }, + fanCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.6.3.1.4', map => \%map_health_status, descr => 'fan' }, + bladeCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.6.3.1.5', map => \%map_health_status, descr => 'blade' }, + tempCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.6.3.1.6', map => \%map_health_status, descr => 'temperature' }, + MMCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.6.3.1.7', map => \%map_health_status, descr => 'management module' } +}; +my $oid_dmmStatusNowGroup = '.1.3.6.1.4.1.674.10892.6.3.1'; + +sub load {} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking health"); + $self->{components}->{health} = { name => 'health', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'health')); + + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_dmmStatusNowGroup}, instance => 0); + foreach my $probe (sort keys %$mapping) { + next if (!defined($result->{$probe})); + + $mapping->{$probe}->{oid} =~ /\.(\d+)$/; + my $instance = $1; + + next if ( $self->check_filter(section => 'health', instance => $instance)); + $self->{components}->{health}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "%s status is %s [instance: %s]", + $mapping->{$probe}->{descr}, + $result->{$probe}, + $instance + ) + ); + + my $exit = $self->get_severity(label => 'default', section => 'health', value => $result->{$probe}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("%s status is %s", + $mapping->{$probe}->{descr}, + $result->{$probe} + ) + ); + } + } +} + +1; diff --git a/centreon-plugins/hardware/server/dell/omem/snmp/mode/components/psu.pm b/centreon-plugins/hardware/server/dell/omem/snmp/mode/components/psu.pm new file mode 100644 index 000000000..138e386ef --- /dev/null +++ b/centreon-plugins/hardware/server/dell/omem/snmp/mode/components/psu.pm @@ -0,0 +1,86 @@ +# +# Copyright 2021 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 hardware::server::dell::omem::snmp::mode::components::psu; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'other', + 2 => 'unknown', + 3 => 'ok', + 4 => 'nonCritical', + 5 => 'critical', + 6 => 'nonRecoverable' +); + +my $mapping = { + dmmPSULocation => { oid => '.1.3.6.1.4.1.674.10892.6.4.2.1.3' }, + dmmPSUCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.6.4.2.1.8', map => \%map_status } +}; +my $oid_dmmPSUTableEntry = '.1.3.6.1.4.1.674.10892.6.4.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_dmmPSUTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking power supplies"); + $self->{components}->{psu} = {name => 'psus', total => 0, skip => 0}; + + return if ($self->check_filter(section => 'psu')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_dmmPSUTableEntry}})) { + next if ($oid !~ /^$mapping->{dmmPSUCurrStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_dmmPSUTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'psu', instance => $instance)); + $self->{components}->{psu}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "power supply '%s' status is %s [instance: %s]", + $result->{dmmPSULocation}, + $result->{dmmPSUCurrStatus}, + $instance + ) + ); + + my $exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{dmmPSUCurrStatus}); + 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->{dmmPSULocation}, + $result->{dmmPSUCurrStatus} + ) + ); + } + } +} + +1; diff --git a/centreon-plugins/hardware/server/dell/omem/snmp/mode/components/temperature.pm b/centreon-plugins/hardware/server/dell/omem/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..4f8aafff2 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/omem/snmp/mode/components/temperature.pm @@ -0,0 +1,75 @@ +# +# Copyright 2021 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 hardware::server::dell::omem::snmp::mode::components::temperature; + +use strict; +use warnings; + +my $mapping = { + dmmChassisFrontPanelAmbientTemperature => { oid => '.1.3.6.1.4.1.674.10892.6.3.1.8', instance => 'chassis', descr => 'chassis ambient temperature' } +}; +my $oid_dmmStatusNowGroup = '.1.3.6.1.4.1.674.10892.6.3.1'; + +sub load {} + +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')); + + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_dmmStatusNowGroup}, instance => 0); + foreach my $probe (keys %$mapping) { + next if (!defined($result->{$probe})); + + next if ($self->check_filter(section => 'temperature', instance => $mapping->{$probe}->{instance})); + $self->{components}->{temperature}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "%s is %dC [instance: %s]", + $mapping->{$probe}->{descr}, $result->{$probe}, + $mapping->{$probe}->{instance} + ) + ); + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $mapping->{$probe}->{instance}, value => $result->{$probe}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("%s is %sC", + $mapping->{$probe}->{descr}, + $result->{$probe} + ) + ); + } + $self->{output}->perfdata_add( + nlabel => 'hardware.temperature.celsius', + unit => 'C', + instances => $mapping->{$probe}->{instance}, + value => $result->{$probe}, + warning => $warn, + critical => $crit + ); + } +} + +1; diff --git a/centreon-plugins/hardware/server/dell/omem/snmp/mode/hardware.pm b/centreon-plugins/hardware/server/dell/omem/snmp/mode/hardware.pm new file mode 100644 index 000000000..b293e491d --- /dev/null +++ b/centreon-plugins/hardware/server/dell/omem/snmp/mode/hardware.pm @@ -0,0 +1,134 @@ +# +# Copyright 2021 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 hardware::server::dell::omem::snmp::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; +use centreon::plugins::misc; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_numeric_check_section_option} = '^(?:temperature|psu\.(voltage|power|current)|chassis\.(power|current))$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + default => [ + [ 'other', 'UNKNOWN' ], + [ 'unknown', 'UNKNOWN' ], + [ 'ok', 'OK' ], + [ 'nonCritical', 'WARNING' ], + [ 'critical', 'CRITICAL' ], + [ 'nonRecoverable', 'CRITICAL' ] + ] + }; + + $self->{components_path} = 'hardware::server::dell::omem::snmp::mode::components'; + $self->{components_module} = ['chassis', 'health', 'psu', 'temperature']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->display_system_information(); + + push @{$self->{request}}, { oid => '.1.3.6.1.4.1.674.10892.6.3.1' }; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + +sub display_system_information { + my ($self, %options) = @_; + + my $oid_dmmProductShortName = '.1.3.6.1.4.1.674.10892.6.1.1.2.0'; + my $oid_dmmChassisServiceTag = '.1.3.6.1.4.1.674.10892.6.1.1.6.0'; + my $oid_dmmFirmwareVersion = '.1.3.6.1.4.1.674.10892.6.1.2.1.0'; + my $oid_dmmFirmwareVersion2 = '.1.3.6.1.4.1.674.10892.6.1.2.2.0'; + + my $snmp_result = $self->{snmp}->get_leef(oids => [$oid_dmmProductShortName, $oid_dmmChassisServiceTag, $oid_dmmFirmwareVersion, $oid_dmmFirmwareVersion2]); + $self->{output}->output_add( + long_msg => sprintf( + "Product Name: %s, Service Tag: %s, Firmware Version of MM1: %s, Firmware Version of MM2: %s", + defined($snmp_result->{$oid_dmmProductShortName}) ? centreon::plugins::misc::trim($snmp_result->{$oid_dmmProductShortName}) : 'unknown', + defined($snmp_result->{$oid_dmmChassisServiceTag}) ? $snmp_result->{$oid_dmmChassisServiceTag} : 'unknown', + defined($snmp_result->{$oid_dmmFirmwareVersion}) ? $snmp_result->{$oid_dmmFirmwareVersion} : 'unknown', + defined($snmp_result->{$oid_dmmFirmwareVersion2}) ? $snmp_result->{$oid_dmmFirmwareVersion2} : 'unknown' + ) + ); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + bless $self, $class; + + $options{options}->add_options(arguments => {}); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check hardware (health, temperatures, power supplies metrics and chassis metrics). + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'health', 'temperature', 'chassis', 'psu'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=fan) +Can also exclude specific instance: --filter=health,2 + +=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='health,CRITICAL,^(?!(ok)$)' + +=item B<--warning> + +Set warning threshold for temperature (syntax: type,regexp,threshold) +Example: --warning='temperature,.*,30' + +=item B<--critical> + +Set critical threshold for temperature (syntax: type,regexp,threshold) +Example: --critical='temperature,.*,40' + +=back + +=cut diff --git a/centreon-plugins/hardware/server/dell/omem/snmp/plugin.pm b/centreon-plugins/hardware/server/dell/omem/snmp/plugin.pm new file mode 100644 index 000000000..42cc6f99f --- /dev/null +++ b/centreon-plugins/hardware/server/dell/omem/snmp/plugin.pm @@ -0,0 +1,48 @@ +# +# Copyright 2021 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 hardware::server::dell::omem::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->{modes} = { + 'hardware' => 'hardware::server::dell::omem::snmp::mode::hardware', + 'uptime' => 'snmp_standard::mode::uptime' + }; + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Dell OpenManage Enterprise Modular in SNMP (Dell MX7000). + +=cut