Created
February 8, 2019 22:27
-
-
Save boombatower/810ae6fbdf8649edac6ca040e272b9e5 to your computer and use it in GitHub Desktop.
Wrapper script for smartctl to correct S.M.A.R.T. attribute values for Seagate 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/bash | |
# Correct S.M.A.R.T. attribute values for Seagate drives | |
# https://serverfault.com/questions/313649/how-to-interpret-this-smartctl-smartmon-data | |
meta_value() | |
{ | |
echo "$1" | grep -oP ":\s+\K.*" | |
} | |
correct_value() | |
{ | |
if [ $correct -eq 1 ] ; then | |
echo -n "$(echo "$1" | grep -oP "(\s+\S+){7}\s+")" | |
echo "$(("$(echo "$1" | grep -oP "(\s+\S+){7}\s+\K\d+")" >> 32))" | |
else | |
echo "$1" | |
fi | |
} | |
IFS=$'\n' | |
output=($(smartctl $@)) | |
correct=0 | |
for line in ${output[@]} ; do | |
case "$line" in | |
*"Model Family"*) | |
if [[ "$(meta_value "$line")" == *"Seagate"* ]] ; then | |
correct=1 | |
fi | |
echo "$line" | |
;; | |
*Raw_Read_Error_Rate*) | |
correct_value "$line" | |
;; | |
*Seek_Error_Rate*) | |
correct_value "$line" | |
;; | |
*) | |
echo $line | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment