D.3 Macros for User-defined Variables

Starting from Nagios 3.0, you can specify your own macros in host, service, and contact definitions. These macros, called custom macros in Nagios jargon, are treated like normal standard macros, and their names begin with an underscore to make them more easily identifiable:

define host {
   host_name         linux01
   ...
   _NSCLIENT_PORT 12489
   _ASSETID       734287
}
define service {
   host_name           linux01
   service_description HTTP
   ...
   _HTTP_PORT          8080
}
define contact {
   contact_name wob
   ...
   _DEPARTMENT  41ZBV
}

They are addressed with a prefixed object type:

$_HOSTNSCLIENT_PORT$
$_HOSTASSETID$
$_SERVICEHTTP_PORT$
$_CONTACTDEPARTMENT$

The macro again starts with an underscore, but the underscore supplied in the definition is omitted. This ...

Get Nagios, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.