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 – resources.cfg
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.
Here is some documentation on macros:
Documentation - Understanding User Macros
Custom Object Variables
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 variable:
Documentation - Understanding Notification Variables
Final Thoughts
For any support related questions please visit the Nagios Support Forums at:
http://support.nagios.com/forum/
Article ID: 509
Created On: Tue, May 3, 2016 at 12:33 AM
Last Updated On: Wed, May 11, 2016 at 5:47 PM
Authored by: tlea
Online URL: https://support.nagios.com/kb/article/nagios-xi-macros-and-custom-object-variables-509.html