From 3fee32b1491175d1722e806217f7381051a85df4 Mon Sep 17 00:00:00 2001 From: root <root@imap00.cs.umd.edu> Date: Thu, 6 Jun 2019 12:10:34 -0400 Subject: [PATCH] Megaraid support to go to Core::SMART module --- lib/Core/SMART.pm | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/lib/Core/SMART.pm b/lib/Core/SMART.pm index 3a9d4a7..676005c 100644 --- a/lib/Core/SMART.pm +++ b/lib/Core/SMART.pm @@ -35,6 +35,8 @@ For more information on smartctl, see http://smartmontools.sourceforge.net/ This indicates the disk argument to be given to smartctl. Expects the basename of the device, not the full path, e.g. "sda" not "/dev/sda". +Check names having "/" and a nubmer after it are considered to be physical parts of +megaraid arrays. =item smartctl_cmd @@ -87,24 +89,49 @@ The raw value of the attribute, expected to be an integer. sub handler { my $self = shift; my $config = $self->{config}; + my ($disk_name,$megaraid_number) = split('/',$self->{check_name}), my $disk; - $disk = "/dev/$self->{check_name}" if ($^O eq "linux") || ($^O =~ /bsd/) ; - $disk = "/dev/rdsk/$self->{check_name}" if $^O eq "solaris"; + $disk = "/dev/$disk_name" if ($^O eq "linux") || ($^O =~ /bsd/) ; + $disk = "/dev/rdsk/$disk_name" if $^O eq "solaris"; my $smartctl_cmd = $config->{smartctl_cmd} || "/usr/sbin/smartctl"; - my $smartctl_args = "-i -A"; + my $smartctl_args = "-i"; + if (defined ($megaraid_number)) { + $smartctl_args .= " -a -H -d megaraid,$megaraid_number"; + } + else { + $smartctl_args .= " -A"; + } $smartctl_args = "$smartctl_args $config->{smartctl_args}" if $config->{smartctl_args}; my $smartdata = {}; my $output = run_command("$smartctl_cmd $smartctl_args $disk"); foreach my $line (split(/\n/, $output)) { - if ($line =~ /^Device Model:\s+(.+)$/) { + if ( ($line =~ /^Device Model:\s+(.+)$/) + ||($line =~ /^Product:\s+(.+)$/) ) + { $smartdata->{"model"} = [$1, "s"]; } - elsif ($line =~ /^Serial Number:\s+(.+)$/) { + elsif ($line =~ /^Serial Number:\s+(.+)$/i) { $smartdata->{"serial"} = [$1, "s"]; } - elsif ($line =~ /^Firmware Version:\s+(.+)$/) { - $smartdata->{"fw"} = [$1, "s"]; + elsif ($line =~ /^SMART Health Status:\s+(.+)$/i) { + $smartdata->{"health"} = [$1, "s"]; + } + elsif ( ($line =~ /^Firmware Version:\s+(.+)$/) + ||($line =~ /^Revision:\s+(.+)$/) ) + { + $smartdata->{"firmware_version"} = [$1, "s"]; + } + elsif ($line =~ /^Elements in grown defect list:\s+(.+)$/) { + $smartdata->{"elements_in_defect_list"} = [$1, "i"]; + } + elsif ($line =~ /^(read|write|verify):\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(\d+)$/) { + print STDERR "$1 $1_errors_corrected $5 $1_errors_uncorrected $8\n"; + $smartdata->{"$1_errors_corrected"} = [$5, "i"]; + $smartdata->{"$1_errors_uncorrected"} = [$8, "i"]; + } + elsif ($line =~ /^Non-medium error count:\s+(.+)$/) { + $smartdata->{"non_medium_errors"} = [$1, "i"]; } # Capture id, attribute_name, threshold, fail, raw_value (columns 1,2,6,7,8) =pod -- GitLab