From 97e447dce7bcac2ea6bd7dc10cff33634e1c3383 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 10 Jan 2019 11:32:56 +0100 Subject: [PATCH] add idrac snmp smart alert disk --- .../dell/idrac/snmp/mode/components/pdisk.pm | 34 +++++++++++++------ .../idrac/snmp/mode/components/resources.pm | 10 ++++-- .../server/dell/idrac/snmp/mode/hardware.pm | 4 +++ 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/hardware/server/dell/idrac/snmp/mode/components/pdisk.pm b/hardware/server/dell/idrac/snmp/mode/components/pdisk.pm index 19230af30..adecc6ee3 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/pdisk.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/pdisk.pm @@ -22,19 +22,22 @@ package hardware::server::dell::idrac::snmp::mode::components::pdisk; use strict; use warnings; -use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status %map_pdisk_state); +use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status %map_pdisk_state %map_pdisk_smartstate); my $mapping = { - physicalDiskState => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.4', map => \%map_pdisk_state }, - physicalDiskComponentStatus => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.24', map => \%map_status }, - physicalDiskFQDD => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.54' }, + physicalDiskState => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.4', map => \%map_pdisk_state }, + physicalDiskComponentStatus => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.24', map => \%map_status }, + physicalDiskSmartAlertIndication => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.31', map => \%map_pdisk_smartstate }, + physicalDiskFQDD => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.54' }, }; my $oid_physicalDiskTableEntry = '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1'; sub load { my ($self) = @_; - push @{$self->{request}}, { oid => $oid_physicalDiskTableEntry }; + foreach (keys %{$mapping}) { + push @{$self->{request}}, { oid => $mapping->{$_}->{oid} }; + } } sub check { @@ -44,17 +47,22 @@ sub check { $self->{components}->{pdisk} = {name => 'physical disks', total => 0, skip => 0}; return if ($self->check_filter(section => 'pdisk')); - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_physicalDiskTableEntry}})) { - next if ($oid !~ /^$mapping->{physicalDiskComponentStatus}->{oid}\.(.*)$/); + my $results = {}; + foreach (keys %{$mapping}) { + $results = { %$results, %{$self->{results}->{$mapping->{$_}->{oid}}} } + } + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{physicalDiskComponentStatus}->{oid}}})) { + $oid =~ /^$mapping->{physicalDiskComponentStatus}->{oid}\.(.*)$/; my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_physicalDiskTableEntry}, instance => $instance); + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance); next if ($self->check_filter(section => 'pdisk', instance => $instance)); $self->{components}->{pdisk}->{total}++; - $self->{output}->output_add(long_msg => sprintf("physical disk '%s' status is '%s' [instance = %s] [state = %s]", + $self->{output}->output_add(long_msg => sprintf("physical disk '%s' status is '%s' [instance = %s] [state = %s] [smart alert = %s]", $result->{physicalDiskFQDD}, $result->{physicalDiskComponentStatus}, $instance, - $result->{physicalDiskState})); + $result->{physicalDiskState}, $result->{physicalDiskSmartAlertIndication})); my $exit = $self->get_severity(section => 'pdisk.state', value => $result->{physicalDiskState}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { @@ -68,6 +76,12 @@ sub check { $self->{output}->output_add(severity => $exit, short_msg => sprintf("physical disk '%s' status is '%s'", $result->{physicalDiskFQDD}, $result->{physicalDiskComponentStatus})); } + + $exit = $self->get_severity(section => 'pdisk.smartalert', value => $result->{physicalDiskSmartAlertIndication}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("physical disk '%s' smart alert predictive failure is '%s'", $result->{physicalDiskFQDD}, $result->{physicalDiskSmartAlertIndication})); + } } } diff --git a/hardware/server/dell/idrac/snmp/mode/components/resources.pm b/hardware/server/dell/idrac/snmp/mode/components/resources.pm index 0c1a0f5d9..516a3e61a 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/resources.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/resources.pm @@ -29,10 +29,16 @@ our %map_status; our %map_probe_status; our %map_amperage_type; our %map_pdisk_state; +our %map_pdisk_smartstate; our %map_vdisk_state; our @ISA = qw(Exporter); -our @EXPORT_OK = qw(%map_probe_status %map_state %map_status %map_amperage_type %map_pdisk_state %map_vdisk_state); +our @EXPORT_OK = qw(%map_probe_status %map_state %map_status %map_amperage_type %map_pdisk_state %map_pdisk_smartstate %map_vdisk_state); + +%map_pdisk_smartstate = ( + 0 => 'off', + 1 => 'on', +); %map_probe_status = ( 1 => 'other', @@ -105,4 +111,4 @@ our @EXPORT_OK = qw(%map_probe_status %map_state %map_status %map_amperage_type 26 => 'amperageProbeTypeIsSystemWatts', ); -1; \ No newline at end of file +1; diff --git a/hardware/server/dell/idrac/snmp/mode/hardware.pm b/hardware/server/dell/idrac/snmp/mode/hardware.pm index cee01edfd..a39bfd526 100644 --- a/hardware/server/dell/idrac/snmp/mode/hardware.pm +++ b/hardware/server/dell/idrac/snmp/mode/hardware.pm @@ -69,6 +69,10 @@ sub set_system { ['non-raid', 'OK'], ['removed', 'OK'], ], + 'pdisk.smartalert' => [ + ['off', 'OK'], + ['on', 'WARNING'], + ], 'vdisk.state' => [ ['unknown', 'UNKNOWN'], ['online', 'OK'],