Page 1 of 1

Alerts needs to be hostname append with the hostgroup name

Posted: Wed Oct 30, 2019 1:21 pm
by IT-OPS-SYS
I am getting the alerts for the host being down in the below format:

Host ‘slc207107’ is DOWN:

I would like to append the hostname with the host group so that we can identify the server group is having an issue. something like this:

Host ‘slc207107-webapp server’ is DOWN: where webapp server is the host group for the machine.


TIA

Re: Alerts needs to be hostname append with the hostgroup na

Posted: Wed Oct 30, 2019 2:55 pm
by benjaminsmith
Hello TIA,

You'll need to go to Admin > Notifications Management and adjust your Email Message template to include the hostroup in the subject and/or body of the notification.
notification-template.png
You can use system macros in the template but you'll need to add them to the XI notification handler. See the guide below for instructions on how to set this up. For example, add --hostgroup="$HOSTGROUPNAME$" to the command string.

Understanding Notification Variables

Re: Alerts needs to be hostname append with the hostgroup na

Posted: Thu Oct 31, 2019 1:53 pm
by IT-OPS-SYS
I tried appending the notification message with "Hostgroup: %hostgroup%" but it did not work.

I don't even see %hostgroup% as one of the variable in the document provided above.

Re: Alerts needs to be hostname append with the hostgroup na

Posted: Thu Oct 31, 2019 2:36 pm
by lmiltchev
In order to be able to use "%hostgroup%" in the notification messages like this, you would need to set up the macro in your notification command.

Core Config Manager > Commands > Commands > xi_host_notification_handler > Edit

For example, if you are using the "default" XI notification handler command (xi_host_notification_handler), you could append the following code to the end of the command:

Code: Select all

--hostgroup="$HOSTGROUPNAME$"
or

Code: Select all

--hostgroup="$HOSTGROUPNAMES$"
The "$HOSTGROUPNAME$" and "$HOSTGROUPNAMES$" macros are a bit different - read more about them here:

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

Example:

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$" --hostgroup="$HOSTGROUPNAMES$"
Once you modify your notification command, and apply configuration, you should be able to use something like this in the "Host Alert Subject" field (under the "Notification Messages" page):

Code: Select all

%type% Host Alert - %host%-%hostgroup% is %hoststate%
You can also use "%hostgroup%" in the "Host Alert Message" field, for example:

Code: Select all

***** Nagios XI Alert *****

%alertsummary%

Notification Type: %type%
Host: %host%
Hostgroup: %hostgroup%
State: %hoststate%
Address: %hostaddress%
Info: %hostoutput%
Date/Time: %datetime%

Respond: %responseurl%
Nagios URL: %xiserverurl%
Let us know if this helped.

Re: Alerts needs to be hostname append with the hostgroup na

Posted: Mon Nov 04, 2019 2:22 pm
by IT-OPS-SYS
i was able to do for 1 single account but how can we deploy the same setting for the entire contact groups or a set of users.

Re: Alerts needs to be hostname append with the hostgroup na

Posted: Mon Nov 04, 2019 2:44 pm
by lmiltchev
You can deploy various notification preferences/templates to users in bulk via the "Notification Settings Management" option, which is available in Nagios XI Enterprise Edition.

Admin > Users > Notification Management

See pages 7-9 in the document below:

https://assets.nagios.com/downloads/nag ... ios-XI.pdf