Nagios email notifications not working

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.
kellyangell
Posts: 18
Joined: Mon Aug 08, 2016 3:20 am

Nagios email notifications not working

Post by kellyangell »

nagios.cfg
(43.96 KiB) Downloaded 259 times
contacts.cfg
(551 Bytes) Downloaded 248 times
commands.cfg
(8.05 KiB) Downloaded 240 times
Hello

My email alerts are not working, can someone please check my configuration files, i have uploaded them. i have sent a test message from nagios so i know send mail is working, but i am not receiving notifications for critical and warnings. please can someone help me out :)

Cant wait to hear from you .
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Nagios email notifications not working

Post by rkennedy »

Could you please post your /usr/local/nagios/var/objects.cache file for us to look at? The ones you posted look fine, assuming general-contact has notification commands defined.

Also, please let us know the host / service and contact, that you're attempting to get notifications for so that we know what to compare it against.
Former Nagios Employee
kellyangell
Posts: 18
Joined: Mon Aug 08, 2016 3:20 am

Re: Nagios email notifications not working

Post by kellyangell »

Hello

i have got it working , so need need to do anything, one more thing is the mails i am receiving are blank and i would like it to contain the status information , is there something i need to change in these 2 entries , as it is a db query i am running i would like to see the output and comments in my email alerts.

hope to hear from you soon. kelly


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

# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/mail "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\n Additional Info:\n\n$SERVICEOUTPUT$\n$LONGSERVICEOUTPUT$ $NOTIFICATIONCOMMENT$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Nagios email notifications not working

Post by avandemore »

Here is some documentation for you: Standard Macros in Nagios

So your command definitions are correct. Is your host/service returning output? Can you post an example message?
Previous Nagios employee
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Nagios email notifications not working

Post by rkennedy »

Take a look at this - https://assets.nagios.com/downloads/nag ... olist.html

You could change your $HOSTOUTPUT$ to $LONGHOSTOUTPUT$ but, I'm not sure that will be the data you're after. For your services, you've already got $LONGSERVICEOUTPUT$ appended so I don't believe more information will be possible.

Could you show us what you're seeing in a current email, vs what you would like to see with screenshots?
Former Nagios Employee
kellyangell
Posts: 18
Joined: Mon Aug 08, 2016 3:20 am

Re: Nagios email notifications not working

Post by kellyangell »

hello

here is a screen shot of the email , there is no information its just the subject

thanks
Attachments
email .tiff
email .tiff (75.92 KiB) Viewed 3898 times
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Nagios email notifications not working

Post by avandemore »

Can you do the following:
  1. backup /usr/local/nagios/etc/nagios.cfg
  2. edit /usr/local/nagios/etc/nagios.cfg to contain the values debug_level=256 and debug_verbosity=2, replacing the existing ones
  3. Restart Nagios Core
  4. Provoke an event which will trigger one of these emails
  5. Upload /usr/local/nagios/var/nagios.debug
  6. Wait for further instructions, if that is enough information I'll have you restore the original and restart again.
Previous Nagios employee
kellyangell
Posts: 18
Joined: Mon Aug 08, 2016 3:20 am

Re: Nagios email notifications not working

Post by kellyangell »

it won't allow me to upload a file with the .debug extension
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Nagios email notifications not working

Post by tmcdonald »

Simply change the extension to .txt and it should be fine.
Former Nagios employee
kellyangell
Posts: 18
Joined: Mon Aug 08, 2016 3:20 am

Re: Nagios email notifications not working

Post by kellyangell »

haha of course . its been a long day ! here is the file
Attachments
nagios.rtf
(732.26 KiB) Downloaded 211 times
Locked