From 4513a9c60377ad9f557e2b3abd11953197fee4b7 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Sat, 13 Feb 2016 23:39:09 +0100 Subject: [PATCH] + ref #201: WIP (still some components todo) --- .../idrac/snmp/mode/components/amperage.pm | 122 ++++++++ .../snmp/mode/components/coolingdevice.pm | 113 ++++++++ .../idrac/snmp/mode/components/coolingunit.pm | 74 +++++ .../dell/idrac/snmp/mode/components/memory.pm | 74 +++++ .../idrac/snmp/mode/components/network.pm | 66 +++++ .../dell/idrac/snmp/mode/components/pci.pm | 74 +++++ .../idrac/snmp/mode/components/processor.pm | 74 +++++ .../dell/idrac/snmp/mode/components/psu.pm | 67 +++++ .../dell/idrac/snmp/mode/components/punit.pm | 74 +++++ .../idrac/snmp/mode/components/resources.pm | 87 ++++++ .../snmp/mode/components/systembattery.pm | 74 +++++ .../idrac/snmp/mode/components/temperature.pm | 55 ++-- .../idrac/snmp/mode/components/voltage.pm | 113 ++++++++ .../server/dell/idrac/snmp/mode/hardware.pm | 264 ++++-------------- 14 files changed, 1091 insertions(+), 240 deletions(-) create mode 100644 centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/amperage.pm create mode 100644 centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/coolingdevice.pm create mode 100644 centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/coolingunit.pm create mode 100644 centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/memory.pm create mode 100644 centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/network.pm create mode 100644 centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/pci.pm create mode 100644 centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/processor.pm create mode 100644 centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/psu.pm create mode 100644 centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/punit.pm create mode 100644 centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/resources.pm create mode 100644 centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/systembattery.pm create mode 100644 centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/voltage.pm diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/amperage.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/amperage.pm new file mode 100644 index 000000000..1ebd18442 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/amperage.pm @@ -0,0 +1,122 @@ +# +# Copyright 2016 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::idrac::snmp::mode::components::amperage; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_probe_status %map_state %map_amperage_type); + +my $mapping = { + amperageProbeStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.30.1.4', map => \%map_state }, + amperageProbeStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.30.1.5', map => \%map_probe_status }, + amperageProbeReading => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.30.1.6' }, + amperageProbeType => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.30.1.7', map => \%map_amperage_type }, + amperageProbeLocationName => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.30.1.8' }, + amperageProbeUpperCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.30.1.10' }, + amperageProbeUpperNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.30.1.11' }, + amperageProbeLowerNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.30.1.12' }, + amperageProbeLowerCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.30.1.13' }, +}; +my $oid_amperageProbeTableEntry = '.1.3.6.1.4.1.674.10892.5.4.600.30.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_amperageProbeTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking amperages"); + $self->{components}->{amperage} = {name => 'amperages', total => 0, skip => 0}; + return if ($self->check_filter(section => 'amperage')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_amperageProbeTableEntry}})) { + next if ($oid !~ /^$mapping->{amperageProbeStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_amperageProbeTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'amperage', instance => $instance)); + $self->{components}->{amperage}->{total}++; + + my ($divisor, $unit) = (1000, 'A'); + if ($result->{amperageProbeType} =~ /amperageProbeTypeIsPowerSupplyAmps|amperageProbeTypeIsSystemAmps/) { + $divisor = 10; + } elsif ($result->{amperageProbeType} =~ /amperageProbeTypeIsPowerSupplyWatts|amperageProbeTypeIsSystemWatts/) { + $unit = 'W'; + } + $result->{amperageProbeReading} = (defined($result->{amperageProbeReading})) ? $result->{amperageProbeReading} / $divisor : 'unknown'; + $self->{output}->output_add(long_msg => sprintf("amperage '%s' status is '%s' [instance = %s] [state = %s] [value = %s]", + $result->{amperageProbeLocationName}, $result->{amperageProbeStatus}, $instance, + $result->{amperageProbeStateSettings}, $result->{amperageProbeReading})); + + my $exit = $self->get_severity(label => 'default.state', section => 'amperage.state', value => $result->{amperageProbeStateSettings}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Amperage '%s' state is '%s'", $result->{amperageProbeLocationName}, $result->{amperageProbeStateSettings})); + next; + } + + $exit = $self->get_severity(label => 'probe.status', section => 'amperage.status', value => $result->{amperageProbeStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Amperage '%s' status is '%s'", $result->{amperageProbeLocationName}, $result->{amperageProbeStatus})); + } + + next if ($result->{amperageProbeType} =~ /amperageProbeTypeIsDiscrete/); + + if (defined($result->{amperageProbeReading}) && $result->{amperageProbeReading} =~ /[0-9]/) { + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'amperage', instance => $instance, value => $result->{amperageProbeReading}); + if ($checked == 0) { + $result->{amperageProbeLowerNonCriticalThreshold} = (defined($result->{amperageProbeLowerNonCriticalThreshold}) && $result->{amperageProbeLowerNonCriticalThreshold} =~ /[0-9]/) ? + $result->{amperageProbeLowerNonCriticalThreshold} / $divisor : ''; + $result->{amperageProbeLowerCriticalThreshold} = (defined($result->{amperageProbeLowerCriticalThreshold}) && $result->{amperageProbeLowerCriticalThreshold} =~ /[0-9]/) ? + $result->{amperageProbeLowerCriticalThreshold} / $divisor : ''; + $result->{amperageProbeUpperNonCriticalThreshold} = (defined($result->{amperageProbeUpperNonCriticalThreshold}) && $result->{amperageProbeUpperNonCriticalThreshold} =~ /[0-9]/) ? + $result->{amperageProbeUpperNonCriticalThreshold} / $divisor : ''; + $result->{amperageProbeUpperCriticalThreshold} = (defined($result->{amperageProbeUpperCriticalThreshold}) && $result->{amperageProbeUpperCriticalThreshold} =~ /[0-9]/) ? + $result->{amperageProbeUpperCriticalThreshold} / $divisor : ''; + my $warn_th = $result->{amperageProbeLowerNonCriticalThreshold} . ':' . $result->{amperageProbeUpperNonCriticalThreshold}; + my $crit_th = $result->{amperageProbeLowerCriticalThreshold} . ':' . $result->{amperageProbeUpperCriticalThreshold}; + $self->{perfdata}->threshold_validate(label => 'warning-amperage-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-amperage-instance-' . $instance, value => $crit_th); + + $exit = $self->{perfdata}->threshold_check(value => $result->{amperageProbeReading}, threshold => [ { label => 'critical-amperage-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-amperage-instance-' . $instance, exit_litteral => 'warning' } ]); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-amperage-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-amperage-instance-' . $instance) + } + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Amperage '%s' is %s %s", $result->{amperageProbeLocationName}, $result->{amperageProbeReading}, $unit)); + } + $self->{output}->perfdata_add(label => 'amperage_' . $result->{amperageProbeLocationName}, unit => $unit, + value => $result->{amperageProbeReading}, + warning => $warn, + critical => $crit, + ); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/coolingdevice.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/coolingdevice.pm new file mode 100644 index 000000000..9eaf13818 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/coolingdevice.pm @@ -0,0 +1,113 @@ +# +# Copyright 2016 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::idrac::snmp::mode::components::coolingdevice; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_probe_status %map_state); + +my $mapping = { + coolingDeviceStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.12.1.4', map => \%map_state }, + coolingDeviceStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.12.1.5', map => \%map_probe_status }, + coolingDeviceReading => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.12.1.6' }, + coolingDeviceLocationName => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.12.1.8' }, + coolingDeviceUpperCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.10' }, + coolingDeviceUpperNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.11' }, + coolingDeviceLowerNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.12' }, + coolingDeviceLowerCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.12.1.13' }, +}; +my $oid_coolingDeviceTableEntry = '.1.3.6.1.4.1.674.10892.5.4.700.12.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_coolingDeviceTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking cooling devices"); + $self->{components}->{coolingdevice} = {name => 'cooling devices', total => 0, skip => 0}; + return if ($self->check_filter(section => 'coolingdevice')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_coolingDeviceTableEntry}})) { + next if ($oid !~ /^$mapping->{coolingDeviceStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_coolingDeviceTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'coolingdevice', instance => $instance)); + $self->{components}->{coolingdevice}->{total}++; + + $result->{coolingDeviceReading} = (defined($result->{coolingDeviceReading})) ? $result->{coolingDeviceReading} : 'unknown'; + $self->{output}->output_add(long_msg => sprintf("cooling device '%s' status is '%s' [instance = %s] [state = %s] [value = %s]", + $result->{coolingDeviceLocationName}, $result->{coolingDeviceStatus}, $instance, + $result->{coolingDeviceStateSettings}, $result->{coolingDeviceReading})); + + my $exit = $self->get_severity(label => 'default.state', section => 'coolingdevice.state', value => $result->{coolingDeviceStateSettings}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Cooling device '%s' state is '%s'", $result->{coolingDeviceLocationName}, $result->{coolingDeviceStateSettings})); + next; + } + + $exit = $self->get_severity(label => 'probe.status', section => 'coolingdevice.status', value => $result->{coolingDeviceStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Cooling device '%s' status is '%s'", $result->{coolingDeviceLocationName}, $result->{coolingDeviceStatus})); + } + + if (defined($result->{coolingDeviceReading}) && $result->{coolingDeviceReading} =~ /[0-9]/) { + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'coolingdevice', instance => $instance, value => $result->{coolingDeviceReading}); + if ($checked == 0) { + $result->{coolingDeviceLowerNonCriticalThreshold} = (defined($result->{coolingDeviceLowerNonCriticalThreshold}) && $result->{coolingDeviceLowerNonCriticalThreshold} =~ /[0-9]/) ? + $result->{coolingDeviceLowerNonCriticalThreshold} / 10 : ''; + $result->{coolingDeviceLowerCriticalThreshold} = (defined($result->{coolingDeviceLowerCriticalThreshold}) && $result->{coolingDeviceLowerCriticalThreshold} =~ /[0-9]/) ? + $result->{coolingDeviceLowerCriticalThreshold} / 10 : ''; + $result->{coolingDeviceUpperNonCriticalThreshold} = (defined($result->{coolingDeviceUpperNonCriticalThreshold}) && $result->{coolingDeviceUpperNonCriticalThreshold} =~ /[0-9]/) ? + $result->{coolingDeviceUpperNonCriticalThreshold} / 10 : ''; + $result->{coolingDeviceUpperCriticalThreshold} = (defined($result->{coolingDeviceUpperCriticalThreshold}) && $result->{coolingDeviceUpperCriticalThreshold} =~ /[0-9]/) ? + $result->{coolingDeviceUpperCriticalThreshold} : ''; + my $warn_th = $result->{coolingDeviceLowerNonCriticalThreshold} . ':' . $result->{coolingDeviceUpperNonCriticalThreshold}; + my $crit_th = $result->{coolingDeviceLowerCriticalThreshold} . ':' . $result->{coolingDeviceUpperCriticalThreshold}; + $self->{perfdata}->threshold_validate(label => 'warning-coolingdevice-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-coolingdevice-instance-' . $instance, value => $crit_th); + + $exit = $self->{perfdata}->threshold_check(value => $result->{coolingDeviceReading}, threshold => [ { label => 'critical-coolingdevice-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-coolingdevice-instance-' . $instance, exit_litteral => 'warning' } ]); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-coolingdevice-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-coolingdevice-instance-' . $instance) + } + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Cooling device '%s' is %s rpm", $result->{coolingDeviceLocationName}, $result->{coolingDeviceReading})); + } + $self->{output}->perfdata_add(label => 'fan_' . $result->{coolingDeviceLocationName}, unit => 'rpm', + value => $result->{coolingDeviceReading}, + warning => $warn, + critical => $crit, + ); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/coolingunit.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/coolingunit.pm new file mode 100644 index 000000000..6968331a6 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/coolingunit.pm @@ -0,0 +1,74 @@ +# +# Copyright 2016 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::idrac::snmp::mode::components::coolingunit; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status %map_state); + +my $mapping = { + coolingUnitStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.10.1.4', map => \%map_state }, + coolingUnitName => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.10.1.7' }, + coolingUnitStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.10.1.8', map => \%map_status }, +}; +my $oid_coolingUnitTableEntry = '.1.3.6.1.4.1.674.10892.5.4.700.10.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_coolingUnitTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking cooling units"); + $self->{components}->{coolingunit} = {name => 'cooling units', total => 0, skip => 0}; + return if ($self->check_filter(section => 'coolingunit')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_coolingUnitTableEntry}})) { + next if ($oid !~ /^$mapping->{coolingUnitStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_coolingUnitTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'coolingunit', instance => $instance)); + $self->{components}->{coolingunit}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("cooling unit '%s' status is '%s' [instance = %s] [state = %s]", + $result->{coolingUnitName}, $result->{coolingUnitStatus}, $instance, + $result->{coolingUnitStateSettings})); + + my $exit = $self->get_severity(label => 'default.state', section => 'coolingunit.state', value => $result->{coolingUnitStateSettings}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Cooling unit '%s' state is '%s'", $result->{coolingUnitName}, $result->{coolingUnitStateSettings})); + next; + } + + $exit = $self->get_severity(label => 'default.status', section => 'coolingunit.status', value => $result->{coolingUnitStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Cooling unit '%s' status is '%s'", $result->{coolingUnitName}, $result->{coolingUnitStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/memory.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/memory.pm new file mode 100644 index 000000000..00d08f636 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/memory.pm @@ -0,0 +1,74 @@ +# +# Copyright 2016 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::idrac::snmp::mode::components::memory; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status %map_state); + +my $mapping = { + memoryDeviceStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.50.1.4', map => \%map_state }, + memoryDeviceStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.50.1.5', map => \%map_status }, + memoryDeviceLocationName => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.50.1.8' }, +}; +my $oid_memoryDeviceTableEntry = '.1.3.6.1.4.1.674.10892.5.4.1100.50.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_memoryDeviceTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking memories"); + $self->{components}->{memory} = {name => 'memories', total => 0, skip => 0}; + return if ($self->check_filter(section => 'memory')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_memoryDeviceTableEntry}})) { + next if ($oid !~ /^$mapping->{memoryDeviceStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_memoryDeviceTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'memory', instance => $instance)); + $self->{components}->{memory}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("memory '%s' status is '%s' [instance = %s] [state = %s]", + $result->{memoryDeviceLocationName}, $result->{memoryDeviceStatus}, $instance, + $result->{memoryDeviceStateSettings})); + + my $exit = $self->get_severity(label => 'default.state', section => 'memory.state', value => $result->{memoryDeviceStateSettings}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Memory '%s' state is '%s'", $result->{memoryDeviceLocationName}, $result->{memoryDeviceStateSettings})); + next; + } + + $exit = $self->get_severity(label => 'default.status', section => 'memory.status', value => $result->{memoryDeviceStatus}); + 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->{memoryDeviceLocationName}, $result->{memoryDeviceStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/network.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/network.pm new file mode 100644 index 000000000..e83342b77 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/network.pm @@ -0,0 +1,66 @@ +# +# Copyright 2016 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::idrac::snmp::mode::components::network; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status); + +my $mapping = { + networkDeviceStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.90.1.3', map => \%map_status }, + networkDeviceProductName => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.90.1.6' }, +}; +my $oid_networkDeviceTableEntry = '.1.3.6.1.4.1.674.10892.5.4.1100.90.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_networkDeviceTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking networks"); + $self->{components}->{network} = {name => 'networks', total => 0, skip => 0}; + return if ($self->check_filter(section => 'network')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_networkDeviceTableEntry}})) { + next if ($oid !~ /^$mapping->{networkDeviceStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_networkDeviceTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'network', instance => $instance)); + $self->{components}->{network}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("network '%s' status is '%s' [instance = %s]", + $result->{networkDeviceProductName}, $result->{networkDeviceStatus}, $instance, + )); + + my $exit = $self->get_severity(label => 'default.status', section => 'network.status', value => $result->{networkDeviceStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Network '%s' status is '%s'", $result->{networkDeviceProductName}, $result->{networkDeviceStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/pci.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/pci.pm new file mode 100644 index 000000000..497e99352 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/pci.pm @@ -0,0 +1,74 @@ +# +# Copyright 2016 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::idrac::snmp::mode::components::pci; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status %map_state); + +my $mapping = { + pCIDeviceStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.80.1.4', map => \%map_state }, + pCIDeviceStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.80.1.5', map => \%map_status }, + pCIDeviceDescriptionName => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.80.1.9' }, +}; +my $oid_pCIDeviceTableEntry = '.1.3.6.1.4.1.674.10892.5.4.1100.80.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_pCIDeviceTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking pci"); + $self->{components}->{pci} = {name => 'pci', total => 0, skip => 0}; + return if ($self->check_filter(section => 'pci')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_pCIDeviceTableEntry}})) { + next if ($oid !~ /^$mapping->{pCIDeviceStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_pCIDeviceTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'pci', instance => $instance)); + $self->{components}->{pci}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("pci '%s' status is '%s' [instance = %s] [state = %s]", + $result->{pCIDeviceDescriptionName}, $result->{pCIDeviceStatus}, $instance, + $result->{pCIDeviceStateSettings})); + + my $exit = $self->get_severity(label => 'default.state', section => 'pci.state', value => $result->{pCIDeviceStateSettings}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("PCI '%s' state is '%s'", $result->{pCIDeviceDescriptionName}, $result->{pCIDeviceStateSettings})); + next; + } + + $exit = $self->get_severity(label => 'default.status', section => 'pci.status', value => $result->{pCIDeviceStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("PCI '%s' status is '%s'", $result->{pCIDeviceDescriptionName}, $result->{pCIDeviceStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/processor.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/processor.pm new file mode 100644 index 000000000..bc2a896ad --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/processor.pm @@ -0,0 +1,74 @@ +# +# Copyright 2016 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::idrac::snmp::mode::components::processor; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status %map_state); + +my $mapping = { + processorDeviceStatusStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.32.1.4', map => \%map_state }, + processorDeviceStatusStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.32.1.5', map => \%map_status }, + processorDeviceStatusLocationName => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.32.1.7' }, +}; +my $oid_processorDeviceStatusTableEntry = '.1.3.6.1.4.1.674.10892.5.4.1100.32.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_processorDeviceStatusTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking processors"); + $self->{components}->{processor} = {name => 'processors', total => 0, skip => 0}; + return if ($self->check_filter(section => 'processor')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_processorDeviceStatusTableEntry}})) { + next if ($oid !~ /^$mapping->{processorDeviceStatusStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_processorDeviceStatusTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'processor', instance => $instance)); + $self->{components}->{processor}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("processor '%s' status is '%s' [instance = %s] [state = %s]", + $result->{processorDeviceStatusLocationName}, $result->{processorDeviceStatusStatus}, $instance, + $result->{processorDeviceStatusStateSettings})); + + my $exit = $self->get_severity(label => 'default.state', section => 'processor.state', value => $result->{processorDeviceStatusStateSettings}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Processor '%s' state is '%s'", $result->{processorDeviceStatusLocationName}, $result->{processorDeviceStatusStateSettings})); + next; + } + + $exit = $self->get_severity(label => 'default.status', section => 'processor.status', value => $result->{processorDeviceStatusStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Processor '%s' status is '%s'", $result->{processorDeviceStatusLocationName}, $result->{processorDeviceStatusStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/psu.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/psu.pm new file mode 100644 index 000000000..c866a1720 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/psu.pm @@ -0,0 +1,67 @@ +# +# Copyright 2016 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::idrac::snmp::mode::components::psu; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status); + +my $mapping = { + powerSupplyStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.12.1.5', map => \%map_status }, + powerSupplyLocationName => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.12.1.8' }, +}; +my $oid_powerSupplyTableEntry = '.1.3.6.1.4.1.674.10892.5.4.600.12.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_powerSupplyTableEntry }; +} + +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_powerSupplyTableEntry}})) { + next if ($oid !~ /^$mapping->{powerSupplyStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_powerSupplyTableEntry}, 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->{powerSupplyLocationName}, $result->{powerSupplyStatus}, $instance, + )); + + + my $exit = $self->get_severity(label => 'default.status', section => 'psu.status', 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->{powerSupplyLocationName}, $result->{powerSupplyStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/punit.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/punit.pm new file mode 100644 index 000000000..d42aead49 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/punit.pm @@ -0,0 +1,74 @@ +# +# Copyright 2016 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::idrac::snmp::mode::components::punit; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status %map_state); + +my $mapping = { + powerUnitStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.10.1.4', map => \%map_state }, + powerUnitName => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.10.1.7' }, + powerUnitStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.10.1.8', map => \%map_status }, +}; +my $oid_powerUnitTableEntry = '.1.3.6.1.4.1.674.10892.5.4.600.10.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_powerUnitTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking power units"); + $self->{components}->{punit} = {name => 'power units', total => 0, skip => 0}; + return if ($self->check_filter(section => 'punit')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_powerUnitTableEntry}})) { + next if ($oid !~ /^$mapping->{powerUnitStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_powerUnitTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'punit', instance => $instance)); + $self->{components}->{punit}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("power unit '%s' status is '%s' [instance = %s] [state = %s]", + $result->{powerUnitName}, $result->{powerUnitStatus}, $instance, + $result->{powerUnitStateSettings})); + + my $exit = $self->get_severity(label => 'default.state', section => 'punit.state', value => $result->{powerUnitStateSettings}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Power unit '%s' state is '%s'", $result->{powerUnitName}, $result->{powerUnitStateSettings})); + next; + } + + $exit = $self->get_severity(label => 'default.status', section => 'punit.status', value => $result->{powerUnitStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Power unit '%s' status is '%s'", $result->{powerUnitName}, $result->{powerUnitStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/resources.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/resources.pm new file mode 100644 index 000000000..2cbad5fb8 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/resources.pm @@ -0,0 +1,87 @@ +# +# Copyright 2016 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::idrac::snmp::mode::components::resources; + +use strict; +use warnings; +use Exporter; + +our %map_state; +our %map_status; +our %map_probe_status; +our %map_amperage_type; + +our @ISA = qw(Exporter); +our @EXPORT_OK = qw(%map_probe_status %map_state %map_status %map_amperage_type); + +%map_probe_status = ( + 1 => 'other', + 2 => 'unknown', + 3 => 'ok', + 4 => 'nonCriticalUpper', + 5 => 'criticalUpper', + 6 => 'nonRecoverableUpper', + 7 => 'nonCriticalLower', + 8 => 'criticalLower', + 9 => 'nonRecoverableLower', + 10 => 'failed', +); + +%map_status = ( + 1 => 'other', + 2 => 'unknown', + 3 => 'ok', + 4 => 'nonCritical', + 5 => 'critical', + 6 => 'nonRecoverable', +); + +%map_state = ( + 1 => 'unknown', + 2 => 'enabled', + 4 => 'notReady', + 6 => 'enabledAndNotReady', +); + +%map_amperage_type = ( + 1 => 'amperageProbeTypeIsOther', + 2 => 'amperageProbeTypeIsUnknown', + 3 => 'amperageProbeTypeIs1Point5Volt', + 4 => 'amperageProbeTypeIs3Point3volt', + 5 => 'amperageProbeTypeIs5Volt', + 6 => 'amperageProbeTypeIsMinus5Volt', + 7 => 'amperageProbeTypeIs12Volt', + 8 => 'amperageProbeTypeIsMinus12Volt', + 9 => 'amperageProbeTypeIsIO', + 10 => 'amperageProbeTypeIsCore', + 11 => 'amperageProbeTypeIsFLEA', + 12 => 'amperageProbeTypeIsBattery', + 13 => 'amperageProbeTypeIsTerminator', + 14 => 'amperageProbeTypeIs2Point5Volt', + 15 => 'amperageProbeTypeIsGTL', + 16 => 'amperageProbeTypeIsDiscrete', + 23 => 'amperageProbeTypeIsPowerSupplyAmps', + 24 => 'amperageProbeTypeIsPowerSupplyWatts', + 25 => 'amperageProbeTypeIsSystemAmps', + 26 => 'amperageProbeTypeIsSystemWatts', +); + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/systembattery.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/systembattery.pm new file mode 100644 index 000000000..6d595dee8 --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/systembattery.pm @@ -0,0 +1,74 @@ +# +# Copyright 2016 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::idrac::snmp::mode::components::systembattery; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status %map_state); + +my $mapping = { + systemBatteryStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.50.1.4', map => \%map_state }, + systemBatteryStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.50.1.5', map => \%map_status }, + systemBatteryLocationName => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.50.1.7' }, +}; +my $oid_systemBatteryTableEntry = '.1.3.6.1.4.1.674.10892.5.4.600.50.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_systemBatteryTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking system batteries"); + $self->{components}->{systembattery} = {name => 'system batteries', total => 0, skip => 0}; + return if ($self->check_filter(section => 'systembattery')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_systemBatteryTableEntry}})) { + next if ($oid !~ /^$mapping->{systemBatteryStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_systemBatteryTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'systembattery', instance => $instance)); + $self->{components}->{systembattery}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("system battery '%s' status is '%s' [instance = %s] [state = %s]", + $result->{systemBatteryLocationName}, $result->{systemBatteryStatus}, $instance, + $result->{systemBatteryStateSettings})); + + my $exit = $self->get_severity(label => 'default.state', section => 'systembattery.state', value => $result->{systemBatteryStateSettings}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("System battery '%s' state is '%s'", $result->{systemBatteryLocationName}, $result->{systemBatteryStateSettings})); + next; + } + + $exit = $self->get_severity(label => 'default.status', section => 'systembattery.status', value => $result->{systemBatteryStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("System battery '%s' status is '%s'", $result->{systemBatteryLocationName}, $result->{systemBatteryStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/temperature.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/temperature.pm index 68fe2a743..95213638a 100644 --- a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/temperature.pm +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/temperature.pm @@ -22,25 +22,8 @@ package hardware::server::dell::idrac::snmp::mode::components::temperature; use strict; use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_probe_status %map_state); -my %map_temp_status = ( - 1 => 'other', - 2 => 'unknown', - 3 => 'ok', - 4 => 'nonCriticalUpper', - 5 => 'criticalUpper', - 6 => 'nonRecoverableUpper', - 7 => 'nonCriticalLower', - 8 => 'criticalLower', - 9 => 'nonRecoverableLower', - 10 => 'failed', -); -my %map_temp_state = ( - 1 => 'unknown', - 2 => 'enabled', - 4 => 'notReady', - 6 => 'enabledAndNotReady', -); my %map_temp_type = ( 1 => 'temperatureProbeTypeIsOther', 2 => 'temperatureProbeTypeIsUnknown', @@ -49,22 +32,22 @@ my %map_temp_type = ( ); my $mapping = { - temperatureProbeStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.4', map => \%map_temp_state }, - temperatureProbeStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.5', map => \%map_temp_status }, + temperatureProbeStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.4', map => \%map_state }, + temperatureProbeStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.5', map => \%map_probe_status }, temperatureProbeReading => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.6' }, temperatureProbeType => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.7', map => \%map_temp_type }, temperatureProbeLocationName => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.8' }, temperatureProbeUpperCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.10' }, - temperatureProbeUpperNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.10' }, - temperatureProbeLowerNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.11' }, - temperatureProbeLowerCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.12' }, + temperatureProbeUpperNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.11' }, + temperatureProbeLowerNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.12' }, + temperatureProbeLowerCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.13' }, }; my $oid_temperatureProbeTableEntry = '.1.3.6.1.4.1.674.10892.5.4.700.20.1'; sub load { - my (%options) = @_; + my ($self) = @_; - push @{$options{request}}, { oid => $oid_temperatureProbeTableEntry, begin => $mapping->{temperatureProbeStateSettings}->{oid}, end => $mapping->{temperatureProbeLowerCriticalThreshold}->{oid} }; + push @{$self->{request}}, { oid => $oid_temperatureProbeTableEntry, begin => $mapping->{temperatureProbeStateSettings}->{oid}, end => $mapping->{temperatureProbeLowerCriticalThreshold}->{oid} }; } sub check { @@ -72,29 +55,29 @@ sub check { $self->{output}->output_add(long_msg => "Checking temperatures"); $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; - return if ($self->check_exclude(section => 'temperature')); + return if ($self->check_filter(section => 'temperature')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_temperatureProbeTableEntry}})) { next if ($oid !~ /^$mapping->{temperatureProbeStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_temperatureProbeTableEntry}, instance => $instance); - next if ($self->check_exclude(section => 'temperature', instance => $instance)); + next if ($self->check_filter(section => 'temperature', instance => $instance)); $self->{components}->{temperature}->{total}++; $result->{temperatureProbeReading} = (defined($result->{temperatureProbeReading})) ? $result->{temperatureProbeReading} / 10 : 'unknown'; - $self->{output}->output_add(long_msg => sprintf("Temperature '%s' status is '%s' [instance = %s] [state = %s] [value = %s]", + $self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s' [instance = %s] [state = %s] [value = %s]", $result->{temperatureProbeLocationName}, $result->{temperatureProbeStatus}, $instance, $result->{temperatureProbeStateSettings}, $result->{temperatureProbeReading})); - my $exit = $self->get_severity(section => 'temperature-state', value => $result->{temperatureProbeStateSettings}); + my $exit = $self->get_severity(label => 'default.state', section => 'temperature.state', value => $result->{temperatureProbeStateSettings}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Temperature '%s' state is '%s'", $result->{temperatureProbeLocationName}, $result->{temperatureProbeStateSettings})); next; } - $exit = $self->get_severity(section => 'temperature-status', value => $result->{temperatureProbeStatus}); + $exit = $self->get_severity(label => 'probe.status', section => 'temperature.status', value => $result->{temperatureProbeStatus}); 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->{temperatureProbeLocationName}, $result->{temperatureProbeStatus})); @@ -103,7 +86,15 @@ sub check { if (defined($result->{temperatureProbeReading}) && $result->{temperatureProbeReading} =~ /[0-9]/) { my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{temperatureProbeReading}); if ($checked == 0) { - my $warn_th = $result->{temperatureProbeLowerNonCriticalThreshold} . ':' . $result->{temperatureProbeUpperCriticalThreshold}; + $result->{temperatureProbeLowerNonCriticalThreshold} = (defined($result->{temperatureProbeLowerNonCriticalThreshold}) && $result->{temperatureProbeLowerNonCriticalThreshold} =~ /[0-9]/) ? + $result->{temperatureProbeLowerNonCriticalThreshold} / 10 : ''; + $result->{temperatureProbeLowerCriticalThreshold} = (defined($result->{temperatureProbeLowerCriticalThreshold}) && $result->{temperatureProbeLowerCriticalThreshold} =~ /[0-9]/) ? + $result->{temperatureProbeLowerCriticalThreshold} / 10 : ''; + $result->{temperatureProbeUpperNonCriticalThreshold} = (defined($result->{temperatureProbeUpperNonCriticalThreshold}) && $result->{temperatureProbeUpperNonCriticalThreshold} =~ /[0-9]/) ? + $result->{temperatureProbeUpperNonCriticalThreshold} / 10 : ''; + $result->{temperatureProbeUpperCriticalThreshold} = (defined($result->{temperatureProbeUpperCriticalThreshold}) && $result->{temperatureProbeUpperCriticalThreshold} =~ /[0-9]/) ? + $result->{temperatureProbeUpperCriticalThreshold} / 10 : ''; + my $warn_th = $result->{temperatureProbeLowerNonCriticalThreshold} . ':' . $result->{temperatureProbeUpperNonCriticalThreshold}; my $crit_th = $result->{temperatureProbeLowerCriticalThreshold} . ':' . $result->{temperatureProbeUpperCriticalThreshold}; $self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th); $self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th); @@ -118,7 +109,7 @@ sub check { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Temperature '%s' is %s degree centigrade", $result->{temperatureProbeLocationName}, $result->{temperatureProbeReading})); } - $self->{output}->perfdata_add(label => 'temp_' . $instance, unit => 'C', + $self->{output}->perfdata_add(label => 'temp_' . $result->{temperatureProbeLocationName}, unit => 'C', value => $result->{temperatureProbeReading}, warning => $warn, critical => $crit, diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/voltage.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/voltage.pm new file mode 100644 index 000000000..ff3399c7b --- /dev/null +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/components/voltage.pm @@ -0,0 +1,113 @@ +# +# Copyright 2016 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::idrac::snmp::mode::components::voltage; + +use strict; +use warnings; +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_probe_status %map_state); + +my $mapping = { + voltageProbeStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.20.1.4', map => \%map_state }, + voltageProbeStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.20.1.5', map => \%map_probe_status }, + voltageProbeReading => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.20.1.6' }, + voltageProbeLocationName => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.20.1.8' }, + voltageProbeUpperCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.20.1.10' }, + voltageProbeUpperNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.20.1.11' }, + voltageProbeLowerNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.20.1.12' }, + voltageProbeLowerCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.600.20.1.13' }, +}; +my $oid_voltageProbeTableEntry = '.1.3.6.1.4.1.674.10892.5.4.600.20.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_voltageProbeTableEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking voltages"); + $self->{components}->{voltage} = {name => 'voltages', total => 0, skip => 0}; + return if ($self->check_filter(section => 'voltage')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_voltageProbeTableEntry}})) { + next if ($oid !~ /^$mapping->{voltageProbeStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_voltageProbeTableEntry}, instance => $instance); + + next if ($self->check_filter(section => 'voltage', instance => $instance)); + $self->{components}->{voltage}->{total}++; + + $result->{voltageProbeReading} = (defined($result->{voltageProbeReading})) ? $result->{voltageProbeReading} / 1000 : 'unknown'; + $self->{output}->output_add(long_msg => sprintf("voltage '%s' status is '%s' [instance = %s] [state = %s] [value = %s]", + $result->{voltageProbeLocationName}, $result->{voltageProbeStatus}, $instance, + $result->{voltageProbeStateSettings}, $result->{voltageProbeReading})); + + my $exit = $self->get_severity(label => 'default.state', section => 'voltage.state', value => $result->{voltageProbeStateSettings}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Voltage '%s' state is '%s'", $result->{voltageProbeLocationName}, $result->{voltageProbeStateSettings})); + next; + } + + $exit = $self->get_severity(label => 'probe.status', section => 'voltage.status', value => $result->{voltageProbeStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Voltage '%s' status is '%s'", $result->{voltageProbeLocationName}, $result->{voltageProbeStatus})); + } + + if (defined($result->{voltageProbeReading}) && $result->{voltageProbeReading} =~ /[0-9]/) { + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{voltageProbeReading}); + if ($checked == 0) { + $result->{voltageProbeLowerNonCriticalThreshold} = (defined($result->{voltageProbeLowerNonCriticalThreshold}) && $result->{voltageProbeLowerNonCriticalThreshold} =~ /[0-9]/) ? + $result->{voltageProbeLowerNonCriticalThreshold} / 1000 : ''; + $result->{voltageProbeLowerCriticalThreshold} = (defined($result->{voltageProbeLowerCriticalThreshold}) && $result->{voltageProbeLowerCriticalThreshold} =~ /[0-9]/) ? + $result->{voltageProbeLowerCriticalThreshold} / 1000 : ''; + $result->{voltageProbeUpperNonCriticalThreshold} = (defined($result->{voltageProbeUpperNonCriticalThreshold}) && $result->{voltageProbeUpperNonCriticalThreshold} =~ /[0-9]/) ? + $result->{voltageProbeUpperNonCriticalThreshold} / 1000 : ''; + $result->{voltageProbeUpperCriticalThreshold} = (defined($result->{voltageProbeUpperCriticalThreshold}) && $result->{voltageProbeUpperCriticalThreshold} =~ /[0-9]/) ? + $result->{voltageProbeUpperCriticalThreshold} / 1000 : ''; + my $warn_th = $result->{voltageProbeLowerNonCriticalThreshold} . ':' . $result->{voltageProbeUpperNonCriticalThreshold}; + my $crit_th = $result->{voltageProbeLowerCriticalThreshold} . ':' . $result->{voltageProbeUpperCriticalThreshold}; + $self->{perfdata}->threshold_validate(label => 'warning-voltage-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-voltage-instance-' . $instance, value => $crit_th); + + $exit = $self->{perfdata}->threshold_check(value => $result->{voltageProbeReading}, threshold => [ { label => 'critical-voltage-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-voltage-instance-' . $instance, exit_litteral => 'warning' } ]); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-voltage-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-voltage-instance-' . $instance) + } + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Voltage '%s' is %s V", $result->{voltageProbeLocationName}, $result->{voltageProbeReading})); + } + $self->{output}->perfdata_add(label => 'voltage_' . $result->{voltageProbeLocationName}, unit => 'V', + value => $result->{voltageProbeReading}, + warning => $warn, + critical => $crit, + ); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/hardware.pm b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/hardware.pm index 57e57e7f0..a1e0b9802 100644 --- a/centreon-plugins/hardware/server/dell/idrac/snmp/mode/hardware.pm +++ b/centreon-plugins/hardware/server/dell/idrac/snmp/mode/hardware.pm @@ -20,33 +20,60 @@ package hardware::server::dell::idrac::snmp::mode::hardware; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -use centreon::plugins::misc; -my $thresholds = { - 'temperature-state' => [ - ['unknown', 'UNKNOWN'], - ['enabled', 'OK'], - ['notReady', 'WARNING'], - ['enabledAndNotReady', 'WARNING'], - ['.*', 'UNKNOWN'], - ], - 'temperature-status' => [ - ['other', 'UNKNOWN'], - ['unknown', 'UNKNOWN'], - ['ok', 'OK'], - ['nonCriticalUpper', 'WARNING'], - ['criticalUpper', 'CRITICAL'], - ['nonCriticalLower', 'WARNING'], - ['criticalLower', 'CRITICAL'], - ['nonRecoverableLower', 'CRITICAL'], - ['failed', 'CRITICAL'], - ['.*', 'UNKNOWN'], - ], -}; +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(psu|punit|temperature|voltage|amperage|systembattery|coolingunit|coolingdevice|processor|memory|pci|network)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|voltage|amperage|coolingdevice)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + 'default.state' => [ + ['unknown', 'UNKNOWN'], + ['enabled', 'OK'], + ['notReady', 'WARNING'], + ['enabledAndNotReady', 'WARNING'], + ], + 'default.status' => [ + ['other', 'UNKNOWN'], + ['unknown', 'UNKNOWN'], + ['ok', 'OK'], + ['nonCritical', 'WARNING'], + ['critical', 'CRITICAL'], + ['nonRecoverable', 'CRITICAL'], + ], + 'probe.status' => [ + ['other', 'UNKNOWN'], + ['unknown', 'UNKNOWN'], + ['ok', 'OK'], + ['nonCriticalUpper', 'WARNING'], + ['criticalUpper', 'CRITICAL'], + ['nonCriticalLower', 'WARNING'], + ['criticalLower', 'CRITICAL'], + ['nonRecoverableLower', 'CRITICAL'], + ['failed', 'CRITICAL'], + ], + }; + + # need also: fru, systemslot, storagectrl (storage controller), storagebattery + # physicaldisk, virtualdisk + $self->{components_path} = 'hardware::server::dell::idrac::snmp::mode::components'; + $self->{components_module} = ['psu', 'punit', 'temperature', 'voltage', 'amperage', + 'systembattery', 'coolingunit', 'coolingdevice', 'processor', 'memory', 'pci', 'network']; +} + +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) = @_; @@ -56,189 +83,11 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => { - "exclude:s" => { name => 'exclude' }, - "component:s" => { name => 'component', default => '.*' }, - "no-component:s" => { name => 'no_component' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - "warning:s@" => { name => 'warning' }, - "critical:s@" => { name => 'critical' }, }); - - $self->{components} = {}; - $self->{no_components} = undef; + return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (defined($self->{option_results}->{no_component})) { - if ($self->{option_results}->{no_component} ne '') { - $self->{no_components} = $self->{option_results}->{no_component}; - } else { - $self->{no_components} = 'critical'; - } - } - - $self->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); - $self->{output}->option_exit(); - } - $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); - push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; - } - - $self->{numeric_threshold} = {}; - foreach my $option (('warning', 'critical')) { - foreach my $val (@{$self->{option_results}->{$option}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $regexp, $value) = ($1, $2, $3); - if ($section !~ /(temperature)/) { - $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: temperature)."); - $self->{output}->option_exit(); - } - my $position = 0; - if (defined($self->{numeric_threshold}->{$section})) { - $position = scalar(@{$self->{numeric_threshold}->{$section}}); - } - if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); - $self->{output}->option_exit(); - } - $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); - push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, regexp => $regexp }; - } - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $snmp_request = []; - my @components = ('temperature'); - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "hardware::server::dell::idrac::snmp::mode::components::$_"; - centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name, - error_msg => "Cannot load module '$mod_name'."); - my $func = $mod_name->can('load'); - $func->(request => $snmp_request); - } - } - - if (scalar(@{$snmp_request}) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); - $self->{output}->option_exit(); - } - $self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request); - - foreach (@components) { - if (/$self->{option_results}->{component}/) { - my $mod_name = "hardware::server::dell::idrac::snmp::mode::components::$_"; - my $func = $mod_name->can('check'); - $func->($self); - } - } - - my $total_components = 0; - my $display_by_component = ''; - my $display_by_component_append = ''; - foreach my $comp (sort(keys %{$self->{components}})) { - # Skipping short msg when no components - next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0); - $total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; - my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; - $display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name}; - $display_by_component_append = ', '; - } - - $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("All %s components are ok [%s].", - $total_components, - $display_by_component) - ); - - if (defined($self->{option_results}->{no_component}) && $total_components == 0) { - $self->{output}->output_add(severity => $self->{no_components}, - short_msg => 'No components are checked.'); - } - - $self->{output}->display(); - $self->{output}->exit(); -} - -sub check_exclude { - my ($self, %options) = @_; - - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - return 1; - } - return 0; -} - -sub get_severity_numeric { - my ($self, %options) = @_; - my $status = 'OK'; # default - my $thresholds = { warning => undef, critical => undef }; - my $checked = 0; - - if (defined($self->{numeric_threshold}->{$options{section}})) { - my $exits = []; - foreach (@{$self->{numeric_threshold}->{$options{section}}}) { - if ($options{instance} =~ /$_->{regexp}/) { - push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); - $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); - $checked = 1; - } - } - $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); - } - - return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked); -} - -sub get_severity { - my ($self, %options) = @_; - my $status = 'UNKNOWN'; # default - - if (defined($self->{overload_th}->{$options{section}})) { - foreach (@{$self->{overload_th}->{$options{section}}}) { - if ($options{value} =~ /$_->{filter}/i) { - $status = $_->{status}; - return $status; - } - } - } - foreach (@{$thresholds->{$options{section}}}) { - if ($options{value} =~ /$$_[0]/i) { - $status = $$_[1]; - return $status; - } - } - - return $status; -} - 1; __END__ @@ -246,7 +95,6 @@ __END__ =head1 MODE Check hardware components (temperatures,...). -Mode is in WIP. =over 8 @@ -255,10 +103,10 @@ Mode is in WIP. Which component to check (Default: '.*'). Can be: 'temperature', -=item B<--exclude> +=item B<--filter> -Exclude some parts (comma seperated list) (Example: --exclude=psu) -Can also exclude specific instance: --exclude='temperature#1.1#' +Exclude some parts (comma seperated list) (Example: --filter=temperature --filter=psu) +Can also exclude specific instance: --filter=temperature,1.1 =item B<--no-component> @@ -267,9 +115,9 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). -Example: --threshold-overload='temperature-state,CRITICAL,^(?!(enabled)$)' +Example: --threshold-overload='temperature.state,CRITICAL,^(?!(enabled)$)' =item B<--warning>