Ubuntu Linux Email Notification on Hard Disk S.M.A.R.T Errors

This is a short guide on setting up sendmail command on Ubuntu to work with smartmontools to monitor SMART statuses of drives and send email notifications on any failures.

1. Setup sendmail to relay to an external SMTP server (Gmail, hotmail, your own host).

sudo apt-get install postfix

/etc/postfix/main.cf

...
myhostname = yourhostname
relayhost = [yourhosturl]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes
...

/etc/postfix/sasl_passwd

[yourhosturl]:587 username:password
sudo chmod 400 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd
sudo service postfix restart

2. Test sendmail.

echo -e "Subject: it works\nYAY!" | sendmail [email protected] \
-F yourhostname

3. Setup smartmontools to monitor drives and send notifications on failure.

sudo apt-get install smartmontools

/etc/smartd.conf

/dev/sda -H -l error -l selftest -f -s (S/../../1/01) -m \
[email protected] -M exec /usr/share/smartmontools/smartd-runner

/etc/default/smartmontools

start_smartd=yes
sudo service smartmontools restart

ref:
https://linux.die.net/man/5/smartd.conf
https://easyengine.io/tutorials/linux/ubuntu-postfix-gmail-smtp/

This entry was posted in Uncategorized and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *