Page 2 of 3
Re: Recipients of a notification be in the To: header
Posted: Thu May 29, 2014 1:15 am
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
----------------------------------------------------------------------------------------
Re: Recipients of a notification be in the To: header
Posted: Thu May 29, 2014 10:31 am
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.
Re: Recipients of a notification be in the To: header
Posted: Fri May 30, 2014 1:10 am
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%
-------------------------------------------------------------------------------------
Re: Recipients of a notification be in the To: header
Posted: Fri May 30, 2014 10:07 am
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.
Re: Recipients of a notification be in the To: header
Posted: Mon Jun 02, 2014 4:17 am
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
.
.
.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Re: Recipients of a notification be in the To: header
Posted: Mon Jun 02, 2014 4:01 pm
by abrist
I just tested this and %hostduration% is working just fine:
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
Re: Recipients of a notification be in the To: header
Posted: Tue Jun 03, 2014 8:00 am
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
-----------------------------------------------------------------------------------------------------------------------------------
Re: Recipients of a notification be in the To: header
Posted: Tue Jun 03, 2014 2:58 pm
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?
Re: Recipients of a notification be in the To: header
Posted: Wed Jun 04, 2014 12:02 am
by anil_kumarv
Attched nagios.cfg file for your reference.
Re: Recipients of a notification be in the To: header
Posted: Wed Jun 04, 2014 3:44 pm
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$"