Page 1 of 1
Limted macro variables in XI event handler?
Posted: Mon Mar 24, 2014 9:16 am
by vAJ
Following
http://assets.nagios.com/downloads/nagi ... ndlers.pdf, am I correct in reading that all of the Nagios macro variables (
http://nagios.sourceforge.net/docs/3_0/ ... #hostnotes) are not available for use with the XI Event Handlers?
I’m trying to get $HOSTNOTES$ passed as in alerts from XI with no luck (passing in the email template as %hostnotes%). Eventually, there are other custom variables that I’d like displayed in host/service alerts. This is going to be a huge problem if I can’t as this was to be a core dependency of new alert severity handling for our NOC and Engineering staff.
Let me know if I’m missing something.
-Andrew
Re: Limted macro variables in XI event handler?
Posted: Mon Mar 24, 2014 11:41 am
by abrist
Can you post the current notification command you are using? You usually need to map the core macro to the XI notification macro. For example, the following is a vanilla XI notification handler:
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$"
}
The command below includes the mapping (--hostnotes="$HOSTNOTES$"):
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$" --hostnotes="$HOSTNOTES$"
}
Once your command has been altered and the changes applied, the %hostnotes% macro should work as expected in XI notifications.
Re: Limted macro variables in XI event handler?
Posted: Mon Mar 24, 2014 12:53 pm
by vAJ
That appears to be my answer. Will test and let you know.
Code: Select all
/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$" --hostgroupnames="$HOSTGROUPNAMES$" --hostgroupnotesurl="$HOSTGROUPNOTESURL$"
Re: Limted macro variables in XI event handler?
Posted: Mon Mar 24, 2014 2:31 pm
by vAJ
That's working. Good to know that new macro vars just need to be called in the command.
Thanks!
Re: Limted macro variables in XI event handler?
Posted: Mon Mar 24, 2014 3:44 pm
by tmcdonald
Good to see it's working! I'll be closing this thread now, but feel free to open another if you need to.