Created
May 17, 2015 05:42
-
-
Save webdestroya/d1711a385c1f7a8698bb to your computer and use it in GitHub Desktop.
Check Load_Cycle_Count rate for drives
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
drives=`sysctl -n kern.disks | awk '{for (i=NF; i!=0 ; i--) print $i }'` | |
echo "+------+-----------------+-----------------+---------+-----------+----------+" | |
echo "|Device|Model |Serial | Power | LCC | LCC/Hr |" | |
echo "+------+-----------------+-----------------+---------+-----------+----------+" | |
for drive in $drives | |
do | |
smartctl -A -i -v 7,hex48 /dev/${drive} | \ | |
awk -v device=${drive} '\ | |
/Serial Number:/{serial=$3} \ | |
/Device Model:/{mfgr=$3} \ | |
/Device Model:/{model=$4} \ | |
/Power_On_Hours/{onHours=$10} \ | |
/Load_Cycle_Count/{lcc=$10} \ | |
END { | |
if(lcc > 0) { | |
lcc_per_hour=lcc/onHours; | |
printf "|%-6s| %.15s | %-15s | %7s |%10u | %.6f |\n", | |
device, model, serial, onHours, lcc, lcc_per_hour; | |
} | |
}' | |
done | |
echo "+------+-----------------+-----------------+---------+-----------+----------+" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment