This is a cache of https://support.nagios.com/kb/article/nagios-xi-macros-and-custom-object-variables-509.html. It is a snapshot of the page at 2025-05-14T00:41:06.968+0000.
Nagios <strong>xi</strong> - Macros and Custom Object Variables
Home » Categories » Products » Nagios xi » Documentation » Best Practices

Nagios xi - Macros and Custom Object Variables

Overview

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.

  • $USER1$ = /usr/local/nagios/libexec

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

    • Misc Settings tab > Manage Variable Definitions button
  • 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/



Special Offer For Knowledgebase Visitors! Get a huge discount on Nagios Log Server by clicking below.

Get 60% Off Nagios Log Server!

Did you know? Nagios provides complete monitoring of: Windows, Linux, UNIX, Servers, Websites, SNMP, DHCP, DNS, Email, Storage, Files, Apache, IIS, EC2, and more!

5 (1)
Article Rating (1 Votes)
Rate this article
  • Icon PDFExport to PDF
  • Icon MS-WordExport to MS Word
Attachments Attachments
There are no attachments for this article.
Related Articles RSS Feed
Nagios xi - Check Interval Considerations
Viewed 8151 times since Tue, May 3, 2016
Nagios xi - Configuration Wizards and Templates
Viewed 11479 times since Tue, May 3, 2016
Nagios xi - What Is Monitoring xi ?
Viewed 4692 times since Mon, May 2, 2016
Nagios xi - Groups
Viewed 10233 times since Tue, May 3, 2016
Nagios xi - xi Server Considerations
Viewed 7934 times since Mon, May 2, 2016
Nagios xi - Monitoring the Nagios xi "localhost"
Viewed 9064 times since Mon, May 2, 2016
Nagios xi - MRTG Clean Configs
Viewed 8689 times since Tue, May 3, 2016
Nagios xi - Best Practices for Managing Configs
Viewed 8920 times since Wed, Jul 19, 2017
Nagios xi - Service Dependencies
Viewed 11501 times since Tue, May 3, 2016