How to configure email alert notification?

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.
Noctis0791
Posts: 58
Joined: Wed Oct 09, 2013 3:41 pm

How to configure email alert notification?

Post by Noctis0791 »

Hello Guys,

I have posted this before but for some reasons it’s gone. I did not get any notification that its awaiting for moderation so I’m not sure what happens. Anyways, I will just post it again.

I would just like to have some overview guys on how to properly configure alert notification in Nagios. We would also like to use our exchange server as the relay host. I tried to look for some reference and I found these 2 articles (article1 and article2) but I found it confusing because they don’t have the same approach. So what is the correct way to configure the alerts? What are the config files that should be modified? Also, if I may ask, what is the main difference between host and service notification, when and where we should use them?

Thank you very much,

Arnel
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: How to configure email alert notification?

Post by abrist »

Either of those links may work for postfix. Alternatively, you can also use sendmail/mailx to send to an smtp relay by creating custom notification handlers:

Code: Select all

notify-host-by-email-core
 
echo "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mailx -v -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ ** (C)" -S smtp=<smtp server> -S from=<from email address> $CONTACTEMAIL$
 
notify-service-by-email-core
 
echo "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /bin/mailx -v -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ ** (C)" -S smtp=<smtp server> -S from=<from email address> $CONTACTEMAIL$
The above handlers assume an smtp server with no auth. Adding auth can be painful, but possible.
Noctis0791 wrote:What are the config files that should be modified?
Depends if you are using postfix, sendmail, mailx, etc. It also depends on what type of authentication your relay requires.
Noctis0791 wrote:Also, if I may ask, what is the main difference between host and service notification, when and where we should use them?

Host notifications are send when a host enters a problem state, while service notification do the same thing, but for services. You will have to decide what types of problems you wish to notify over, and those which you do not.
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.
Noctis0791
Posts: 58
Joined: Wed Oct 09, 2013 3:41 pm

Re: How to configure email alert notification?

Post by Noctis0791 »

Thanks a lot abrist. I was able to setup the alert somehow following article2. I'll do some test for now and will let you know if I have any further questions.

Thank You,

Arnel
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: How to configure email alert notification?

Post by slansing »

Great just let us know!
lsazzad
Posts: 72
Joined: Tue Apr 07, 2015 6:52 am
Location: ​Osnabrück, Deutschland
Contact:

Re: How to configure email alert notification?

Post by lsazzad »

Hallo Guys,

I am facing problem with Email alert sending configuration from my server. Could you please share me a trustworthy site which i can follow? I have tried using SendEmail & followed bellow URL:
http://sharadchhetri.com/2013/07/16/how ... ment-18916

Unfortunately not succeeded...

Anyone is there to support me?
Regards
Sazzad
lsazzad
Posts: 72
Joined: Tue Apr 07, 2015 6:52 am
Location: ​Osnabrück, Deutschland
Contact:

Re: How to configure email alert notification?

Post by lsazzad »

Noctis0791 wrote:Thanks a lot abrist. I was able to setup the alert somehow following article2. I'll do some test for now and will let you know if I have any further questions.

Thank You,

Arnel
Hi, would you please share the article with me? It will be highly appreciated!
Regards
Sazzad
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: How to configure email alert notification?

Post by abrist »

They are linked by the OP in the first post on this thread:
Noctis0791 wrote:(article1 and article2)
A1: http://www.telnetport25.com/2012/02/con ... gios-core/
A2: http://awaseroot.wordpress.com/2013/02/ ... ns-puppet/
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.
lsazzad
Posts: 72
Joined: Tue Apr 07, 2015 6:52 am
Location: ​Osnabrück, Deutschland
Contact:

Re: How to configure email alert notification?

Post by lsazzad »

Hi,

Thanks a lot for the document. I have followed the document & configured postfix successfully. By using bellow command i can receive email. But can't receive automatically email from NAGIOS. I have configured commands.cfg contacts.cfg. But nothing received when any device is unreachable.



*POSTFIX MAIL checking:
telnet <IP> 25
EHLO
MAIL FROM: <from-email>
RCPT TO: <recipient-email>
DATA
Type message here.
. <Enter>
=>

Would you like to help me a little bit!
Regards
Sazzad
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: How to configure email alert notification?

Post by jdalrymple »

Are you certain that notifications are being raised? Look in Notifications under Reports in the sidebar menu. Send us a screenshot if there is any interesting information there.
lsazzad
Posts: 72
Joined: Tue Apr 07, 2015 6:52 am
Location: ​Osnabrück, Deutschland
Contact:

Re: How to configure email alert notification?

Post by lsazzad »

Thanks for your reply. Please have a look over the following log. Why post fix is sending alert to root@XXXXX ? When any device got down, i am not receiving any email. I think its because of Aliases! I have checked Aliases also. Nothing exists there.

root@RR-DE-NMS-1:/home/rr-de-nms-1# cd /etc
root@RR-DE-NMS-1:/etc# ls -lrt aliases
-rw-r--r-- 1 root root 0 Apr 7 11:29 aliases
root@RR-DE-NMS-1:/etc# more aliases

Apr 9 08:00:01 RR-DE-NMS-1 postfix/pickup[32522]: 53F24D20A54: uid=108 from=<smmsp>
Apr 9 08:00:01 RR-DE-NMS-1 postfix/cleanup[32602]: 53F24D20A54: message-id=<20150409060001.53F24D20A54@RR-DE-NMS-1.de.rr-icecream.internal>
Apr 9 08:00:01 RR-DE-NMS-1 postfix/qmgr[9703]: 53F24D20A54: from=<smmsp@de.rr-icecream.internal>, size=756, nrcpt=1 (queue active)
Apr 9 08:00:01 RR-DE-NMS-1 postfix/smtp[32604]: 53F24D20A54: to=<root@de.rr-icecream.internal>, orig_to=<root>, relay=172.19.1.31[172.19.1.31]:25, delay=0.19, delays=0.01/0/0/0.17, dsn=2.6.0, status=sent (250 2.6.0 <20150409060001.53F24D20A54@RR-DE-NMS-1.de.rr-icecream.internal> Queued mail for delivery)
Apr 9 08:00:01 RR-DE-NMS-1 postfix/qmgr[9703]: 53F24D20A54: removed
Apr 9 08:20:01 RR-DE-NMS-1 postfix/pickup[32522]: 69BA4D20A54: uid=108 from=<smmsp>
Apr 9 08:20:01 RR-DE-NMS-1 postfix/cleanup[332]: 69BA4D20A54: message-id=<20150409062001.69BA4D20A54@RR-DE-NMS-1.de.rr-icecream.internal>
Apr 9 08:20:01 RR-DE-NMS-1 postfix/qmgr[9703]: 69BA4D20A54: from=<smmsp@de.rr-icecream.internal>, size=756, nrcpt=1 (queue active)
Apr 9 08:20:01 RR-DE-NMS-1 postfix/smtp[334]: 69BA4D20A54: to=<root@de.rr-icecream.internal>, orig_to=<root>, relay=172.19.1.31[172.19.1.31]:25, delay=0.14, delays=0.01/0/0/0.13, dsn=2.6.0, status=sent (250 2.6.0 <20150409062001.69BA4D20A54@RR-DE-NMS-1.de.rr-icecream.internal> Queued mail for delivery)
Apr 9 08:20:01 RR-DE-NMS-1 postfix/qmgr[9703]: 69BA4D20A54: removed
Regards
Sazzad
Locked