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.
Locked
samton99
Posts: 45
Joined: Wed Jun 13, 2012 9:53 am

Notifications not working.

Post by samton99 »

Hello,

I am trying to enable notifications and it does not seem to work. I purposely disabled a service that I am monitoring and I do not get notifications.

What i did is the following

I installed postfix
then installed Heirloom-MailX

I configured Exchange 2007 to allow connections from nagios

Here is my templates.cfg

define contact{
name generic-contact ; The name of this contact template
service_notification_period 24x7 ; service notifications can be sent anytime
host_notification_period 24x7 ; host notifications can be sent anytime
service_notification_options w,u,c,r,f,s ; send notifications for all service states, flapping events, and scheduled downtime events
host_notification_options d,u,r,f,s ; send notifications for all host states, flapping events, and scheduled downtime events
service_notification_commands notify-service-by-email ; send service notifications via email
host_notification_commands notify-host-by-email ; send host notifications via email
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE!
}


Here is my contacts.cfg

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
email [email protected] ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}



###############################################################################
###############################################################################
#
# CONTACT GROUPS
#
###############################################################################
###############################################################################

# We only have one contact in this simple configuration file, so there is
# no need to create more than one contact group.

define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin
}

Here is my service that I disabled

define service{
use generic-service
host_name rha-mail
service_description BlackBerry Alert
check_command check_nt!SERVICESTATE!-d SHOWALL -l "Blackberry Server Alert"
}

Here is my commands.cfg

# 'notify-host-by-email' command definition
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" | /usr/bin/mailx -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/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" | /usr/bin/mailx -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}


I think this all I need to configure. If there is anything I am missing please let me know.

Thanks in advance
hendra
Posts: 2
Joined: Fri Jul 06, 2012 12:36 am

Re: Notifications not working.

Post by hendra »

May I suggest 2 things:

1. Does email sending from cli works? Better test it the same way you call it from Nagios command definition by supplying dummy strings to replace the Nagios variables
2. Enable debugging in nagios.cfg

and see how it goes from there?
samton99
Posts: 45
Joined: Wed Jun 13, 2012 9:53 am

Re: Notifications not working.

Post by samton99 »

How would i test from the cli. Can you give me an example?
samton99
Posts: 45
Joined: Wed Jun 13, 2012 9:53 am

Re: Notifications not working.

Post by samton99 »

Well I am getting a bit further along.

I was able to send an email from the cli to my email account and I received it.

I set the debugging level to 32 for notifications in nagios.cfg

I restarted nagios and still don't see any messages coming for that service alert.
samton99
Posts: 45
Joined: Wed Jun 13, 2012 9:53 am

Re: Notifications not working.

Post by samton99 »

ok. one step further

I tried this command

echo "this is the body of a test message" | /usr/bin/mailx -s "this is a subject" [email protected]

and it works.

but still no email from the service check in nagios
samton99
Posts: 45
Joined: Wed Jun 13, 2012 9:53 am

Re: Notifications not working.

Post by samton99 »

Great.

Its working now.

Thanks for your help
hendra
Posts: 2
Joined: Fri Jul 06, 2012 12:36 am

Re: Notifications not working.

Post by hendra »

Awesome, good to know it's working now, may be you can share the root cause and the solution just in case someone else experiencing similar problem.
Locked