From facd6beee4c46dc34b25a2eb04afedbe265de614 Mon Sep 17 00:00:00 2001 From: prpr Date: Sun, 24 Apr 2022 17:33:49 +0100 Subject: [PATCH] Handle errors from Smartctl --- webif/html/diag/disk.jim | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/webif/html/diag/disk.jim b/webif/html/diag/disk.jim index f6f0dc0e..4dc06589 100755 --- a/webif/html/diag/disk.jim +++ b/webif/html/diag/disk.jim @@ -30,7 +30,10 @@ puts " " -foreach line [split [exec /bin/smartctl -i $device] "\n"] { +if {[catch {set msg [exec /bin/smartctl -i $device]} xmsg]} { + set msg $xmsg +} +foreach line [split $msg "\n"] { if {[string match "*Not in smartctl database*" $line]} continue if {[string match "*: *" $line]} { regsub -all -- {[[:space:]]+} $line " " line @@ -95,8 +98,11 @@ set nolife {184 187 188 189 191 197 198} set derive {4 "" 5 sectors 9 hours 12 cycles 192 "" 193 "cycles"} +if {[catch {set msg [exec /bin/smartctl -A $device]}]} { + set msg "" +} set i 0 -foreach line [split [exec /bin/smartctl -A $device] "\n"] { +foreach line [split $msg "\n"] { regsub -all -- {[[:space:]]+} $line " " line regsub -all -- {^[[:space:]]+} $line "" line if {[incr i] < 8} continue @@ -185,8 +191,8 @@ puts { } -if {[catch {set msg [exec /bin/smartctl -l selftest $device]} xmsg]} { - set msg $xmsg +if {[catch {set msg [exec /bin/smartctl -l selftest $device]}]} { + set msg "" } set i 0
SMART Status$smart