Hello, I have two questions around using custom variables.
First, we have a custom variable (_role) set for our hosts which show the role it plays in the environment (database, storage, utility, etc.). When Nagios issues an alert, I would like to include that custom variable in the message.
I have included this variable in the email alert template in the format I believe it should be (below). However when the email is issued, it contains, literally, the string %_role%, rather than the content of the custom variable. Do I need a different syntax for custom variable than the standard variables which do come through as expected? I added %contactemail% to the template, and it comes thru fine.
***** Nagios XI Alert *****
%alertsummary%
Notification Type: %type%
Host: %host%
State: %hoststate%
Address: %hostaddress%
Info: %hostoutput%
Date/Time: %datetime%
Respond: %responseurl%
Nagios URL: %xiserverurl%
Node's Role: %_role%
Persons notified: %contactemail%
Second question, can I include custom variables in the host alias field? When looking at a long list of Host or Service Status it would be helpful for the viewer to, again, know the role of the host at a glance.
Using Custom Variables in Email Notification or Host Alias?
Re: Using Custom Variables in Email Notification or Host Alias?
Hi @gregbeyer, thanks for reaching out.
It sounds like you have already done step 1. Have you added the custom variable to the xi_host_notification_handler?
I have not verified this, so please test, before changing all your hosts.
It sounds like you have already done step 1. Have you added the custom variable to the xi_host_notification_handler?
- Going by the "Custom Variable Macros" section of the Macros doc, the "Example" section of the Custom Object Variables doc, and because this is a HOST object variable, the _role custom variable should be available as the macro $_HOSTROLE$.
- Then in the Understanding Nagios XI Notification Variables doc, page 9, it shows how to add the $HOSTROLE$ macro to the xi_host_notification_handler's command line, so it is available as %_role%.
Code: Select all
alias ThisHostsAlias $_HOSTROLE$
Please let us know if you have any other questions or concerns.
-Laura
-Laura
Re: Using Custom Variables in Email Notification or Host Alias?
Thanks for the info