L'une des caractéristiques principales qui rend Shinken Enterprise si flexible, c'est sa capacité à utiliser des données dans la définition des commandes. Ces données permettent de référencer des informations provenant des hôtes, des services, ou d'autres sources dans les commandes.
Before Shinken Enterprise executes a command, it will replace any datas it finds in the command definition with their corresponding values. This data substitution occurs for all types of commands that Shinken Enterprise executes - host and service checks, notifications, event handlers, etc.
Certain datas may themselves contain other datas. These include the "$HOSTNOTES$", "$HOSTNOTESURL$", "$HOSTACTIONURL$", "$SERVICENOTES$", "$SERVICENOTESURL$", and "$SERVICEACTIONURL$" datas.
Tip: If, you need to have the '$' character in one of your command (and not referring to a data), please put "$$" instead. Shinken Enterprise will replace it well
When you use host and service datas in command definitions, they refer to values for the host or service for which the command is being run. Let's try an example. Assuming we are using a host definition and a check_ping command defined like this:
| Property | Value |
|---|---|
| Name | linuxbox |
| address | 192.168.1.2 |
| check_command | check_ping |
| Property | Value |
|---|---|
| Name | check_ping |
| command_line | /var/lib/Shinken Enterprise/libexec/check_ping -H $HOSTADDRESS$ -w 100.0,90% -c 200.0,60% |
The expanded/final command line to be executed for the host's check command would look like this:
/var/lib/Shinken Enterprise/libexec/check_ping -H 192.168.1.2 -w 100.0,90% -c 200.0,60% |
You can use a single command definition to check an unlimited number of hosts. Each host can be checked with the same command definition because each host's address is automatically substituted in the command line before execution.
You can pass arguments to commands as well, which is quite handy if you'd like to keep your command definitions rather generic. Arguments are specified in the object (i.e. host or service) definition, by separating them from the command name with exclamation points (!) like so:
The check:
| Property | Value |
|---|---|
| host_name | linuxbox |
| Description | PING |
| command | check_ping!200.0,80%!400.0,40% |
In the example above, the service check command has two arguments (which can be referenced with $ARGn$. The $ARG1$ data will be "200.0,80%" and "$ARG2$" will be "400.0,40%" (both without quotes). Assuming we are using the host definition given earlier and a check_ping command defined like this:
The command:
| Property | Value |
|---|---|
| Name | check_ping |
| command line | /var/lib/Shinken Enterprise/libexec/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ |
The expanded/final command line to be executed for the service's check command would look like this:
/var/lib/Shinken Enterprise/libexec/check_ping -H 192.168.1.2 -w 200.0,40% -c 400.0,80% |
If you need to pass bang (!) characters in your command arguments, you can do so by escaping them with a backslash (\). If you need to include backslashes in your command arguments, they should also be escaped with a backslash.
Normally when you use host and service datas in command definitions, they refer to values for the host or service for which the command is being run. For instance, if a host check command is being executed for a host named "linuxbox", all the :ref:standard host datas <thebasics/datalist> will refer to values for that host ("linuxbox").
If you would like to reference values for another host or service in a command (for which the command is not being run), you can use what are called "on-demand" datas. On-demand datas look like normal datas, except for the fact that they contain an identifier for the host or service from which they should get their value. Here's the basic format for on-demand datas:
Replace "HOSTdataNAME" and "SERVICEdataNAME" with the name of one of the standard host of service datas found :ref:here <thebasics/datalist>.
Note that the data name is separated from the host or service identifier by a colon (:). For on-demand service datas, the service identifier consists of both a host name and a service description - these are separated by a colon (:) as well.
On-demand service datas can contain an empty host name field. In this case the name of the host associated with the service will automatically be used.
Examples of on-demand host and service datas follow:
On-demand datas are also available for hostgroup, servicegroup, contact, and contactgroup datas. For example:
Any custom object variables that you define in host, service, or contact definitions are also available as datas. Custom variable datas are named as follows:
Take the following host definition with a custom variable called ""_MACADDRESS""...
Host definiton
| Property | Value |
|---|---|
| Name | linuxbox |
| address | 192.168.1.1 |
| _MACADDRESS | 00:01:02:03:04:05 |
The "_MACADDRESS" custom variable would be available in a data called "$_HOSTMACADDRESS$".
Some datas are stripped of potentially dangerous shell metacharacters before being substituted into commands to be executed. Which characters are stripped from the datas depends on the setting of the illegal_data_output_chars directive. The following datas are stripped of potentially dangerous characters: