Configuring Nagios to send notifications via Exchange server

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.
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Configuring Nagios to send notifications via Exchange server

Post by neworderfac33 »

Good morning,

Totally encouraged by the support I received with my first post, I'm having another go on another subject!

I have now managed to configure Nagios Core to monitor a pair of servers and I now need to get it to send email notifications.

We have a Microsoft Exchange server, but in all the articles I've Googled, none of them seem to mention where you specify the email server ID.

I have executed a Dig command (dig [email protected] mx) to prove that Nagios can communicate with the server in question, and it returns a result that indicates that this is the case.

(EDIT)
I've now confirmed that I have postfix-2.6.6-6.e16_5.x86_64 installed on my server, which is running RedHat Enterprise 6.6
Am I correct in my assumption that Nagios talks to PostFix and it's PostFix that needs to be configured with details of my Exchange mail server... or should I go and lie down in a darkened room again?

Cheers

Pete
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Configuring Nagios to send notifications via Exchange se

Post by jdalrymple »

Nagios is already configured to send mail directly from the Postfix mail server installed on it. Your problem is likely that Exchange isn't configured to handle mail received internally from the Nagios server. Take a look at this guys' blog entry, it gives pretty clear instruction and if nothing else may make you better able to understand what's going on:

https://glazenbakje.wordpress.com/2012/ ... connector/

Exchange is great, except when it makes the simple parts more complicated.
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Configuring Nagios to send notifications via Exchange se

Post by neworderfac33 »

Thank you for your reply - apologies for not replying sooner, I was on leave yesterday.

I have spoken to our Messaging team and it seems that it will be possible for our email server to process emails sent by Nagios/PostFix. I have used FSO emailing within Excel/VBA applications referring to this mail server and I don't encounter any issues.

The challenge I now have is where do I specify the name of the Exchange server - somewhere within PostFix?

Thanks

Pete
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Configuring Nagios to send notifications via Exchange se

Post by neworderfac33 »

I think I figured this bit out by adding the IP address of my exchange server to relayhost=99.99.99.99 to /etc/postfix/main.cf

In /usr/local/nagios/etc/objects/commands.cfg, I changed all occurrences of /bin/mail to /usr/bin/mailx

Finally, in /usr/local/nagios/etc/objects/contacts.cfg I substituted my email address in the "email" line within "define_contact"

I restarted PostFix and Nagios, having set a diskspace threshold on one of my monitored drive to alert when it's down to 90% available (its currently 40%, so that should be alerting fine).

Except that it isn't. There are so many suggestions and bits of advice out there, I sometimes wonder which is correct or applicable and which isn't!

Hope someone can help out before the weekend! :-)

Thanks

Pete
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Configuring Nagios to send notifications via Exchange se

Post by jdalrymple »

Are you trying to send E-mail to any addresses besides ones that Exchange server handles? If so you've already done too much work.

Or are you trying to send stuff to both @myinternalmail.com and also @gmail.com?
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Configuring Nagios to send notifications via Exchange se

Post by neworderfac33 »

At the moment, I just want to send it to myself [email protected], whilst I'm testing it out.

However, I'm eventually going to want it to send to distribution lists that are held on the Exchange server such as "[email protected]"

Nothing external to the company either - all emails will be to [email protected] - no Gmail or anything like that.

How do you mean, I've done too much? :)

Pete
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Configuring Nagios to send notifications via Exchange se

Post by jdalrymple »

So if you have no desire to send to anyone except [email protected] there is no need for a relayhost. You can undo everything you did on the XI server - it is already configured to handle e-mailing [email protected] right out of the box.

The process looks like this for E-mailing [email protected]

Postfix gets the message to be processed
Postfix requests the MX record for "whereiwork.com" from its DNS servers, it should get an IP back that belongs to your Exchange servers hosting the external connectors
Postfix sends the mail straight there over TCP 25 - standard sendmail stuff - the only tricky part is making Exchange accept it, as I described earlier. Your messaging team should be able to interpret this for you if it doesn't make any sense.

The only time mail gets complicated is if your Nagios server is unable to speak directly to port 25 on your mail server - this is typically only the case when the mail has to take a trip outside your network.
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Configuring Nagios to send notifications via Exchange se

Post by neworderfac33 »

Good morning - apologies for not having got back to you sooner, but I've been on leave from work.

So what you're saying is that PostFix should be able to resolve the "@WhereIWork" part of the email address and simply send my email alerts without me having to specify the name/IP of my Exchange server at all - providing there is connectivity to Port 25.

So, the change I made to /etc/postfix/main.cf where I added the line "relayhost = 99.99.99.99" is redundant and I can comment it back out again?

My next query then is with the messaging team to check the Port 25 issue!

Thanks

Pete
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Configuring Nagios to send notifications via Exchange se

Post by neworderfac33 »

Following the advice from another Internet source (http://www.telnetport25.com/2012/02/con ... gios-core/), within /usr/local/nagios/etc/objects/commands.cfg, I also changed all references to "/bin/mail" to "/usr/bin/mailx"

Should I undo these changes also?

Cheers
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Configuring Nagios to send notifications via Exchange se

Post by tmcdonald »

In the grand scheme, you can use basically either mail program to send email:

http://unix.stackexchange.com/questions ... -and-mailx

But you may need to adjust your commands to use the right arguments for the mailx command.

Personally, for the sake of us supporting you, I would keep it to mail for now. That way once you get it working with that, we can possibly look at getting it switched.

Let us know what your mail team says!
Former Nagios employee
Locked