Allow HD to collect disk stats.

This commit is contained in:
prpr 2022-04-24 17:36:35 +01:00
parent a34a951a33
commit 97b24da0ed

View File

@ -3,8 +3,6 @@
source /mod/webif/lib/setup
require system.class settings.class
if {[system model] eq "HD"} exit
set disk [system disk]
set settings [settings]
@ -20,7 +18,10 @@ if {$line ne ""} {
}
# Extract disk model.
foreach line [split [exec /bin/smartctl -i $disk] "\n"] {
if {[catch {set msg [exec /bin/smartctl -i $disk]}]} {
set msg ""
}
foreach line [split $msg "\n"] {
if {[string match "*Not in smartctl database*" $line]} continue
if {[string match "*: *" $line]} {
regsub -all -- {[[:space:]]+} $line " " line
@ -31,7 +32,11 @@ foreach line [split [exec /bin/smartctl -i $disk] "\n"] {
}
# Extract disk attributes.
foreach line [split [exec /bin/smartctl -A -f brief $disk] "\n"] {
if {[catch {set msg [exec /bin/smartctl -A -f brief $disk]}]} {
set msg ""
}
set attrs {}
foreach line [split $msg "\n"] {
regsub -all -- {[[:space:]]+} $line " " line
regsub -all -- {^[[:space:]]+} $line "" line
lassign [split $line] id name flags val worst thresh when rval