Skip to content

Instantly share code, notes, and snippets.

@chris13524
Created June 10, 2022 16:26
Show Gist options
  • Save chris13524/761a981a3bde88eecd9950c4b95ca60d to your computer and use it in GitHub Desktop.
Save chris13524/761a981a3bde88eecd9950c4b95ca60d to your computer and use it in GitHub Desktop.
zpool status bad sectors
zpool status | while IFS=$'\n' read line; do
if [[ "$line" == *"ata-"* ]]; then
id=$(echo "$line" | grep -oP '(ata-[^\s]+)')
count=$(sudo smartctl -a /dev/disk/by-id/$id | grep Reallocated_Sector_Ct | grep -oP '(\d+)$')
echo "$line - bad sectors: $count"
else
echo "$line"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment