Appendix D. Macros

Macros are the salt in the Nagios soup, for without them each service would have to be defined individually for each host and each command defined separately for each host and each service. They are identified by the dollar signs surrounding them: $macro$. We will look at the definition of a command with the plugin check_http (see 6.4.2 Web server control via HTTP, page 119):

define command{
   command_name check_http
   command_line $USER1$/check_http -H $HOSTADDRESS$ $ARG1$
}

The definition contains three different macros: the user macro $USER1$, defined in the file resource.cfg (see 2.14 The Resources File resource.cfg, page 79), as well as $HOSTADDRESS$ and $ARG1$. The 32 possible user macros $USER1$ to $USER32$ are like constants ...

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.