Skip to content

Instantly share code, notes, and snippets.

@zentrification
Last active August 29, 2019 16:23
Show Gist options
  • Save zentrification/a39a1d1c758918674f45b1989c91c961 to your computer and use it in GitHub Desktop.
Save zentrification/a39a1d1c758918674f45b1989c91c961 to your computer and use it in GitHub Desktop.
#!/bin/bash
# https://www.backblaze.com/blog/what-smart-stats-indicate-hard-drive-failures/
ATTRIBUTES=" 5|187|188|197|198"
for DRIVE in `ls /dev/sd[a-z]`; do
COUNT=$(sudo smartctl -A $DRIVE | grep -E "$ATTRIBUTES" | grep -v " 0$" | wc -l)
echo ""
echo $DRIVE
echo "$COUNT attributes failing"
if (($COUNT > 0)); then
sudo smartctl -A $DRIVE | grep -E "$ATTRIBUTES" | grep -v " 0$"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment