Recipients of a notification be in the To: header

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
anil_kumarv
Posts: 50
Joined: Thu Oct 17, 2013 2:00 am

Re: Recipients of a notification be in the To: header

Post by anil_kumarv »

This is a regular email template. I've changed the email template as you mentioned and still same issue. Just showing days and no mins. If the Date/Time is showing all details as expected, how come Host/service duration is missing..?
----------------------------------------------------------------------------------------
Notification Type: PROBLEM
Host: 10.213.161.201
State: DOWN since 0d
Address: 10.213.161.201
Info: PING CRITICAL - Packet loss = 100%
Host Duration: 0d
Date/Time: 2014-05-29 05:26:43
----------------------------------------------------------------------------------------
Service: Disk
Host: ban-gti-rep01.corp.avertlabs.internal
Address: ban-gti-rep01.corp.avertlabs.internal
State: CRITICAL since 196d
Info:
Connection refused by host
Service Duration: 196d
Date/Time: 2014-05-29 05:28:18
----------------------------------------------------------------------------------------
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Recipients of a notification be in the To: header

Post by sreinhardt »

Could you post the current template as you have it now please? Much easier to take a look at what it absolutely is, rather than what we think it might be.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
anil_kumarv
Posts: 50
Joined: Thu Oct 17, 2013 2:00 am

Re: Recipients of a notification be in the To: header

Post by anil_kumarv »

I've posted in my previous post, but doing it again.
Host alert message email template :
-------------------------------------------------------------------------------------
%alertsummary%

Notification Type: %type%
Host: %host%
State: %hoststate% since %hostduration%
Address: %hostaddress%
Info: %hostoutput%
Host Duration: %hostduration%
Date/Time: %datetime%

Hostgroups: %hostgroups%
Recipients: %recipients%

Respond: %responseurl%

Nagios URL: %xiserverurl%
-------------------------------------------------------------------------------------
Service alert message email template :
-------------------------------------------------------------------------------------
%alertsummary%

Notification Type: %type%

Service: %service%
Host: %host%
Address: %hostaddress%
State: %servicestate% since %serviceduration%
Info:
%serviceoutput%
Service Duration: %serviceduration%
Date/Time: %datetime%

Hostgroups: %hostgroups%
Recipients: %recipients%

Respond: %responseurl%

Nagios URL: %xiserverurl%
-------------------------------------------------------------------------------------
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Recipients of a notification be in the To: header

Post by abrist »

It looks like you have the assignment of "$HOSTDURATOIN$" correctly quoted. Tail the nagios.log after sending one of these notifications. There possibly may be some information in the log about how this command is handling the $HOSTDURATION$ macro.
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.
anil_kumarv
Posts: 50
Joined: Thu Oct 17, 2013 2:00 am

Re: Recipients of a notification be in the To: header

Post by anil_kumarv »

