Handle SMART error counters more intelligently

This commit is contained in:
prpr 2022-04-20 12:17:06 +01:00
parent 1e53bc1b37
commit 9b8e6763af
2 changed files with 25 additions and 10 deletions

View File

@ -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
}

View File

@ -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