Browse Source

add temp, and deal w/ drives that don't report it (or other things)..

main
John-Mark Gurney 3 years ago
parent
commit
cb75e51eb9
1 changed files with 18 additions and 10 deletions
  1. +18
    -10
      diskstat

+ 18
- 10
diskstat View File

@@ -8,23 +8,31 @@ BEGIN {
}

function printdiskinfo(lblname, devname) {
cmd = "smartctl -a /dev/" devname " | egrep '"'"'Device Model|Power_On_Hours'"'"'"
cmd = "smartctl -a /dev/" devname " | egrep '"'"'Temperature_Celsius|Device Model:|Power_On_Hours'"'"'"
r = cmd | getline
#print "xfoox" r "x" $0 "xbarx"

model = "unknown"
hours = 0
temp = "unkn"
if (r) {
$1 = ""
$2 = ""
model = $0
cmd | getline
hours = $10
} else {
model = "unknown"
hours = 0
for (i = 0; i < 3; i++) {
if ($1 == "Device" && $2 == "Model:") {
$1 = ""
$2 = ""
model = sprintf("%-*s", 4*8 - 1, $0)
} else if ($2 == "Temperature_Celsius") {
temp = $10
} else if ($2 == "Power_On_Hours") {
hours = $10
}
r = cmd | getline
}
}
close(cmd)

years = sprintf("%.4g", ( hours / 24. / 365 ))
print lblname "\t->\t" devname "\t->\t" disksize[devname] " TB\t->\t" years "\t" model
print lblname "\t->\t" devname "\t->\t" disksize[devname] " TB\t->\t" years "\t" model "\t" temp
delete disksize[devname]
}



Loading…
Cancel
Save