Inconsistency in Notification Email

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.
vinothsethuram
Posts: 147
Joined: Thu Nov 07, 2013 11:44 am

Inconsistency in Notification Email

Post by vinothsethuram »

Hi,

I'm facing following issues in Nagios notification.

1) Custom notification is working for few services,but not for all the services. For few services, custom notification is not sending emails.

2) For few services/host, critical/recovery emails were received without info. i.e email body is blank and few emails had partial info.

Please share your thoughts/view to fix this issue
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Inconsistency in Notification Email

Post by abrist »

Well, lets start by looking at the custom notification handlers. Could you post them? There is a good chance from your description that there is a syntax problem in the handler.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
vinothsethuram
Posts: 147
Joined: Thu Nov 07, 2013 11:44 am

Re: Inconsistency in Notification Email

Post by vinothsethuram »

Could you please let me know file name and the location for custom handlers. I searched in etc and objects directory, but couldnt find
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Inconsistency in Notification Email

Post by abrist »

Usually, you will find the notify-*-by-email commands in the commands.cfg file. You mentioned that these are custom notifications, is that not the case? Nagios ships with a few notification commands, did you change these?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
vinothsethuram
Posts: 147
Joined: Thu Nov 07, 2013 11:44 am

Re: Inconsistency in Notification Email

Post by vinothsethuram »

I changed two commands in commands.cfg. They are

1) notify-host-by-email
2) notify-service-by-email.

Apart from above two services, I didn't change any commands.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Inconsistency in Notification Email

Post by tmcdonald »

abrist was asking if you could post them so we can see what you have.
Former Nagios employee
vinothsethuram
Posts: 147
Joined: Thu Nov 07, 2013 11:44 am

Re: Inconsistency in Notification Email

Post by vinothsethuram »

Code: Select all

# '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$$LONGHOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | sed 's/\r//' | /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/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$$LONGSERVICEOUTPUT$\n" | sed 's/\r//' | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Inconsistency in Notification Email

Post by abrist »

I believe the sed may be causing some issues . . . .
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
vinothsethuram
Posts: 147
Joined: Thu Nov 07, 2013 11:44 am

Re: Inconsistency in Notification Email

Post by vinothsethuram »

Even without sed also facing the issue.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Inconsistency in Notification Email

Post by lmiltchev »

I am not sure if this is going to fix your problem, but I noticed that you don't have any space between these macros: $HOSTOUTPUT$$LONGHOSTOUTPUT$ and $SERVICEOUTPUT$$LONGSERVICEOUTPUT$. Try putting a space in and see if this is going to help...

$HOSTOUTPUT$ $LONGHOSTOUTPUT$
and
$SERVICEOUTPUT$ $LONGSERVICEOUTPUT$
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked