Last active
January 11, 2025 15:42
-
-
Save dadatuputi/5925703c69471be7f59e5a50c4289e24 to your computer and use it in GitHub Desktop.
Run SMART tests on a ZFS pool
This file contains hidden or 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 | |
usage() { echo "Usage: $0 -p <POOL> (-s|-l)" 1>&2; exit 1; } | |
while getopts ":p:sl" o; do | |
case "${o}" in | |
p) | |
p=${OPTARG} | |
;; | |
s) | |
test=short | |
;; | |
l) | |
test=long | |
;; | |
*) | |
usage | |
;; | |
esac | |
done | |
shift $((OPTIND-1)) | |
if [ -z "${p}" ] || [ -z "${test}" ]; then | |
usage | |
fi | |
drives="$(zpool status -LP ${p} | grep /dev/ | awk '{print $1}')" | |
for drive in ${drives} | |
do | |
smartctl="/usr/sbin/smartctl" | |
command=( $smartctl -t $test $drive ) | |
echo ${command[@]} | |
"${command[@]}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment