Public domain
if [ -x /usr/sbin/smartd ]; then
/usr/sbin/smartd
fi
#DEVICESCAN
/dev/sda -a -d ata -o on -S on -s (S/../.././02|L/../../6/03) -m root -M exec /usr/local/sbin/smartd-logger
/dev/sdb -a -d ata -o on -S on -s (S/../.././02|L/../../6/03) -m root -M exec /usr/local/sbin/smartd-logger
/dev/sdc -a -d ata -o on -S on -s (S/../.././02|L/../../6/03) -m root -M exec /usr/local/sbin/smartd-logger
#!/bin/bash
#
LOGFILE="/var/log/smartd.log"
# Save standard input into a temp file
echo "----- MARK -----" >> ${LOGFILE}
date >> ${LOGFILE}
# Echo environment variables into a temp file
echo "Variables are": >> ${LOGFILE}
echo "$SMARTD_DEVICE" >> ${LOGFILE}
echo "$SMARTD_DEVICESTRING" >> ${LOGFILE}
echo "$SMARTD_DEVICETYPE" >> ${LOGFILE}
echo "$SMARTD_MESSAGE" >> ${LOGFILE}
echo "$SMARTD_FULLMESSAGE" >> ${LOGFILE}
echo "$SMARTD_ADDRESS" >> ${LOGFILE}
echo "$SMARTD_SUBJECT" >> ${LOGFILE}
echo "$SMARTD_TFIRST" >> ${LOGFILE}
echo "$SMARTD_TFIRSTEPOCH" >> ${LOGFILE}
# Run smartctl -a and save output in temp file
/usr/sbin/smartctl -a -d $SMARTD_DEVICETYPE $SMARTD_DEVICE >> ${LOGFILE}
# Email the contents of the temp file. Solaris and other OSes
# may need to use /bin/mailx not /bin/mail.
/bin/mail -s "SMART errors detected on host: `hostname`" $SMARTD_ADDRESS < ${LOGFILE}
# And exit
exit 0
chmod +x /usr/local/sbin/smartd-logger
/usr/sbin/smartd
BY: Pejman Moghadam
TAG: smartd
DATE: 2009-06-29 15:57:41