Page 1 of 1
Configure multiple E-mail servers
Posted: Wed Feb 27, 2013 10:58 am
by mallu0987
I have Nagios monitoring postfix along with other services on a server. The client is like to get e-mail alert if postfix stop working. Is there anyway we can configure nagios to use a remote e-mail server if the local postfix is not working? If that is not possible, how can I configure nagios to use remote e-mail server all the time? From what I understand Nagios is using /bin/mail on my host for sending e-mails. Appreciate all your help.
Re: Configure multiple E-mail servers
Posted: Wed Feb 27, 2013 11:41 am
by sreinhardt
By default there is not another option from /bin/mail. However you may try something like
Send HTML Email Alert v2
Re: Configure multiple E-mail servers
Posted: Wed Feb 27, 2013 11:54 am
by mallu0987
Thank you for the suggestion. Unfortunately we don't have php installed on this host.
Re: Configure multiple E-mail servers
Posted: Thu Feb 28, 2013 2:08 pm
by abrist
Any email client that can be passed a message from the cli through a pipe ("|") can be used with nagios. You will need to create custom notification commands. This includes altering the path to the new binary and changing any syntax to the expected syntax for the new client:
Code: Select all
# 'notify-host-by-email' command definition
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" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
You should copy the notification commands from commands.cfg, make sure to change the command names so they do not conflict with the standard notification commands. Everything after the pipe ("|") in tehse commands may have to be modified to accommodate the syntax of the new email client.