Macros
One of the features available in NetSaint is the ability to use macros in command defintions. Immediately prior to the execution of a command, NetSaint will replace all macros in the command with their corresponding values. This allows you to define a few generic commands to handle all your needs.
Macro Validity
Although macros can be used in all commands you define, not all macros may be "valid" in a particular type of command. For example, some macros may only be valid during service notification commands, whereas other may only be valid during host check commands. There are 8 types of commands that NetSaint recognizes and treats differently:
The table below lists all macros currently available in NetSaint, along with a brief description of each and the types of commands in which they are valid. If a macro is used in a command in which it is invalid, it is replaced with an empty string. It should be noted that macros consist of all uppercase characters and are enclosed in $ characters.
Available Macros
Macro | Description | Service Checks | Service Notifications | Host Checks | Host Notifications | Service Event Handlers & Global Service Event Handler | Host Event Handlers & Global Host Event Handler |
$CONTACTNAME$ | Short name for the contact (i.e. "jdoe") that is being notified of a host or service problem | No | Yes | No | Yes | No | No |
$CONTACTALIAS$ | Long name/description for the contact (i.e. "John Doe") being notified | No | Yes | No | Yes | No | No |
$CONTACTEMAIL$ | Email address of the contact being notified | No | Yes | No | Yes | No | No |
$CONTACTPAGER$ | Pager number/address of the contact being notified | No | Yes | No | Yes | No | No |
$HOSTNAME$ | Short name for the host (i.e. "biglinuxbox"). During a service notification, this refers to the host associated with the service. | No | Yes | No | Yes | No | Yes |
$HOSTALIAS$ | Long name/description for the host (i.e. "Big Linux Server") | No | Yes | No | Yes | No | Yes |
$HOSTADDRESS$ | The IP address of the host | Yes | Yes | Yes | Yes | No | Yes |
$HOSTSTATE$ | The current state of the host ("UP", "DOWN", or "UNREACHABLE") | No | No | No | Yes | No | Yes |
$ARGn$ | The nth argument passed to the service check command. Read the documentation on service definitions for more info. NetSaint supports up to sixteen argument macros ($ARG1$ through $ARG16$). | Yes | No | No | No | No | No |
$SERVICEDESC$ | The long name/description of the service being monitored (i.e. "Main Website") | No | Yes | No | No | Yes | No |
$SERVICESTATE$ | The status of the service being monitored ("WARNING", "UNKNOWN", "CRITICAL", or "RECOVERY") | No | Yes | No | No | Yes | No |
$OUTPUT$ | The text output from the service check (i.e. "FTP ok - 1 second response time") | No | Yes | No | No | Yes | No |
$SUMMARY$ | The results of the generic service summary defined in the main configuration file | No | Yes | No | No | No | No |
$DATETIME$ | Date/time stamp | No | Yes | No | Yes | Yes | Yes |
$ADMINEMAIL$ | Email address for the local administrator (of the host doing the monitoring) | Yes | Yes | Yes | Yes | Yes | Yes |
$ADMINPAGER$ | Pager number/address for the local administrator | Yes | Yes | Yes | Yes | Yes | Yes |
$STATETYPE$ | The state type for the current service or host check ("HARD" or "SOFT"). Soft states occur when service or host checks return a non-OK state and are in the process of being retried. Hard states result when service or host checks have been checked a specified maximum number of times. Notifications are sent out only when hard state changes occur. | No | No | No | No | Yes | Yes |
$SERVICEATTEMPT$ | This refers to the number of the current service check retry. For instance, if this is the second time that the service is being rechecked, this will be the number two. Current attempt number is only useful when writing service event handlers for "soft" states that take a specific action based on the service retry number. | No | No | No | No | Yes | No |
$HOSTATTEMPT$ | This refers to the number of the current host check retry. For instance, if this is the second time that the host is being rechecked, this will be the number two. Current attempt number is only useful when writing host event handlers for "soft" states that take a specific action based on the host retry number. | No | No | No | No | No | Yes |