Share this post
Michael Bellerue
Table of Contents
Custom Variables in Nagios XI
|
Michael Bellerue
These days, having a Configuration Management Database (CMDB) is a must. While Nagios XI is not built for managing your configurations, you can put some helpful information about your hosts and services into Nagios XI using Custom Variables. Once the custom variables are there, the information will be right at your fingertips in the very moment you need it most.
How To Configure Custom Variables
Custom variables can be created on an individual host or service, or they can be configured in a host or service template.
To start off, let’s look at how to create custom variables. In this example, we will add them to a host in Nagios XI interface.
- Hover over the gear icon on the left menu, and select the Core Config manager.
- In the Core Config Manager, click on Hosts
- Select a host you want to give custom information. This will bring you to the Host Management screen.
- In this screen, select the Misc Settings tab, and then click on the Manage Custom Variables button in the right column. This will bring up a Manage Custom Variables window.
- Here you have a Name field and a Value field.
- Things to keep in mind when filling out the Name field
- The beginning of the variable name should always be an underscore ( _ )
- It is best practice for the variable names to be all lower case, or all upper case
- Avoid special characters like spaces, and ampersands
- Things to keep in mind when filling out the Name field
- With those in mind, let’s create a variable named
_ncpa_token
.- You can see here I used an underscore in place of a space.
- For the Value, we’ll want whatever the host’s NCPA token actually is. In my case, I use a super secure token, ‘ASecretToken’.
Ideas For Using Custom Variables
Custom Variables can be referenced in host or service checks, Event Handlers, and through Nagios XI’s API. Any piece of information you think is relevant to the host or service can be placed via a custom variable. It might be a Dell service tag ID for a server or maybe the Windows service name of a service you are monitoring, for use with an Event Handler to attempt to restart the service.
Custom variables can be assigned to hosts or services. Personally, I’m a fan of assigning variables to hosts, because you can create a generalized service check referenced by multiple hosts (typically known as Hostgroup Inheritance). Then when Nagios runs a service check for any host with the specific custom variable, it will pull the custom variable from the host and insert it into the service check.
Note: In the previous image, the variables were defined like, _ncpa_port
, lower case, with an underscore in front. When referencing the variables, it’s _HOSTNCPA_PORT
, capitalized with underscore host in front denoting it is a custom variable defined at the host level.
This type of setup will add a ton of value for:
- Customers who need a different secret token for each system running NCPA
- Customers who are utilizing Hostgroup Inheritance
- Customers who need or want certain data to be available at a couple of clicks
When looking at dashboards in Nagios XI, you may find a host has gone down. Depending on the dashlet you are looking at, you can click into the host and see all of the custom variables you have defined for the host. This can be very useful for network operation centers where you may have a process for ordering replacement hardware for your servers. Not having to access another application to get the system’s manufacturer ID number could help System Administrators get parts ordered faster.
Additionally, automating workflows based around the status of a given host or its service checks could be created by pulling custom variable information from Nagios XI’s API. For example, host variables for Ansible could be defined as custom variables in Nagios XI. Then Ansible could use Nagios XI as an Ansible inventory source, and have connection information centralized in Nagios XI.
With custom variables, the only limitation is your imagination!