Nagios Email Notifications not sending emails

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Nagios Email Notifications not sending emails

Postby allta » Tue Jul 05, 2016 10:25 am

Nagios Core 4.1.1 (Student VM)
Notification is enabled in nagios.cfg

[root@nagios ~]# cat /usr/local/nagios/etc/nagios.cfg | grep enable_notifications
enable_notifications=1



below is content of my host's cfg

define host {
host_name maplebee-001
address 10.10.10.10
check_command check-host-alive!!!!!!!!
max_check_attempts 2
check_interval 2
retry_interval 1
check_period 24x7
flap_detection_enabled 0
contacts maplebee
notification_interval 5
notification_period 24x7
notification_options d,u,r,f,s,
notifications_enabled 1
register 1
}

below is content of my contact's cfg
define contact {
contact_name maplebee
alias maplebee
host_notifications_enabled 1
service_notifications_enabled 1
host_notification_period 24x7
service_notification_period 24x7
host_notification_options d,u,r,f,s,n,
service_notification_options w,u,c,r,f,s,n,
host_notification_commands notify-host-by-email
service_notification_commands notify-service-by-email
email maplebeexyz001@gmail.com
}

commands' cfgs:

define command {
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}

define command {
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}

I am able to run the mail test command from cli as root and also nagios user.

/usr/bin/printf "%b" "test" | /bin/mail -s "test subject" maplebeexyz001@gmail.com

My tail -f on nagios.log shows Host Notification HARD, but there is no HOST email alerting out msg

what am I doing wrong here? I've spent almost a couple days trying to figure this out
allta
 
Posts: 3
Joined: Thu Jun 30, 2016 2:19 pm

Re: Nagios Email Notifications not sending emails

Postby tgriep » Tue Jul 05, 2016 11:02 am

You need to remove the "n" from the service / host notification options
If you specify n (none) as an option, the contact will not receive any type of host / service notifications.
Change that option and restart nagios and that contact should start receiving notifications.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 8208
Joined: Thu Oct 30, 2014 9:02 am

Re: Nagios Email Notifications not sending emails

Postby allta » Tue Jul 05, 2016 11:26 am

Wow, that is the issue, thanks a lot.

I removed the "n" option and emails are now being received
allta
 
Posts: 3
Joined: Thu Jun 30, 2016 2:19 pm

Re: Nagios Email Notifications not sending emails

Postby mcapra » Tue Jul 05, 2016 11:28 am

Is it alright if we lock this thread and mark the issue as resolved?
Former Nagios employee
http://www.mcapra.com/
User avatar
mcapra
 
Posts: 3573
Joined: Thu May 05, 2016 3:54 pm

Re: Nagios Email Notifications not sending emails

Postby allta » Tue Jul 05, 2016 12:00 pm

Yes, issue resolved for me.
allta
 
Posts: 3
Joined: Thu Jun 30, 2016 2:19 pm


Return to Nagios Core

Who is online

Users browsing this forum: Google [Bot] and 16 guests