Handle errors from Smartctl

This commit is contained in:
prpr 2022-04-24 17:33:49 +01:00
parent 12ecc32e44
commit a34a951a33

View File

@ -30,7 +30,10 @@ puts "
<table>
<tr><th class=key>SMART Status</th><td>$smart<td></tr>
"
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 {
</tr>
}
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