Postfix for smartd and mdadm

If you are using mdadm and smartd to monitor your hdd and raid, you probably want to be informed if they find any errors or so. So there is postfix which can send mails via sendmail to your e-mail address. It is quite useful to get one of a free webmail service. Would be better to encrypt them though.

First of all, you will need to install postfix (this one is for arch linux, the configuration is the same for ubuntu).

# pacman -S postfix

Now you need to edit the main.cf file, to configure postfix.

# sets gmail as relay
relayhost = [smtp.gmail.com]:587
# use tls
smtp_use_tls=yes
# use sasl when authenticating to foreign SMTP servers
smtp_sasl_auth_enable = yes
# path to password map file
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
# list of CAs to trust when verifying server certificate
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
# eliminates default security options which are incompatible with gmail
smtp_sasl_security_options =

Next thing to do is to give your credentials in a postfix readable form. So write them into /etc/postfix/sasl_passwd:

[smtp.gmail.com]:587 username:password

With it gets into a .db file:

# postmap /etc/postfix/sasl_passwd

After a (re-)start of the postfix deamon:

# rc.d start postfix

you can check via:

# echo ‘hello world!’ | mail -s ‘first email’ username@gmail.com

if it worked.

After that bit is done, you can configure the other deamons to work with your e-mail address. For mdadm you have to add in your /etc/mdadm/mdadm.conf the

MAILADDR username@gmail

option. There can only be one. With

# mdadm –monitor –scan –test

You can check if the mail will be delivered. Now be sure that the demon runs on startup with your pc.

For smartd you need to modify the /etc/smartd.conf like:

DEVICESCAN -a -n standby,15,q -m address@domain.com -M test

If you (re-)start the daemon, you will get a test mail, so after it worked, just delete ‘-M test’ in the config. After -n are options to prevent the disks from idling for a test.

sources:

http://sherlock.heroku.com/blog/2012/02/03/setting-up-postfix-to-use-gmail-as-an-smtp-relay-host-in-archlinux/
http://www.novell.com/support/kb/doc.php?id=7001034
https://wiki.archlinux.org/index.php/S.M.A.R.T.#Email_potential_problems
http://sourceforge.net/apps/trac/smartmontools/wiki/Powermode

~ by frankooh on 2012-10-25T17:33:02+01:00.

2 Responses to “Postfix for smartd and mdadm”

  1. So the demon ran away with my pc.. Now what?

  2. Very helpful guide.
    Thank you for this, this is ‘de facto’ how to make guides.
    There’s also sources :)

Leave a comment