Configure multiple E-mail servers

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
mallu0987
Posts: 2
Joined: Wed Feb 27, 2013 10:51 am

Configure multiple E-mail servers

Post 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.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Configure multiple E-mail servers

Post by sreinhardt »

By default there is not another option from /bin/mail. However you may try something like Send HTML Email Alert v2
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
mallu0987
Posts: 2
Joined: Wed Feb 27, 2013 10:51 am

Re: Configure multiple E-mail servers

Post by mallu0987 »

Thank you for the suggestion. Unfortunately we don't have php installed on this host.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Configure multiple E-mail servers

Post 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.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked