e52a4095e3
1. Start "smartd" service after "DAEMON" - smartd starts too early. 2. Exclude "mfid" device from automatic detection in daily "smart". 3. Add the ability to manually specify the "pass" device with parameters in "periodic.conf" for processing in daily "smart", example: daily_status_smart_devices="pass14,-dsat pass15,-dsat" PR: 288538 Approved by: Oleksii Samorukov <samm@FreeBSD.org> (3 explicit, 1 and 2 timeout > 1 month) Co-authored-by: Anton Saietskii <vsasjason@gmail.com>
92 lines
2.2 KiB
Bash
92 lines
2.2 KiB
Bash
#!/bin/sh
|
|
# This script is in the public domain. Original author: Garrett Wollman
|
|
|
|
if [ -r /etc/defaults/periodic.conf ]; then
|
|
. /etc/defaults/periodic.conf
|
|
source_periodic_confs
|
|
fi
|
|
|
|
smartctl=%%PREFIX%%/sbin/smartctl
|
|
: ${daily_status_smartctl_flags="-H"}
|
|
: ${daily_status_smartctl_extra_status_flags="-a"}
|
|
|
|
case "${daily_status_smart_devices}" in
|
|
# XXX AUTO mode selects only regular ad/da disks
|
|
[Aa][Uu][Tt][Oo])
|
|
daily_status_smart_devices="$(sysctl -n kern.disks | sed -E 's/[[:<:]](cd|ar|vtbd|mfid)[0-9]+//g; s/n(da|vd)/nvme/g')"
|
|
;;
|
|
*) ;;
|
|
esac
|
|
|
|
if [ -z "${daily_status_smart_devices}" ]; then
|
|
: ${daily_status_smart_enable="NO"}
|
|
else
|
|
: ${daily_status_smart_enable="YES"}
|
|
fi
|
|
|
|
trim_junk="tail -n +4"
|
|
|
|
tmpfile="$(mktemp -t daily)"
|
|
trap "rm -f ${tmpfile}" 0 1 3 15
|
|
|
|
rc=0
|
|
case "${daily_status_smart_enable}" in
|
|
[Yy][Ee][Ss])
|
|
echo
|
|
echo 'SMART status:'
|
|
cd /dev
|
|
for device in ${daily_status_smart_devices}; do
|
|
device="${device#/dev/}"
|
|
devflags=""
|
|
case ${device} in
|
|
tw[aes]*) devflags="-d3ware,${device##tw[aes][0-9]*,}"
|
|
device="/dev/${device%,[0-9]*}"
|
|
;;
|
|
ciss*) devflags="-dcciss,${device##ciss[0-9]*,}"
|
|
device="/dev/${device%,[0-9]*}"
|
|
;;
|
|
arcmsr*) devflags="-dareca,${device##arcmsr[0-9]*,}"
|
|
device="/dev/${device%,[0-9]*}"
|
|
;;
|
|
mrsas*) devflags="-dmegaraid,${device##mrsas[0-9]*,}"
|
|
device="/dev/${device%,[0-9]*}"
|
|
;;
|
|
pass*) devflags="${device#pass[0-9]*,}"
|
|
device="/dev/${device%%,[:alpha:0-9-]*}"
|
|
;;
|
|
/*) ;;
|
|
*) device="/dev/${device}"
|
|
;;
|
|
esac
|
|
|
|
if [ -e ${device} ]; then
|
|
echo -n "Checking health of ${device}"
|
|
if [ -n "${devflags}" ]; then
|
|
echo -n " (${devflags})"
|
|
fi
|
|
echo -n ": "
|
|
|
|
${smartctl} ${devflags} ${daily_status_smartctl_flags} ${device} > "${tmpfile}"
|
|
status=$?
|
|
if [ ${status} -eq 0 ]; then
|
|
echo "OK"
|
|
elif [ ${status} -eq 32 ]; then
|
|
echo "OK (but has failed in the past)"
|
|
elif [ $((status & 3)) -ne 0 ]; then
|
|
rc=2
|
|
${trim_junk} "${tmpfile}"
|
|
elif [ `grep -c '^SMART support is: Unavailable' ${tmpfile}` -eq 1 ] ; then
|
|
rc=2
|
|
echo "N/A"
|
|
else
|
|
rc=3
|
|
${smartctl} ${devflags} ${daily_status_smartctl_extra_status_flags} \
|
|
${device} | ${trim_junk}
|
|
fi
|
|
fi
|
|
done
|
|
;;
|
|
esac
|
|
|
|
exit "${rc}"
|