D.2 On-Demand Macros

On-demand macros—which have existed since Nagios 2.0—reference the same contents as standard macros do. The subtle difference between them lies in the context of what they reference. Whereas standard macros refer exclusively to the host, service, or contact object currently being used, on-demand macros enable access to values from any external objects you please:

$HOSTADDRESS:linux01$
$HOSTSTATE:switch05$

The macros are the same as standard macros, but their names include the name of the host to which the reference is made. The colon is used as a separator. For services, the service name also needs to be specified, again separated with another colon:

$SERVICESTATE:switch05:PING$
$SERVICESTATE::NRPE$

If the host field is left empty, ...

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.