I could not find anything suspicious in the log. Log flow below for a host :
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
]# tail -f /usr/local/nagios/var/nagios.log | grep 10.213.161.201
[1401700179] HOST ALERT: 10.213.161.201;DOWN;SOFT;1;PING CRITICAL - Packet loss = 100%
[1401700239] Warning: Check of host '10.213.161.201' could not be rescheduled properly. Scheduling check for next week...
[1401700249] HOST ALERT: 10.213.161.201;DOWN;SOFT;2;PING CRITICAL - Packet loss = 100%
[1401700259] SERVICE ALERT: 10.213.161.201;PING-mon22;CRITICAL;HARD;1;PING CRITICAL - Packet loss = 100%
[1401700309] Warning: Check of host '10.213.161.201' could not be rescheduled properly. Scheduling check for next week...
[1401700329] HOST ALERT: 10.213.161.201;DOWN;SOFT;3;PING CRITICAL - Packet loss = 100%
[1401700389] SERVICE ALERT: 10.213.161.201;PING;CRITICAL;HARD;1;PING CRITICAL - Packet loss = 100%
[1401700389] Warning: Check of host '10.213.161.201' could not be rescheduled properly. Scheduling check for next week...
[1401700399] HOST ALERT: 10.213.161.201;DOWN;HARD;4;PING CRITICAL - Packet loss = 100%
[1401700399] HOST NOTIFICATION: dl-dev-akumar6;10.213.161.201;DOWN;xi_host_notification_handler;PING CRITICAL - Packet loss = 100%
[1401700399] HOST NOTIFICATION: mkumarkr;10.213.161.201;DOWN;xi_host_notification_handler;PING CRITICAL - Packet loss = 100%
[1401700399] HOST NOTIFICATION: akumar16;10.213.161.201;DOWN;xi_host_notification_handler;PING CRITICAL - Packet loss = 100%
[1401700549] HOST ALERT: 10.213.161.201;UP;HARD;1;PING WARNING - Packet loss = 85%, RTA = 0.45 ms
[1401700549] HOST NOTIFICATION: dl-dev-akumar6;10.213.161.201;UP;xi_host_notification_handler;PING WARNING - Packet loss = 85%, RTA = 0.45 ms
[1401700549] HOST NOTIFICATION: mkumarkr;10.213.161.201;UP;xi_host_notification_handler;PING WARNING - Packet loss = 85%, RTA = 0.45 ms
[1401700549] HOST NOTIFICATION: akumar16;10.213.161.201;UP;xi_host_notification_handler;PING WARNING - Packet loss = 85%, RTA = 0.45 ms
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

And the notifications for host down & Up I received :
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Nagios has detected a problem with this host.

Notification Type: PROBLEM
Host: 10.213.161.201
State: DOWN since 0d
Address: 10.213.161.201
Info: PING CRITICAL - Packet loss = 100%
Host Duration: 0d
Date/Time: 2014-06-02 09:13:21

Hostgroups: os-windows,mon-mon22,loc-bangalore,env-development
Recipients: akumar16,mkumarkr,dl-dev-akumar6
.
.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Nagios has detected this host has recovered.

Notification Type: RECOVERY
Host: 10.213.161.201
State: UP since 0d
Address: 10.213.161.201
Info: PING WARNING - Packet loss = 85%, RTA = 0.45 ms
Host Duration: 0d
Date/Time: 2014-06-02 09:15:52

Hostgroups: os-windows,mon-mon22,loc-bangalore,env-development
Recipients: akumar16,mkumarkr,dl-dev-akumar6
.
.
.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Recipients of a notification be in the To: header

Post by abrist »

I just tested this and %hostduration% is working just fine:

Code: Select all

Duration: 10d 3h 2m 42s
But I noticed you are using the script: /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php
Is there a reason why you are using this script? The commands (and subsequent scripts) that should be edited for XI users are:

Code: Select all

xi_host_notification_handler
xi_service_notification_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.
anil_kumarv
Posts: 50
Joined: Thu Oct 17, 2013 2:00 am

Re: Recipients of a notification be in the To: header

Post by anil_kumarv »

We are using xi_host_notification_handler & xi_service_notification_handler only. See below :
-----------------------------------------------------------------------------------------------------------------------------------
define command {
command_name xi_host_notification_handler
command_line /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=host --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT$" --datetime="$LONGDATETIME$" --hostduration=$HOSTDURATION$ --hostgroups=$HOSTGROUPNAMES$ --recipients=$NOTIFICATIONRECIPIENTS$
}

define command {
command_name xi_service_notification_handler
command_line /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=service --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --service="$SERVICEDESC$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --servicestate=$SERVICESTATE$ --servicestateid=$SERVICESTATEID$ --lastservicestate=$LASTSERVICESTATE$ --lastservicestateid=$LASTSERVICESTATEID$ --servicestatetype=$SERVICESTATETYPE$ --currentattempt=$SERVICEATTEMPT$ --maxattempts=$MAXSERVICEATTEMPTS$ --serviceeventid=$SERVICEEVENTID$ --serviceproblemid=$SERVICEPROBLEMID$ --serviceoutput="$SERVICEOUTPUT$" --longserviceoutput="$LONGSERVICEOUTPUT$" --datetime="$LONGDATETIME$" --hostgroups=$HOSTGROUPNAMES$ --recipients=$NOTIFICATIONRECIPIENTS$ --serviceduration=$SERVICEDURATION$
}
-----------------------------------------------------------------------------------------------------------------------------------

