Products
This guide on Best Practices is about macros and custom object variables and what you should take into consideration when designing your monitoring deployment.
User macros are a way of storing and referencing common items such as usernames and passwords. Because you are referencing the objects as a macro, the actual value is not visible in the object definitions.
It also allows special characters to be used like an exclamation mark. Normally when an exclamation mark is used in a command_name directive, it's purpose is to split up the different arguments, so by storing it in a user macro it works around the problem.
You'll notice in all the command definitions, $USER1$ always precedes the plugin.
$USER1$ = /usr/local/nagios/libexecHere is some documentation on macros:
Custom object variables are one of the lesser known features of Nagios.
It allows you to define you own variables to use in your object definitions, this makes Nagios very flexible and very powerful.
A good example is if each windows host had it's own custom check_nt password. What you can do is store that password in the host object and then from your service objects you can reference the password. It also means that you can still have just one command that can be used my many hosts, reducing administrative overhead.
E.G. hosts have their own check_nt password
Define _CHECK_NT_PASSWORD in host object
In command definitions reference it as:
$_HOSTCHECK_NT_PASSWORD$Here is some documentation on variables:
In Nagios XI 2026R1.5+ and Nagios Core 4.5.13+, custom variable macros ($_HOSTvarname$, $_SERVICEvarname$, $_CONTACTvarname$) will by stripped of illegal characters for security reasons.
These characters are defined in the illegal_macro_output_chars config option, which can typically be found in:
/usr/local/nagios/etc/nagios.cfgBy default the following characters will be stripped:
` ~ $ & | ' " < >
If you want to use any of these characters in a custom variable, then it will have to be removed from this list. Keep in mind the security implications, as each of these characters pose a potential security vulnerability if removed.
For any support related questions please visit the Nagios Support Forums at:
© All rights reserved. 2026