Smard configuration for Megaraid and notices by email.

below:
File of configuration:

/dev/sg2 -a -d megaraid,N  -T permissive -o on -S on -W 5,30,35 -s (S/../.././11|L/../../7/03) -m info@email.com, support@email.com -M test -M diminishing -M exec /etc/smartd_mail.sh
/dev/sda -a -d sat -T permissive -o on -S on -W 5,30,35 -s (S/../.././11|L/../../7/03) -m info@email.com,support@email.com -M test -M diminishing -M exec /etc/smartd_mail.sh

File for email:


#!/bin/bash 
##########################
echo "-----------------------------------------------" > /tmp/tempfile
##########################
cat >> /tmp/tempfile
##########################
echo "-----------------------------------------------" >> /tmp/tempfile
##########################

# Echo command line arguments into temp file
echo "Command line argument 1: $1" >> /tmp/tempfile
echo "Command line argument 2: $2" >> /tmp/tempfile
echo "Command line argument 3: $3" >> /tmp/tempfile

##########################
echo "-----------------------------------------------" >> /tmp/tempfile
##########################

# Echo environment variables into a temp file
echo "Variables are:" >> /tmp/tempfile
echo "SMARTD_DEVICE - $SMARTD_DEVICE" >> /tmp/tempfile
echo "SMARTD_DEVICESTRING - $SMARTD_DEVICESTRING" >> /tmp/tempfile
echo "SMARTD_DEVICETYPE - $SMARTD_DEVICETYPE" >> /tmp/tempfile
echo "SMARTD_MESSAGE - $SMARTD_MESSAGE" >> /tmp/tempfile
echo "SMARTD_FULLMESSAGE - $SMARTD_FULLMESSAGE" >> /tmp/tempfile
echo "SMARTD_ADDRESS - $SMARTD_ADDRESS" >> /tmp/tempfile
echo "SMARTD_SUBJECT - $SMARTD_SUBJECT" >> /tmp/tempfile
echo "SMARTD_SUBJECT - $SMARTD_TFIRST" >> /tmp/tempfile
echo "SMARTD_TFIRSTEPOCH - $SMARTD_TFIRSTEPOCH" >> /tmp/tempfile

##########################
echo "-----------------------------------------------" >> /tmp/tempfile
##########################
shopt -s extglob
SMARTD_DEVICE=${SMARTD_DEVICE%%?(\[*\])}
shopt -u extglob
/usr/sbin/smartctl -a -d $SMARTD_DEVICETYPE $SMARTD_DEVICE >> /tmp/tempfile
##########################
echo "-----------------------------------------------" >> /tmp/tempfile
##########################

/bin/mail -s "SMARTD MESSAGE FROM: `hostname` at `date`" $SMARTD_ADDRESS < /tmp/tempfile

exit 0

Download file: smartd_mail.sh.tar

Scroll to top