Skip to content

Instantly share code, notes, and snippets.

@crazy-max
Created August 13, 2017 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crazy-max/b95b936b4d3888af8e0b5a46eab46697 to your computer and use it in GitHub Desktop.
Save crazy-max/b95b936b4d3888af8e0b5a46eab46697 to your computer and use it in GitHub Desktop.
Checking disks for important SMART errors
#/bin/bash
TMP_FILE=/tmp/check-smart-errors.log
for I in $(ls /sys/block); do
smartctl -a /dev/$I > $TMP_FILE
if [ "$?" -ne "1" ]; then
DEVICE_MODEL="$(smartctl -a /dev/$I | grep -i 'device model')"
echo "DISK $I - $DEVICE_MODEL"
cat "$TMP_FILE" | grep -v "\- 0" | grep Raw_Read_Error_Rate
cat "$TMP_FILE" | grep -v "\- 0" | grep Reallocated_Event_Count
cat "$TMP_FILE" | grep -v "\- 0" | grep Reallocated_Sector_Count
cat "$TMP_FILE" | grep -v "\- 0" | grep Reported_Uncorrectable_Errors
cat "$TMP_FILE" | grep -v "\- 0" | grep Command_Timeout
cat "$TMP_FILE" | grep -v "\- 0" | grep Current_Pending_Sector_Count
cat "$TMP_FILE" | grep -v "\- 0" | grep Offline_Uncorrectable
cat "$TMP_FILE" | grep -v "\- 0" | grep CRC_Error_Count
cat "$TMP_FILE" | grep -v "\- 0" | grep Seek_Error_Rate
cat "$TMP_FILE" | grep "^ATA Error Count"
cat "$TMP_FILE" | grep "^Error [0-9]* occurred at disk"
echo "----------------"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment