Skip to content

Instantly share code, notes, and snippets.

@dadatuputi
Last active February 12, 2024 16:13
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dadatuputi/5925703c69471be7f59e5a50c4289e24 to your computer and use it in GitHub Desktop.
Save dadatuputi/5925703c69471be7f59e5a50c4289e24 to your computer and use it in GitHub Desktop.
Run SMART tests on a ZFS pool
#!/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