From 9b8e6763af23df744cf22338bad79ec15d43199d Mon Sep 17 00:00:00 2001 From: prpr Date: Wed, 20 Apr 2022 12:17:06 +0100 Subject: [PATCH] Handle SMART error counters more intelligently --- webif/html/diag/diskack.jim | 4 +--- webif/include/diskcheck.jim | 31 ++++++++++++++++++++++++------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/webif/html/diag/diskack.jim b/webif/html/diag/diskack.jim index 331574b..a9dafd7 100755 --- a/webif/html/diag/diskack.jim +++ b/webif/html/diag/diskack.jim @@ -7,10 +7,8 @@ httpheader set settings [settings] -foreach attr {realloc pending offline} { +foreach attr {realloc pending offline spinretry} { set val [$settings _nval_setting "SMART_$attr"] if {$val < 0} continue $settings _nval_setting "SMART_ack_$attr" $val } - - diff --git a/webif/include/diskcheck.jim b/webif/include/diskcheck.jim index e79660a..d872915 100755 --- a/webif/include/diskcheck.jim +++ b/webif/include/diskcheck.jim @@ -4,6 +4,19 @@ source /mod/webif/lib/setup require system.class require settings.class +proc {system disksmarterror} {sa count ack_count} { + if {$sa eq "spinretry"} { + set msg "Disk $sa count is: $count" + } else { + set msg "Disk $sa sector count is: $count" + } + if {$ack_count > 0} { + append msg " (was $ack_count)" + } + append msg "\n" + return $msg +} + proc {system disksmart} {} { set smartmsg "" @@ -26,19 +39,23 @@ proc {system disksmart} {} { # (SMART_ack_status 0 SMART_ack_pending 0 SMART_status PASSED SMART_pending 7 SMART_ack_realloc 0 SMART_ack_offline 0 SMART_realloc 0 SMART_offline 7) - if {$smartattribs(SMART_status) ne "PASSED"} { + if {$smartattribs(SMART_status) ne "PASSED" && + $smartattribs(SMART_status) ne "Unknown"} { append smartmsg \ "Disk overall health assessment is: $smartattribs(SMART_status)\n" } foreach sa $smartattrs { - if {$smartattribs(SMART_$sa) != $smartattribs(SMART_ack_$sa)} { - append smartmsg \ - "Disk $sa sector count is: $smartattribs(SMART_$sa)" - if {$smartattribs(SMART_ack_$sa) > 0} { - append smartmsg " (was $smartattribs(SMART_ack_$sa))" + set count $smartattribs(SMART_$sa) + set ack_count $smartattribs(SMART_ack_$sa) + if {$count > $ack_count} { + append smartmsg [system disksmarterror $sa $count $ack_count] + } elseif {$count < $ack_count} { + if {($sa eq "pending" || $sa eq "offline") && ($count > 0)} { + append smartmsg [system disksmarterror $sa $count $ack_count] + } else { + [settings] _nval_setting "SMART_ack_$sa" $count } - append smartmsg "\n" } } return $smartmsg