Page 1 of 1

Send mail notifications

Posted: Thu May 16, 2013 3:44 am
by alexmati
Hi to all,

I 'm new to nagios and ubuntu so please be gently to me :)

I have install ubuntu on a VM and NagiosĀ® Coreā„¢ Version 3.4.4.

I have add two hosts and everything works fine.

What i want is to Nagios can send mail notification if an error occurs.

I have read a lot of articles and says that i have to install postfix and mailx. Is this right.

FYI: I have a windows exchange server, so i don't want to install mail server to ubuntu machine. What i want is Nagios can use the existing mail server to send notifications.

Thanks you.

Re: Send mail notifications

Posted: Thu May 16, 2013 11:53 am
by abrist
You will still need an mta to forward the mail to your exchange server. See: http://www.telnetport25.com/2012/02/con ... gios-core/

Re: Send mail notifications

Posted: Mon May 20, 2013 11:19 am
by alexmati
Hi again,

I have install postfix and mailx from the link you gave me.

I think the mail server is working because when i run telnet from this link (http://www.linux.com/component/content/ ... ail-server) i have the same results.

When i send custom notification from nagios i don't receive any mail.

FYI: 1) I haven't join the nagios server to domain.
2) Exchange server in configured to allow to send as anonymous

Maybe the solution is easy but i am a newby to ubuntu and nagios.

Thank you

Re: Send mail notifications

Posted: Mon May 20, 2013 3:16 pm
by sreinhardt
Did you also configure your exchange server to have a receive connector specific to nagios or allow nagios' IP on the existing one access to send to the server? Is the exchange server configured for anonymous smtp connections? Are you sending to the same domain as the exchange server or is it different?

Re: Send mail notifications

Posted: Tue May 21, 2013 1:33 am
by alexmati
Hi sreinhardt,

I allow nagios IP to send to the server.
Exchange server configured for anonymous smtp connections.

I am sending to the same domain where the exchange server is but as i told you before, nagios server is not joined into domain.

Thank you

Edit: i see this in mail.log

Code: Select all

May 21 15:36:54 SAVSGATH01AP09 postfix/error[29695]: 16329221903: to=<*******.********@******.***>, relay=none, delay=216068, delays=216068/0.01/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: connect to ****.*********.***[IP***.**.***.***]:25: Connection timed out)
The name and the IP of the server used in mail.log is through an external mail server and blocks it the firewall.
I miss something in order to send directly into domain?

Here is my main.cf configuration:

Code: Select all

myhostname = ubuntu_server_name
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = mymailserver.mydomain.net, nagios.notify-gr, ubuntu_server_name, localhost.localdomain, localhost
relayhost = 
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mydomain = mydomain.net
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

Re: Send mail notifications

Posted: Tue May 21, 2013 1:15 pm
by sreinhardt
The name and the IP of the server used in mail.log is through an external mail server and blocks it the firewall.
I miss something in order to send directly into domain?
Maybe I missed this before, but you have a firewall in between that is blocking the connection on port 25? If that is the case, this port needs to get opened, or it doesn't matter how much configuration on either nagios or exchange is done, it will never work.
I am sending to the same domain where the exchange server is but as i told you before, nagios server is not joined into domain.
This is perfectly fine and normal, I just wanted to be sure they were the same name as exchange servers by default will not relay to another domain to prevent spam and generally will not even take in the message if it is not for their internal known domains. The nagios server does not need to be connected to it at all.

Can you telnet or nmap the smtp port from your nagios machine?

Code: Select all

telnet [IP of exchange server]:25
nmap [IP of exchange server] -p 25

Re: Send mail notifications

Posted: Tue May 21, 2013 1:18 pm
by abrist
Just for clarity's sake: the emails are being routed externally, correct? While you need them to remain internal? Do the fqdn server names in your "destination" directive resolve to external ip addresses? If they do, they will be routed externally. Does your exchange server have an internal name/address?

Re: Send mail notifications

Posted: Wed May 22, 2013 1:52 am
by alexmati
Maybe I missed this before, but you have a firewall in between that is blocking the connection on port 25? If that is the case, this port needs to get opened, or it doesn't matter how much configuration on either nagios or exchange is done, it will never work.
@sreinhardt: Firewall blocks on port 25 because nagios tries to send mails through external mail address and i don't want this. I am at the same network with exchange server, i can ping and telnet to IP but not the name of the exchange server.

Just for clarity's sake: the emails are being routed externally, correct? While you need them to remain internal? Do the fqdn server names in your "destination" directive resolve to external ip addresses? If they do, they will be routed externally. Does your exchange server have an internal name/address?
@abrist: Yes, i need them to remain internal. I have the name of the server.
As i explain to sreinhardt, when i ping to the name of the server i have a result: ping: unknown host


What i am missing?

Edit: Maybe this is useful: When i install postfix, i have install it as Internet Site. Is this tight or not?

Thanks for your interesting guys



Edit 2: Finally works: :D

Code: Select all

myhostname = ubuntu_server_name
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = mymailserver.mydomain.net, nagios.notify-gr, ubuntu_server_name, localhost.localdomain, localhost
relayhost = My_Exchange_IP
mynetworks = ***.***.***.***/24 
mydomain = mydomain.net
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all