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.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: How to configure email alert notification?

Post by lmiltchev »

Can you post the command and the contact definitions?
Be sure to check out our Knowledgebase for helpful articles and solutions!
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 lmiltchev,

Thanks for the reply.

1) Fortunately i am receiving mail to my email address when i change $CONTACTMAIL$ to my email address at command.cfg file. But i think its for temporarily. When i need to segregrate contacts then i need to do modify. When i use $CONTACTMAIL$ in command.cfg file i can't receive any email during device state change.



CONTACT:
define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
email sazzad.hussein@de.rr-icecream.eu ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}

COMMAND:
# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** R&R Central Network Monitoring System(NMS) *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mailx -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" sazzad.hussein@de.rr-icecream.eu
}

# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** R&R Central Network Monitoring System(NMS) *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/bin/mailx -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" sazzad.hussein@de.rr-icecream.eu
}

2) Another thing is that recently i have added proxy email address(root@de.rr-icecream.eu) with my enail address by my exchange server & receiving the service notification. But i need to change this email address(From "root@mydomain" to "myemail-address@mydomain"). Could you help by sharing the path?

3) At root@mydomain email address i am reciving following message in every 10 minutes.

Subject: Cron <smmsp@RR-DE-NMS-1> test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp
Body of Message: /usr/share/sendmail/sendmail: 899: /usr/share/sendmail/sendmail: /usr/sbin/sendmail-msp: not found

Before i have installed SendMail & after that i have installed postfix. Is it happening due to SendMail? Should SendMail removal can do that resloution?
Regards
Sazzad
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: How to configure email alert notification?

Post by tgriep »

1. If you remove $CONTACTMAIL$ from the notify-host-by-email and notify-service-by-email and just put in your email addresses, if is set to only send emails you you and no one else will receive emails at all. I would put back the $CONTACTMAIL$ in that command. If you want to receive notifications for a host or service, you will need to edit those and add the following in your checks.

Code: Select all

contacts                        nagiosadmin
That should enable the nagiosadmin to receive emails.

2. To change your From address in your emails, you will have to configure the email server you are using on the Nagios system. Are you using sendmail or postfix?

3. That looks like your cron process is sending emails and is not related to Nagios. But here is a link that may help you.
http://unix.stackexchange.com/questions ... o-dev-null
Be sure to check out our Knowledgebase for helpful articles and solutions!
karthikeyaece
Posts: 5
Joined: Tue May 24, 2016 4:53 am

Re: How to configure email alert notification?

Post by karthikeyaece »

Hi ,

i have configured nagios to send mail alert using "sendmail" option. But i dint receive any mail notification like host down or up etc...But i could able to get test notification.
What i am missing here, please help

Thanks
Karthi
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: How to configure email alert notification?

Post by tgriep »

Take a look in the /var/log/maillog file when the Nagios system generated an email notification and see if there are any errors.
If you see any errors that the says the root email address is rejected, you can change the from address by adding the following option

Code: Select all

-r myemail-address@mydomain
To the end of both of these commands.

Code: Select all

notify-host-by-email
notify-service-by-email
That should fix the sending of emails as root.
If you need help, post the errors from that file so we can view them.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked