Nagios Email Notifications not sending emails

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.
Locked
allta
Posts: 3
Joined: Thu Jun 30, 2016 2:19 pm

Nagios Email Notifications not sending emails

Post by allta »

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
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Nagios Email Notifications not sending emails

Post by tgriep »

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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
allta
Posts: 3
Joined: Thu Jun 30, 2016 2:19 pm

Re: Nagios Email Notifications not sending emails

Post by allta »

Wow, that is the issue, thanks a lot.

I removed the "n" option and emails are now being received
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Nagios Email Notifications not sending emails

Post by mcapra »

Is it alright if we lock this thread and mark the issue as resolved?
Former Nagios employee
https://www.mcapra.com/
allta
Posts: 3
Joined: Thu Jun 30, 2016 2:19 pm

Re: Nagios Email Notifications not sending emails

Post by allta »

Yes, issue resolved for me.
Locked