Given the following service and command configuration using Nagios 3.3.1…
[code]define service{
service_description service1
check_command check-my-service
…
_testmacro this-is-test-info
notes this is the notes macro
}
define service{
service_description service2
check_command check-my-service
…
}
define command{
command_name check-my-service
command_line echo “$SERVICEDESC$ macro -> $_SERVICETESTMACRO$ notes -> $SERVICENOTES$” > /tmp/test.out
}[/code]
If I restart Nagios and pick up this config, then watch the /tmp/test.out file, I get the following
and
So, the gist here is that the custom $_SERVICETESTMACRO$ macro substitutes in a “$” if that custom variable is not defined in the config. This is different than the stock $SERVICENOTES$ macro that doesn’t get anything substituted in. I know this is sort of an uncommon occurrence, but it did cause me grief earlier today. My workaround was to use the notes variable/macro and it behaved properly.