Skip to content

Instantly share code, notes, and snippets.

@dasjoe
Last active November 20, 2018 09:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dasjoe/a7252e3f737ec36de36f to your computer and use it in GitHub Desktop.
Save dasjoe/a7252e3f737ec36de36f to your computer and use it in GitHub Desktop.
Check SMART values for ata-* disks
#!/bin/bash
DIR='/dev/disk/by-id/'
#DIR='/dev/disk/by-vdev/'
#DIR='/dev/disk/by-path/'
PREFIX='ata-*'
#PREFIX='pci-*'
#PREFIX='*'
while IFS= read -r -d '' disk
do
smartctl -a "$disk" \
| egrep "self-assessment test result|^ 5 |^187 |^19(6|7|8) " \
| egrep -v 'PASSED$| 0$' \
&& echo -e "$disk\n" \
|| true
done < <(find "$DIR" -xtype b -name "$PREFIX" -not -name '*-part*' -print0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment