O'Reilly logo

Nagios, 2nd Edition by Wolfgang Barth

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

H.2 Variable and Macros

You can define your own variables in the objects host, service, and contact. The names of these always begin with an underscore and are inherited like normal variables:

define host {
   host_name linux01
   use       host_site_t,host_generic_t
   ...
   _NRPE_PORT 5666
}

The variable _NRPE_PORT is accessed with $_HOSTNRPE_PORT$, which means that the object type (HOST, SERVICE, or CONTACT) is added after the underscore. This is slightly unfortunate, as it is more difficult to read. The macro created can be used elsewhere, for example in the definition of a command:

define command {
   command_name check_nrpe
   command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p $_HOSTNRPE_PORT$
-c $ARG1$
}

Macros allow access to configuration data, states, and check ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required