And all contacts are using the same one :

service_notification_commands xi_service_notification_handler
host_notification_commands xi_host_notification_handler
-----------------------------------------------------------------------------------------------------------------------------------
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Recipients of a notification be in the To: header

Post by lmiltchev »

I don't see anything wrong with your commands. I've set up %hostduration% in exactly the same way but it's working for me. Can you post the nagios.cfg file, so that we can take a look at it?
Be sure to check out our Knowledgebase for helpful articles and solutions!
anil_kumarv
Posts: 50
Joined: Thu Oct 17, 2013 2:00 am

Re: Recipients of a notification be in the To: header

Post by anil_kumarv »

Attched nagios.cfg file for your reference.
You do not have the required permissions to view the files attached to this post.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Recipients of a notification be in the To: header

Post by scottwilkerson »

anil_kumarv wrote:We are using xi_host_notification_handler & xi_service_notification_handler only. See below :
-----------------------------------------------------------------------------------------------------------------------------------
define command {
command_name xi_host_notification_handler
command_line /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=host --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT$" --datetime="$LONGDATETIME$" --hostduration=$HOSTDURATION$ --hostgroups=$HOSTGROUPNAMES$ --recipients=$NOTIFICATIONRECIPIENTS$
}

define command {
command_name xi_service_notification_handler
command_line /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=service --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --service="$SERVICEDESC$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --servicestate=$SERVICESTATE$ --servicestateid=$SERVICESTATEID$ --lastservicestate=$LASTSERVICESTATE$ --lastservicestateid=$LASTSERVICESTATEID$ --servicestatetype=$SERVICESTATETYPE$ --currentattempt=$SERVICEATTEMPT$ --maxattempts=$MAXSERVICEATTEMPTS$ --serviceeventid=$SERVICEEVENTID$ --serviceproblemid=$SERVICEPROBLEMID$ --serviceoutput="$SERVICEOUTPUT$" --longserviceoutput="$LONGSERVICEOUTPUT$" --datetime="$LONGDATETIME$" --hostgroups=$HOSTGROUPNAMES$ --recipients=$NOTIFICATIONRECIPIENTS$ --serviceduration=$SERVICEDURATION$
}
-----------------------------------------------------------------------------------------------------------------------------------

And all contacts are using the same one :

service_notification_commands xi_service_notification_handler
host_notification_commands xi_host_notification_handler
-----------------------------------------------------------------------------------------------------------------------------------
Here is the problem, change the handlers to quote the $HOSTDURATION$ and $SERVICEDURATION$

e.g.

Code: Select all

define command {
       command_name                             xi_host_notification_handler
       command_line                             /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=host --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT$" --datetime="$LONGDATETIME$" --hostduration="$HOSTDURATION$" --hostgroups=$HOSTGROUPNAMES$ --recipients=$NOTIFICATIONRECIPIENTS$
}

define command {
       command_name                             xi_service_notification_handler
       command_line                             /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=service --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --service="$SERVICEDESC$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --servicestate=$SERVICESTATE$ --servicestateid=$SERVICESTATEID$ --lastservicestate=$LASTSERVICESTATE$ --lastservicestateid=$LASTSERVICESTATEID$ --servicestatetype=$SERVICESTATETYPE$ --currentattempt=$SERVICEATTEMPT$ --maxattempts=$MAXSERVICEATTEMPTS$ --serviceeventid=$SERVICEEVENTID$ --serviceproblemid=$SERVICEPROBLEMID$ --serviceoutput="$SERVICEOUTPUT$" --longserviceoutput="$LONGSERVICEOUTPUT$" --datetime="$LONGDATETIME$" --hostgroups=$HOSTGROUPNAMES$ --recipients=$NOTIFICATIONRECIPIENTS$ --serviceduration="$SERVICEDURATION$"
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked