Page 1 of 1
hostgroup variable for notifications?
Posted: Fri Jul 12, 2013 9:50 am
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
Re: hostgroup variable for notifications?
Posted: Fri Jul 12, 2013 10:03 am
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:
A full list of object type specific macros can be found below:
http://nagios.sourceforge.net/docs/3_0/macrolist.html
Re: hostgroup variable for notifications?
Posted: Fri Jul 12, 2013 11:00 am
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!