Reader small image

You're reading from  Nagios Core Administration Cookbook Second Edition - Second Edition

Product typeBook
Published inFeb 2016
Publisher
ISBN-139781785889332
Edition2nd Edition
Tools
Right arrow
Author (1)
Tom Ryder
Tom Ryder
author image
Tom Ryder

Tom Ryder is a systems administrator living in New Zealand who works for an internet services provider. He loves terminals, text editors, network monitoring and security, Unix and GNU/Linux, shell script, and programming in general. He is also the author of the Nagios Core Administration Cookbook.
Read more about Tom Ryder

Right arrow

Defining macros in a resource file


In this recipe, you'll learn how to define custom user macros in resource files. This is good practice for strings used in check_command definitions or other directives that are shared by more than one host or service. For example, take a look at the following example of writing the full path in a command_name directive:

command_name=/usr/local/nagios/libexec/check_ssh $HOSTADDRESS$

In lieu of this, we could write the following line:

command_name=$USER1$/check_ssh $HOSTADDRESS$

As a result, if the location of the check_ssh script changes, we only need to change the value of $USER1$ in the appropriate resource file to update all of its uses throughout the configuration.

Most of the macros in Nagios Core are defined automatically by the monitoring server, but up to 32 user-defined macros can be used as well in the $USERn$ form.

Getting ready

You will need to have a server running Nagios Core 4.0 or later and have access to the command line to change its configuration...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Nagios Core Administration Cookbook Second Edition - Second Edition
Published in: Feb 2016Publisher: ISBN-13: 9781785889332

Author (1)

author image
Tom Ryder

Tom Ryder is a systems administrator living in New Zealand who works for an internet services provider. He loves terminals, text editors, network monitoring and security, Unix and GNU/Linux, shell script, and programming in general. He is also the author of the Nagios Core Administration Cookbook.
Read more about Tom Ryder