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/

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 - Monitoring the Nagios XI "localhost"
Viewed 7193 times since Mon, May 2, 2016
Nagios XI - What Is Monitoring XI ?
Viewed 3761 times since Mon, May 2, 2016
Nagios XI - Groups
Viewed 7865 times since Tue, May 3, 2016
Nagios XI - Configuration Wizards and Templates
Viewed 9895 times since Tue, May 3, 2016
Nagios XI - Best Practices for Managing Configs
Viewed 7664 times since Wed, Jul 19, 2017
Nagios XI - MRTG Clean Configs
Viewed 7344 times since Tue, May 3, 2016
Nagios XI - Check Interval Considerations
Viewed 6678 times since Tue, May 3, 2016
Nagios XI - Service Dependencies
Viewed 9754 times since Tue, May 3, 2016
Nagios XI - XI Server Considerations
Viewed 6553 times since Mon, May 2, 2016