Using Custom Variables in Email Notification or Host Alias?
Posted: Mon Aug 26, 2024 12:10 pm
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.
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.