hostgroup variable for notifications?

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

hostgroup variable for notifications?

Post by vAJ »

I'm looking to show the HOSTGROUP in all notifications as configured in the Admin-->Notification Management screen.

In reading http://assets.nagios.com/downloads/nagi ... iables.pdf, I don't see a variable for HOSTGROUP or SERVICEGROUP.

This would be tremendously helpful to our operations center in knowing what groups alerts belong to. We have different SLAs for different systems, as I'm sure other shops do.

Any ideas?

-Andrew
Andrew J. - Do you even grok?
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: hostgroup variable for notifications?

Post by abrist »

You can actually use just about any core macro with the notification component. First, add the macro assignment you want ( $HOSTGROUPNAMES$ in this example ) to the notification command in the CCM. Go to --> Configure --> Core Configuration Manager --> Commands --> Click "xi_host_notification_handler" --> Add the following line to end of the command:

Code: Select all

--hostgroupnames="$HOSTGROUPNAMES$"
So the check resembles (your command may be slightly different, but it should contain the added macro assignment:

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$"
Now edit the notification "Host Alert Message" in the notification component. Add the following to the message:

Code: Select all

Hostgroups: %hostgroupnames%
A full list of object type specific macros can be found below:
http://nagios.sourceforge.net/docs/3_0/macrolist.html
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: hostgroup variable for notifications?

Post by vAJ »

Tested successfully with both host and service notifications!

I'll follow the same lines to get the Notes URL passed in notifications as well. Sending a link to the wiki for our various environments will be even better.

Thanks Andy!
Andrew J. - Do you even grok?
Locked