From 5eabb2d09d9240aaf5ff1c1fe0510c9f40b87bba Mon Sep 17 00:00:00 2001 From: christophe-activiumid <79632125+christophe-activiumid@users.noreply.github.com> Date: Wed, 9 Nov 2022 11:42:28 +0100 Subject: [PATCH] Add xFusion iBMC snmp monitoring (#4043) --- .../ibmc/snmp/mode/components/component.pm | 86 ++++++++++++ .../xfusion/ibmc/snmp/mode/components/cpu.pm | 79 +++++++++++ .../xfusion/ibmc/snmp/mode/components/fan.pm | 102 ++++++++++++++ .../ibmc/snmp/mode/components/harddisk.pm | 106 ++++++++++++++ .../ibmc/snmp/mode/components/logicaldrive.pm | 80 +++++++++++ .../ibmc/snmp/mode/components/memory.pm | 79 +++++++++++ .../xfusion/ibmc/snmp/mode/components/pcie.pm | 86 ++++++++++++ .../xfusion/ibmc/snmp/mode/components/psu.pm | 108 +++++++++++++++ .../snmp/mode/components/raidcontroller.pm | 99 +++++++++++++ .../ibmc/snmp/mode/components/temperature.pm | 78 +++++++++++ .../server/xfusion/ibmc/snmp/mode/hardware.pm | 130 ++++++++++++++++++ .../server/xfusion/ibmc/snmp/plugin.pm | 48 +++++++ 12 files changed, 1081 insertions(+) create mode 100644 centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/component.pm create mode 100644 centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/cpu.pm create mode 100644 centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/fan.pm create mode 100644 centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/harddisk.pm create mode 100644 centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/logicaldrive.pm create mode 100644 centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/memory.pm create mode 100644 centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/pcie.pm create mode 100644 centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/psu.pm create mode 100644 centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/raidcontroller.pm create mode 100644 centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/temperature.pm create mode 100644 centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/hardware.pm create mode 100644 centreon-plugins/hardware/server/xfusion/ibmc/snmp/plugin.pm diff --git a/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/component.pm b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/component.pm new file mode 100644 index 000000000..902ce3f57 --- /dev/null +++ b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/component.pm @@ -0,0 +1,86 @@ +# +# Copyright 2022 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::xfusion::ibmc::snmp::mode::components::component; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'ok', + 2 => 'minor', + 3 => 'major', + 4 => 'critical', + 5 => 'absence', + 6 => 'unknown', +); + +my %map_type = ( + 1 => 'baseBoard', + 2 => 'mezzCard', + 3 => 'amcController', + 4 => 'mmcController', + 5 => 'hddBackPlane', + 6 => 'raidCard', +); + +my $mapping = { + componentName => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.10.50.1.1' }, + componentType => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.10.50.1.2', map => \%map_type }, + componentStatus => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.10.50.1.5', map => \%map_status }, +}; +my $oid_componentDescriptionEntry = '.1.3.6.1.4.1.58132.2.235.1.1.10.50.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_componentDescriptionEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking component"); + $self->{components}->{component} = {name => 'components', total => 0, skip => 0}; + return if ($self->check_filter(section => 'component')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_componentDescriptionEntry}})) { + next if ($oid !~ /^$mapping->{componentStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_componentDescriptionEntry}, instance => $instance); + + next if ($self->check_filter(section => 'component', instance => $instance)); + next if ($result->{componentStatus} =~ /absence/); + $self->{components}->{component}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Component '%s' of type '%s' status is '%s' [instance = %s]", + $result->{componentName}, $result->{componentType}, $result->{componentStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'component', value => $result->{componentStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Component '%s' of type '%s' status is '%s'", + $result->{componentName}, $result->{componentType}, $result->{componentStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/cpu.pm b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/cpu.pm new file mode 100644 index 000000000..5e5115210 --- /dev/null +++ b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/cpu.pm @@ -0,0 +1,79 @@ +# +# Copyright 2022 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::xfusion::ibmc::snmp::mode::components::cpu; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'ok', + 2 => 'minor', + 3 => 'major', + 4 => 'critical', + 5 => 'absence', + 6 => 'unknown', +); + +my $mapping = { + cpuStatus => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.15.50.1.6', map => \%map_status }, + cpuDevicename => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.15.50.1.10' }, +}; +my $oid_cpuDescriptionEntry = '.1.3.6.1.4.1.58132.2.235.1.1.15.50.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_cpuDescriptionEntry, + start => $mapping->{cpuStatus}->{oid}, + end => $mapping->{cpuDevicename}->{oid}, + }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking CPU"); + $self->{components}->{cpu} = {name => 'cpu', total => 0, skip => 0}; + return if ($self->check_filter(section => 'cpu')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cpuDescriptionEntry}})) { + next if ($oid !~ /^$mapping->{cpuStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cpuDescriptionEntry}, instance => $instance); + + next if ($self->check_filter(section => 'cpu', instance => $instance)); + next if ($result->{cpuStatus} =~ /absence/); + $self->{components}->{cpu}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Cpu '%s' status is '%s' [instance = %s]", + $result->{cpuDevicename}, $result->{cpuStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'cpu', value => $result->{cpuStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Cpu '%s' status is '%s'", $result->{cpuDevicename}, $result->{cpuStatus})); + } + } +} + +1; diff --git a/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/fan.pm b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/fan.pm new file mode 100644 index 000000000..d9978e3b4 --- /dev/null +++ b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/fan.pm @@ -0,0 +1,102 @@ +# +# Copyright 2022 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::xfusion::ibmc::snmp::mode::components::fan; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'ok', + 2 => 'minor', + 3 => 'major', + 4 => 'critical', + 5 => 'absence', + 6 => 'unknown', +); + +my %map_installation_status = ( + 1 => 'absence', + 2 => 'presence', + 3 => 'unknown', +); + +my $mapping = { + fanSpeed => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.8.50.1.2' }, + fanPresence => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.8.50.1.3', map => \%map_installation_status }, + fanStatus => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.8.50.1.4', map => \%map_status }, + fanDevicename => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.8.50.1.7' }, +}; +my $oid_fanDescriptionEntry = '.1.3.6.1.4.1.58132.2.235.1.1.8.50.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_fanDescriptionEntry }; +} + +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_fanDescriptionEntry}})) { + next if ($oid !~ /^$mapping->{fanStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_fanDescriptionEntry}, instance => $instance); + + next if ($self->check_filter(section => 'fan', instance => $instance)); + next if ($result->{fanPresence} !~ /presence/); + $self->{components}->{fan}->{total}++; + + if (defined($result->{fanSpeed}) && $result->{fanSpeed} =~ /[0-9]/) { + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $result->{fanSpeed}); + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Fan '%s' speed is %s RPM", $result->{fanDevicename}, $result->{fanSpeed})); + } + + $self->{output}->perfdata_add( + label => 'speed', unit => 'rpm', + nlabel => 'hardware.fan.speed.rpm', + instances => $result->{fanDevicename}, + value => $result->{fanSpeed}, + warning => $warn, + critical => $crit, + min => 0 + ); + } + + $self->{output}->output_add(long_msg => sprintf("Fan '%s' status is '%s' [instance = %s]", + $result->{fanDevicename}, $result->{fanStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'fan', value => $result->{fanStatus}); + 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->{fanDevicename}, $result->{fanStatus})); + } + } +} + +1; diff --git a/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/harddisk.pm b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/harddisk.pm new file mode 100644 index 000000000..bd067f82f --- /dev/null +++ b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/harddisk.pm @@ -0,0 +1,106 @@ +# +# Copyright 2022 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::xfusion::ibmc::snmp::mode::components::harddisk; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'ok', + 2 => 'minor', + 3 => 'major', + 4 => 'critical', + 5 => 'absence', + 6 => 'unknown', +); + +my %map_installation_status = ( + 1 => 'absence', + 2 => 'presence', + 3 => 'unknown', +); + +my $mapping = { + hardDiskPresence => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.18.50.1.2', map => \%map_installation_status }, + hardDiskStatus => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.18.50.1.3', map => \%map_status }, + hardDiskDevicename => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.18.50.1.6' }, + hardDiskTemperature => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.18.50.1.20' }, +}; +my $oid_hardDiskDescriptionEntry = '.1.3.6.1.4.1.58132.2.235.1.1.18.50.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_hardDiskDescriptionEntry, + start => $mapping->{hardDiskPresence}->{oid}, + end => $mapping->{hardDiskTemperature}->{oid}, + }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking hard disks"); + $self->{components}->{harddisk} = {name => 'hard disks', total => 0, skip => 0}; + return if ($self->check_filter(section => 'harddisk')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_hardDiskDescriptionEntry}})) { + next if ($oid !~ /^$mapping->{hardDiskStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_hardDiskDescriptionEntry}, instance => $instance); + + next if ($self->check_filter(section => 'harddisk', instance => $instance)); + next if ($result->{hardDiskPresence} !~ /presence/); + $self->{components}->{harddisk}->{total}++; + + if (defined($result->{hardDiskTemperature}) && $result->{hardDiskTemperature} =~ /[0-9]/) { + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'harddisk', instance => $instance, value => $result->{hardDiskTemperature}); + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Hard Disk '%s' temperature is %s celsius degrees", $result->{hardDiskDevicename}, $result->{hardDiskTemperature})); + } + + $self->{output}->perfdata_add( + label => 'temperature', unit => 'C', + nlabel => 'hardware.harddisk.temperature.celsius', + instances => $result->{hardDiskDevicename}, + value => $result->{hardDiskTemperature}, + warning => $warn, + critical => $crit, + min => 0 + ); + } + + $self->{output}->output_add(long_msg => sprintf("Hard disk '%s' status is '%s' [instance = %s]", + $result->{hardDiskDevicename}, $result->{hardDiskStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'harddisk', value => $result->{hardDiskStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Hard disk '%s' status is '%s'", $result->{hardDiskDevicename}, $result->{hardDiskStatus})); + } + } +} + +1; diff --git a/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/logicaldrive.pm b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/logicaldrive.pm new file mode 100644 index 000000000..5f15c131a --- /dev/null +++ b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/logicaldrive.pm @@ -0,0 +1,80 @@ +# +# Copyright 2022 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::xfusion::ibmc::snmp::mode::components::logicaldrive; + +use strict; +use warnings; + +my %map_state = ( + 1 => 'offline', + 2 => 'partial degraded', + 3 => 'degraded', + 4 => 'optimal', + 255 => 'unknown', +); + +my $mapping = { + logicalDriveRAIDControllerIndex => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.37.50.1.1' }, + logicalDriveIndex => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.37.50.1.2' }, + logicalDriveState => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.37.50.1.4', map => \%map_state }, +}; +my $oid_logicalDriveDescriptionEntry = '.1.3.6.1.4.1.58132.2.235.1.1.37.50.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_logicalDriveDescriptionEntry, + end => $mapping->{logicalDriveState}->{oid}, + }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking logical drives"); + $self->{components}->{logicaldrive} = {name => 'logical drives', total => 0, skip => 0}; + return if ($self->check_filter(section => 'logicaldrive')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_logicalDriveDescriptionEntry}})) { + next if ($oid !~ /^$mapping->{logicalDriveState}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_logicalDriveDescriptionEntry}, instance => $instance); + + next if ($self->check_filter(section => 'logicaldrive', instance => $instance)); + $self->{components}->{logicaldrive}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Logical drive '%s.%s' status is '%s' [instance = %s]", + $result->{logicalDriveRAIDControllerIndex}, $result->{logicalDriveIndex}, $result->{logicalDriveState}, $instance, + )); + + my $exit = $self->get_severity(section => 'logicaldrive', value => $result->{logicalDriveState}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Logical drive '%s.%s' status is '%s'", + $result->{logicalDriveRAIDControllerIndex}, + $result->{logicalDriveIndex}, + $result->{logicalDriveState})); + } + } +} + +1; diff --git a/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/memory.pm b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/memory.pm new file mode 100644 index 000000000..2c6e8ccbb --- /dev/null +++ b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/memory.pm @@ -0,0 +1,79 @@ +# +# Copyright 2022 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::xfusion::ibmc::snmp::mode::components::memory; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'ok', + 2 => 'minor', + 3 => 'major', + 4 => 'critical', + 5 => 'absence', + 6 => 'unknown', +); + +my $mapping = { + memoryStatus => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.16.50.1.6', map => \%map_status }, + memoryDevicename => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.16.50.1.10' }, +}; +my $oid_memoryDescriptionEntry = '.1.3.6.1.4.1.58132.2.235.1.1.16.50.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_memoryDescriptionEntry, + start => $mapping->{memoryStatus}->{oid}, + end => $mapping->{memoryDevicename}->{oid}, + }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking memory"); + $self->{components}->{memory} = {name => 'memorys', total => 0, skip => 0}; + return if ($self->check_filter(section => 'memory')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_memoryDescriptionEntry}})) { + next if ($oid !~ /^$mapping->{memoryStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_memoryDescriptionEntry}, instance => $instance); + + next if ($self->check_filter(section => 'memory', instance => $instance)); + next if ($result->{memoryStatus} =~ /absence/); + $self->{components}->{memory}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Memory '%s' status is '%s' [instance = %s]", + $result->{memoryDevicename}, $result->{memoryStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'memory', value => $result->{memoryStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Memory '%s' status is '%s'", $result->{memoryDevicename}, $result->{memoryStatus})); + } + } +} + +1; diff --git a/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/pcie.pm b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/pcie.pm new file mode 100644 index 000000000..9f787c155 --- /dev/null +++ b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/pcie.pm @@ -0,0 +1,86 @@ +# +# Copyright 2022 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::xfusion::ibmc::snmp::mode::components::pcie; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'ok', + 2 => 'minor', + 3 => 'major', + 4 => 'critical', + 5 => 'absence', + 6 => 'unknown', +); + +my %map_installation_status = ( + 1 => 'absence', + 2 => 'presence', + 3 => 'unknown', +); + +my $mapping = { + pCIePresence => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.24.50.1.2', map => \%map_installation_status }, + pCIeStatus => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.24.50.1.3', map => \%map_status }, + pCIeDevicename => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.24.50.1.7' }, +}; +my $oid_pCIeDescriptionEntry = '.1.3.6.1.4.1.58132.2.235.1.1.24.50.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_pCIeDescriptionEntry, + start => $mapping->{pCIePresence}->{oid}, + end => $mapping->{pCIeDevicename}->{oid}, + }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking PCIe"); + $self->{components}->{pcie} = {name => 'pcie', total => 0, skip => 0}; + return if ($self->check_filter(section => 'pcie')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_pCIeDescriptionEntry}})) { + next if ($oid !~ /^$mapping->{pCIeStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_pCIeDescriptionEntry}, instance => $instance); + + next if ($self->check_filter(section => 'pcie', instance => $instance)); + next if ($result->{pCIePresence} !~ /presence/); + $self->{components}->{pcie}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("PCIe '%s' status is '%s' [instance = %s]", + $result->{pCIeDevicename}, $result->{pCIeStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'pcie', value => $result->{pCIeStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("PCIe '%s' status is '%s'", $result->{pCIeDevicename}, $result->{pCIeStatus})); + } + } +} + +1; diff --git a/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/psu.pm b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/psu.pm new file mode 100644 index 000000000..162ea57b5 --- /dev/null +++ b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/psu.pm @@ -0,0 +1,108 @@ +# +# Copyright 2022 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::xfusion::ibmc::snmp::mode::components::psu; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'ok', + 2 => 'minor', + 3 => 'major', + 4 => 'critical', + 5 => 'absence', + 6 => 'unknown', +); + +my %map_installation_status = ( + 1 => 'absence', + 2 => 'presence', + 3 => 'unknown', +); + +my $mapping = { + powerSupplyPowerRating => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.6.50.1.6' }, + powerSupplyStatus => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.6.50.1.7', map => \%map_status }, + powerSupplyInputPower => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.6.50.1.8' }, + powerSupplyPresence => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.6.50.1.9', map => \%map_installation_status }, + powerSupplyDevicename => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.6.50.1.13' }, +}; +my $oid_powerSupplyDescriptionEntry = '.1.3.6.1.4.1.58132.2.235.1.1.6.50.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_powerSupplyDescriptionEntry, + start => $mapping->{powerSupplyPowerRating}->{oid}, + }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking power supplies"); + $self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0}; + return if ($self->check_filter(section => 'psu')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_powerSupplyDescriptionEntry}})) { + next if ($oid !~ /^$mapping->{powerSupplyStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_powerSupplyDescriptionEntry}, instance => $instance); + + next if ($self->check_filter(section => 'psu', instance => $instance)); + next if ($result->{powerSupplyPresence} !~ /presence/); + $self->{components}->{psu}->{total}++; + + if (defined($result->{powerSupplyInputPower}) && $result->{powerSupplyInputPower} =~ /[0-9]/ && + defined($result->{powerSupplyPowerRating}) && $result->{powerSupplyPowerRating} =~ /[0-9]/) { + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'psu', instance => $instance, value => $result->{powerSupplyInputPower}); + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Power supply '%s' power is %s watts", $result->{powerSupplyDevicename}, $result->{powerSupplyInputPower})); + } + + $self->{output}->perfdata_add( + label => 'power', unit => 'W', + nlabel => 'hardware.powersupply.power.watt', + instances => $result->{powerSupplyDevicename}, + value => $result->{powerSupplyInputPower}, + warning => $warn, + critical => $crit, + min => 0, + max => $result->{powerSupplyPowerRating} + ); + } + + $self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is '%s' [instance = %s]", + $result->{powerSupplyDevicename}, $result->{powerSupplyStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{powerSupplyStatus}); + 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->{powerSupplyDevicename}, $result->{powerSupplyStatus})); + } + } +} + +1; diff --git a/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/raidcontroller.pm b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/raidcontroller.pm new file mode 100644 index 000000000..9d7fa33b0 --- /dev/null +++ b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/raidcontroller.pm @@ -0,0 +1,99 @@ +# +# Copyright 2022 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::xfusion::ibmc::snmp::mode::components::raidcontroller; + +use strict; +use warnings; + +my $mapping = { + raidControllerComponentName => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.36.50.1.4' }, + raidControllerHealthStatus => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.36.50.1.7' }, +}; +my $oid_raidControllerDescriptionEntry = '.1.3.6.1.4.1.58132.2.235.1.1.36.50.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_raidControllerDescriptionEntry, + start => $mapping->{raidControllerComponentName}->{oid}, + end => $mapping->{raidControllerHealthStatus}->{oid}, + }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking raid controllers"); + $self->{components}->{raidcontroller} = {name => 'raidcontrollers', total => 0, skip => 0}; + return if ($self->check_filter(section => 'raidcontroller')); + + my %bitmap_status = ( + 0 => 'memory correctable error', + 1 => 'memory uncorrectable error', + 2 => 'memory ECC error reached limit', + 3 => 'NVRAM uncorrectable error', + ); + my %map_status = ( + 0 => 'ok', + 65535 => 'unknown', + ); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_raidControllerDescriptionEntry}})) { + next if ($oid !~ /^$mapping->{raidControllerHealthStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_raidControllerDescriptionEntry}, instance => $instance); + + next if ($self->check_filter(section => 'raidcontroller', instance => $instance)); + $self->{components}->{raidcontroller}->{total}++; + + if (defined($map_status{$result->{raidControllerHealthStatus}})) { + $self->{output}->output_add(long_msg => sprintf("Raid controller '%s' status is '%s' [instance = %s]", + $result->{raidControllerComponentName}, $map_status{$result->{raidControllerHealthStatus}}, $instance, + )); + + my $exit = $self->get_severity(section => 'raidcontroller', value => $map_status{$result->{raidControllerHealthStatus}}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Raid controller '%s' status is '%s'", $result->{raidControllerComponentName}, $map_status{$result->{raidControllerHealthStatus}})); + } + + next; + } + + for (my $i = 0; $i < 4; $i++) { + next if (!($result->{raidControllerHealthStatus} & (1 << $i))); + + my $status = $bitmap_status{$i}; + $self->{output}->output_add(long_msg => sprintf("Raid controller '%s' status is '%s' [instance = %s]", + $result->{raidControllerComponentName}, $status, $instance, + )); + + my $exit = $self->get_severity(section => 'raidcontroller', value => $status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Raid controller '%s' status is '%s'", $result->{raidControllerComponentName}, $status)); + } + } + } +} + +1; diff --git a/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/temperature.pm b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..d263330a5 --- /dev/null +++ b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/components/temperature.pm @@ -0,0 +1,78 @@ +# +# Copyright 2022 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::xfusion::ibmc::snmp::mode::components::temperature; + +use strict; +use warnings; + +my $mapping = { + temperatureObject => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.26.50.1.2' }, + temperatureReading => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.26.50.1.3' }, +}; +my $oid_temperatureDescriptionEntry = '.1.3.6.1.4.1.58132.2.235.1.1.26.50.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_temperatureDescriptionEntry, + start => $mapping->{temperatureObject}->{oid}, + end => $mapping->{temperatureReading}->{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_temperatureDescriptionEntry}})) { + next if ($oid !~ /^$mapping->{temperatureReading}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_temperatureDescriptionEntry}, instance => $instance); + + next if ($self->check_filter(section => 'temperature', instance => $instance)); + next if ($result->{temperatureReading} == 65535); + $self->{components}->{temperature}->{total}++; + $self->{output}->output_add(long_msg => sprintf("Temperature of '%s' is '%s' celsius degrees [instance = %s]", + $result->{temperatureObject}, $result->{temperatureReading} / 10, $instance, + )); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{temperatureReading} / 10); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Temperature of '%s' is '%s' celsius degrees", $result->{temperatureObject}, $result->{temperatureReading} / 10)); + } + + $self->{output}->perfdata_add( + label => 'temperature', unit => 'C', + nlabel => 'hardware.temperature.celsius', + instances => $result->{temperatureObject}, + value => $result->{temperatureReading} / 10, + warning => $warn, + critical => $crit + ); + } +} + +1; diff --git a/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/hardware.pm b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/hardware.pm new file mode 100644 index 000000000..c25cafeff --- /dev/null +++ b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/mode/hardware.pm @@ -0,0 +1,130 @@ +# +# Copyright 2022 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::xfusion::ibmc::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} = '^(harddisk|fan|psu|temperature)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + 'default' => [ + ['ok', 'OK'], + ['minor', 'WARNING'], + ['major', 'CRITICAL'], + ['critical', 'CRITICAL'], + ['absence', 'UNKNOWN'], + ['unknown', 'UNKNOWN'] + ], + 'logicaldrive' => [ + ['offline', 'OK'], + ['partial degraded', 'WARNING'], + ['degraded', 'CRITICAL'], + ['optimal', 'OK'], + ['unknown', 'UNKNOWN'] + ], + 'raidcontroller' => [ + ['memory correctable error', 'WARNING'], + ['memory uncorrectable error', 'CRITICAL'], + ['memory ECC error reached limit', 'CRITICAL'], + ['NVRAM uncorrectable error', 'CRITICAL'], + ['ok', 'OK'], + ['unknown', 'UNKNOWN'] + ] + }; + + $self->{components_path} = 'hardware::server::xfusion::ibmc::snmp::mode::components'; + $self->{components_module} = [ + 'component', 'cpu', 'harddisk', 'fan', 'logicaldrive', + 'memory', 'pcie', 'psu', 'raidcontroller', 'temperature' + ]; +} + +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); + bless $self, $class; + + $options{options}->add_options(arguments => {}); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check hardware components. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'component', 'cpu', 'harddisk', 'fan', 'logicaldrive', +'memory', 'pcie', 'psu', 'raidcontroller', 'temperature'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=psu) +Can also exclude specific instance: --filter=psu,1 + +=item B<--no-component> + +Return an error if no components are checked. +If total (with skipped) is 0. (Default: 'critical' returns). + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,[instance,]status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='psu,CRITICAL,^(?!(ok)$)' + +=item B<--warning> + +Set warning threshold (syntax: type,regexp,threshold) +Example: --warning='psu,.*,300' + +=item B<--critical> + +Set critical threshold (syntax: type,regexp,threshold) +Example: --critical='psu,.*,400' + +=back + +=cut + diff --git a/centreon-plugins/hardware/server/xfusion/ibmc/snmp/plugin.pm b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/plugin.pm new file mode 100644 index 000000000..c3c12ba5c --- /dev/null +++ b/centreon-plugins/hardware/server/xfusion/ibmc/snmp/plugin.pm @@ -0,0 +1,48 @@ +# +# Copyright 2022 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::xfusion::ibmc::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' => 'hardware::server::xfusion::ibmc::snmp::mode::hardware', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check xFusion iBMC in SNMP. + +=cut