Nagios uses sendmail, new mail server, need to change SMTP server

8,168

Nagios actually uses external commands to send email—it doesn't send them directly. For example, in our config here, /etc/nagios3/commands.cfg contains (in part):

define command{
    command_name    notify-host-by-email
    command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
    }

if you scroll to the right, you'll see that it's sending via /usr/bin/mail. mail generally uses the system MTA (Exim in my case, but probably not yours).

If yours is also going through the system MTA, you'll probably find the Email chapter of the Deployment Guide useful, in particular its two MTA sections.

Share:
8,168

Related videos on Youtube

Trim
Author by

Trim

Updated on September 18, 2022

Comments

  • Trim
    Trim almost 2 years

    I'm working with a CentOS server that has Nagios running and sending notification emails. The emails are still going to the old email system which was kept up to ensure all emails were being routed to the correct location. I didn't set the system up, but it appears that this machine was able to relay to the smtp server to send mail? It still sends it through to the old system. I have the hostname for the new SMTP server but I'm not sure where I need to input this data.

  • Trim
    Trim almost 11 years
    I'm sorry if I wasn't clear, but the commands were already setup before me and they use the "/usr/sbin/mail" command to send emails. I updated the sendmail.mc configuration file to point the "Smart Host" at my smtp server. Everything seems to be working for now.