Alerts needs to be hostname append with the hostgroup name

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
IT-OPS-SYS
Posts: 184
Joined: Sun Jan 07, 2018 12:56 pm

Alerts needs to be hostname append with the hostgroup name

Post 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
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

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

Post 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
You do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
IT-OPS-SYS
Posts: 184
Joined: Sun Jan 07, 2018 12:56 pm

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

Post 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.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

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

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
IT-OPS-SYS
Posts: 184
Joined: Sun Jan 07, 2018 12:56 pm

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

Post 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.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

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

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked