Limted macro variables in XI event handler?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
vAJ
Posts: 456
Joined: Thu Nov 08, 2012 5:09 pm
Location: Austin, TX

Limted macro variables in XI event handler?

Post 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
Andrew J. - Do you even grok?
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Limted macro variables in XI event handler?

Post 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.
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.
vAJ
Posts: 456
Joined: Thu Nov 08, 2012 5:09 pm
Location: Austin, TX

Re: Limted macro variables in XI event handler?

Post 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$"
Andrew J. - Do you even grok?
vAJ
Posts: 456
Joined: Thu Nov 08, 2012 5:09 pm
Location: Austin, TX

Re: Limted macro variables in XI event handler?

Post by vAJ »

That's working. Good to know that new macro vars just need to be called in the command.

Thanks!
Andrew J. - Do you even grok?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Limted macro variables in XI event handler?

Post 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.
Former Nagios employee
Locked