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 - Best Practices for Managing Configs
Viewed 2914 times since Wed, Jul 19, 2017
Nagios XI - Check Interval Considerations
Viewed 2117 times since Tue, May 3, 2016
Nagios XI - Groups
Viewed 2427 times since Tue, May 3, 2016
Nagios XI - XI Server Considerations
Viewed 2111 times since Mon, May 2, 2016
Nagios XI - What Is Monitoring XI ?
Viewed 1229 times since Mon, May 2, 2016
Nagios XI - Service Dependencies
Viewed 3258 times since Tue, May 3, 2016
Nagios XI - Monitoring the Nagios XI "localhost"
Viewed 1912 times since Mon, May 2, 2016
Nagios XI - Configuration Wizards and Templates
Viewed 3675 times since Tue, May 3, 2016
Nagios XI - MRTG Clean Configs
Viewed 2184 times since Tue, May 3, 2016