From 6a9ea86ef16e4a0c5970dfab07e9a0e2e93deccf Mon Sep 17 00:00:00 2001 From: Sergey Ivanov <seriv@cs.umd.edu> Date: Tue, 4 Jun 2019 18:09:24 -0400 Subject: [PATCH] improve Core::SMART module --- lib/Core/SMART.pm | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/Core/SMART.pm b/lib/Core/SMART.pm index da94dda..3a9d4a7 100644 --- a/lib/Core/SMART.pm +++ b/lib/Core/SMART.pm @@ -106,10 +106,30 @@ sub handler { elsif ($line =~ /^Firmware Version:\s+(.+)$/) { $smartdata->{"fw"} = [$1, "s"]; } - # Capture attribute_name, value, raw_value (columns 2,4,10) - elsif ($line =~ /^\s*\d+\s(\S+)\s+\S+\s+(\S+)\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+(\S+)/) { - $smartdata->{"$1"} = [$2, "i"]; - $smartdata->{"$1_raw"} = [$3, "i"]; + # Capture id, attribute_name, threshold, fail, raw_value (columns 1,2,6,7,8) +=pod +Vendor Specific SMART Attributes with Thresholds: +ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE + 1 Raw_Read_Error_Rate 0x000b 100 100 016 Pre-fail Always - 0 + 2 Throughput_Performance 0x0004 137 137 000 Old_age Offline - 91 + 3 Spin_Up_Time 0x0007 120 120 024 Pre-fail Always - 317 (Average 313) + +Per https://www.backblaze.com/blog/what-smart-stats-indicate-hard-drive-failures/, +we should check attributes: +ATTRIBUTE DESCRIPTION +SMART 5 Reallocated Sectors Count +SMART 187 Reported Uncorrectable Errors +SMART 188 Command Timeout +SMART 197 Current Pending Sector Count +SMART 198 Uncorrectable Sector Count +=cut + elsif ( ( $line =~ /^\s*(5|187|188|197|198)\s/ ) + && ($line =~ /^\s*(\d+)\s(\S+)\s+\S+\s+\S+\s+\S+\s+(\S+)\s+\S+\s+\S+\s+(\S+)\s+(\S+)/) + ) { + $smartdata->{"$1_name"} = [$2, "s"]; + $smartdata->{"$1_thresh"} = [$3, "i"]; + $smartdata->{"$1_whenfailed"} = [$4, "s"]; + $smartdata->{"$1_raw"} = [$5, "i"]; } } -- GitLab