GDMA Advanced

Version 2 by Bren Eckles
on Oct 05, 2018 13:52.

compared with
Version 3 by Bren Eckles
on Sep 05, 2019 07:32.

Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (7)

View Page History

GDMA macro substitution is done in two places:

# On the server, when externals are built
# On the client, when checks are executed

Here are all the variables that are substituted into the {{host-config}} file content, both when externals are built on the server, and when the contents of that file are interpreted on the client.

# When externals are built on the server:
## Service external macros are substituted first. For each host, all the service externals for that host are processed first and all of their service-related macro substitutions are done at that time. Listed here are macro references that may be used in service externals:
##* {{$INSTANCESUFFIX$}} expands to the instance name suffix as defined in Monarch, but with a leading underscore (if any) elided. This makes it easier to customize the service externals definitions with a string reflecting just the critical part of the service instance name suffix, while keeping an underscore in the instance name suffix for overall readability of the full service name.
##* {{$ARG#$}} macros ({{$ARG1$}}, {{$ARG2$}}, etc.) expand to values defined in the Monarch UI at either the generic-service, host-service, or service-instance level, depending on the complexity of your setup and what inheritance options you have chosen.
##* Attempting to use these macros to best effect and to generalize service externals definitions as much as possible, the following general form is recommended: (This example is not trying to establish any convention for the ordering or use of the {{$ARG#$}} macros. Instead, it is illustrating the intended uses of the {{$BASESERVICEDESC$}}, {{$INSTANCE$}}, {{$SERVICEDESC$}}, and {{$INSTANCESUFFIX$}} macros.)
{noformat}Check_$BASESERVICEDESC$[$INSTANCE$]_Enable="ON"
Check_$BASESERVICEDESC$[$INSTANCE$]_Service="$SERVICEDESC$"
Check_$BASESERVICEDESC$[$INSTANCE$]_Command="check_foo_activity -w
Check_$BASESERVICEDESC$[$INSTANCE$]_Command="check_foo -w $ARG1$ -c $ARG2$ -i $INSTANCESUFFIX$"
Check_$BASESERVICEDESC$[$INSTANCE$]_Check_Interval="$ARG3$"{noformat}
This example is not trying to establish any convention for the ordering or use of the {{$ARG#$}} macros. Instead, it is illustrating the intended uses of the {{$BASESERVICEDESC$}}, {{$INSTANCE$}}, {{$SERVICEDESC$}}, and {{$INSTANCESUFFIX$}} macros.
{note:title=IMPORTANT UPDATE}
What we have above, as the recommended boilerplate construction for service externals, will work cleanly for all setup cases for GDMA *2.7.0 and later*. It will also work adequately when generating externals for earlier GDMA releases, for services with a {{\_Check_Interval}} of "1". *However, if you have earlier GDMA releases deployed*, it is necessary to switch to an alternate construction if you have set the {{\_Check_Interval}} in the service external to a value greater than 1 (in this example boilerplate, we assume that {{$ARG3$}} might expand to a value other than 1) and you have multiple instances for the service:
\\
\\
The alternate boilerplate form would look like:
{noformat}Check_$SERVICEDESC$[1]_Enable="ON"
Check_$SERVICEDESC$[1]_Service="$SERVICEDESC$"
Check_$SERVICEDESC$[1]_Command="check_foo -w $ARG1$ -c $ARG2$ -i $INSTANCESUFFIX$"
Check_$SERVICEDESC$[1]_Check_Interval="2"{noformat}
The expanded forms could be these, assuming instance names of {{\_first}} and {{\_second}} for the instances of the {{foo}} service on this host in Monarch:
{noformat}Check_foo_first[1]_Enable="ON"
Check_foo_first[1]_Service="foo_first"
Check_foo_first[1]_Command="check_foo -w 10 -c 20 -i first"
Check_foo_first[1]_Check_Interval="2"

Check_foo_second[1]_Enable="ON"
Check_foo_second[1]_Service="foo_second"
Check_foo_second[1]_Command="check_foo -w 15 -c 25 -i second"
Check_foo_second[1]_Check_Interval="2"{noformat}
Specifically, {{$BASESERVICEDESC$}} gets manually changed to {{$SERVICEDESC$}}, and {{\[$INSTANCES$\]}} gets manually changed to \[1\].
\\
GDMA itself is in this case unaware that these are multiple service instances; it just treats them as completely separate services, each with only one instance.
## Then, Nagios resource macros are substituted. These are {{$USERn$}} references, as defined under _Configuration > Control > Nagios resource macros_.
## Next, Monarch group macros are substituted, as defined under _Configuration_ > _Groups_ > _Macros_ (to first establish the existence of a given macro name) and then under _Configuration_ > _Groups_ > _Groups_ > <_group name>_ > _Detail_ > _Macros_.