Use OMD with ssmtp

If you use Open Monitoring Distribution (OMD) and don’t want to setup a full-fledged Postfix or Sendmail service (e.g. because it is a test system) you might want to have a look at the alternative tool ssmtp for relaying mails to an external mail server. The tool is only recommend if you don’t need any local mail transfers.

Of course this works with Postfix and Sendmail as well but implementing this task is – depending on the configuration the mail server – more time-comsuming (e.g. because canonical maps, SASL, SSL/TLS have to be configures). I prefer ssmtp for fast setups because I can do all the configuration tasks in one single file and this takes not even 5 minutes.

First of all you’ll have to install ssmtp:

# yum install -y ssmtp
# cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.initial
# vi /etc/ssmtp/ssmtp.conf

Afterwards you should test the functionality of ssmtp at least once – it’s recommended to have a look in the protocol file /var/log/maillog:

# uptime|sendmail mail@hoster.tld
# tail -f /var/log/maillog

If sending mails is working fine you’ll have to customize a script inside the appropriate OMD site – have a look at the variable $mail in line 16:

# vi /opt/omd/sites/SITE/lib/nagios/plugins/
my $mail     = $ENV{'OMD_ROOT'}.'/bin/mail -t';

You’ll need to adjust the line like this:

my $mail     = $ENV{'OMD_ROOT'}.'/bin/mail';

A symbolic link inside the site has to be adjusted so that the mail command points to the ssmtp utility:

# rm /opt/omd/sites/SITE/bin/mail
# ln -s $(which ssmtp) /opt/omd/sites/SITE/bin/mail

It might be possible that your mail provides claims that you use sender addresses that are assigned to your server – if so, edit the file /etc/ssmtp/revaliases:


Sending mails from inside the site should work now:

# su - SITE
$ uptime|sendmail mail@hoster.tld

All notifications are now sent using ssmtp – it is recommended to disable the previously used mail service and set a symbolic link if you also need to send mails from outside the OMD site:

# chkconfig postfix off
# service postfix stop
# rm /etc/alternatives/mta
# ln -s $(which ssmtp) /etc/alternatives/mta

Of course this works only if you don’t need local mail transfer. 😉

Sharing is caring

Leave a Reply