Page 1 of 1

Add Hostgroup to Notifications

Posted: Wed Sep 02, 2020 11:34 am
by brucej543
Nagios 5.6.14 - On the notifications being sent, is there an easy way to add the hostgroup to the notifications. We are moving to having a central group for the alerts notification and they need to know what type of OS the alert is for so they can contact the correct group for resolution.
I reviewed the Understanding Notification Variables document and to not see any reference to Hostgroups.

Re: Add Hostgroup to Notifications

Posted: Thu Sep 03, 2020 10:12 am
by cdienger
$HOSTGROUPNAME$ AND $HOSTGROUPNAMES$ are available and can be added to notifications:

https://assets.nagios.com/downloads/nag ... olist.html

Edit the xi_hostnotification_handler to add $HOSTGROUPNAMES$:

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$" --hostgroups="$HOSTGROUPNAMES$"
A list of the hostgroups will then be stored in %hostgroups% which can be used in the notification message.

Re: Add Hostgroup to Notifications

Posted: Fri Sep 04, 2020 6:30 am
by brucej543
Thank you for the information. This post can be closed.

Re: Add Hostgroup to Notifications

Posted: Fri Sep 04, 2020 6:52 am
by scottwilkerson
brucej543 wrote:Thank you for the information. This post can be closed.
Great

Closing thread