Configure nagios to use backup mailserver for notifications


Hello all,

Not a hard question, however I can’t connect the strings together to get it working:

I want nagios to use a secondary mailserver if my primary mailserver goes down.

The best would be if nagios just automatically determines if the primary mailserver is up, and if it would be down, use the secondary mailserver for the notifications. However I am happy enough if I could just configure nagios to use my secondary mailserver for only the notifications about my primary mailserver, so he uses my secondary mailserver if there are notifications about my primary mailserver being down.

I know I just have to create a second host and service notification, however I don’t really know how to connect the second notifications with the specific exchange host or a specific hosts group.

At the moment, I just get nothing when my primary mailserver goes down.

Thanks in advance!


do you have a mail server on your nagios server? it’s not nagios’s business to route mail :slight_smile:


I’m sorry, had to be a little bit more specific.

I have sendemail installed, so I can send my email with a command, the command is set in my commands.cfg:

define command{ command_name notify-host-by-email command_line usr/bin/sendEmail -f nagios@*****.com -t $CONTACTEMAIL$ -u $HOSTNAME$ -s -xu nagios -xp ***** -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n"

I have to create a second command, with an other server-ip (and the right credentials) and rename the command_name. However I don’t know how to connect the second command to notifications relating our EXCHANGE server


I already found out how to do what I wanted.

I created a second notification command that uses the external backup mailserver.

I then created a contact, put the contact in a contacts group, and told the contacts group to use the other newly created commands for notifications.

I then went to the hosts config file, and added a line in the host and service definitions to notify the newly created group.

Everything works like a charm!

If anybody would like me to be more specific, just reply.
However I think you guys know how to do this already, and I sorted it out myself before anybody could give me an answer :slight_smile:


aren’t you receiving double notifications this way?


It could be that nagios would try to send double notifications, however, I will never get any notifications twice, because when nagios sends to the second mailserver, the first mailserver is down, and will be unreachable for relaying notifications.

What I don’t know, is, if you set the parameter “contact_groups” in the host definition, if nagios will append the manually entered contact_groups, of if nagios will ignore the default notify config, and ONLY use the manually given contact_groups…

That’s something nice to try and figure out :slight_smile:


i’m not sure i understood :smiley:

you created a notification command which is only used for a check towards the first mailserver? (that would make sense) :slight_smile:


[quote=“luca”]i’m not sure i understood :smiley:

you created a notification command which is only used for a check towards the first mailserver? (that would make sense) :)[/quote]

Sorry if I were blurry.

I created a notification command that is only used on the primary mailserver indeed. The notification command is connected to the newly created contact group, and the contact group is configured at the primary mailserver, so the primary mailserver does not notify the default contact group but the newly created contact group that has the notification command using backup mailserver.



looks like a good way to solve the problem :slight_smile: