Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Clean: plus notion de illegal_macro_output_chars et des DATA on demand (mal gérées par l'arbiter donc dangereuse)

...


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:

  • Host:
PropertyValue
Namelinuxbox
address192.168.1.2
check_commandcheck_ping
  • Command

 

PropertyValue
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:

...

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:

PropertyValue
host_namelinuxbox
DescriptionPING
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:

PropertyValue
Namecheck_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:

...



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.

 

On-Demand datas

...

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:

  • * "$HOSTdataNAME:host_name$"
  • * "$SERVICEdataNAME:host_name:service_description$"

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:

  • $HOSTDOWNTIME:myhost$ // On-demand host data
  • $SERVICESTATEID:server:database$ // On-demand service data
  • $SERVICESTATEID::CPU Load$ // On-demand service data with blank host name field

...

  • $CONTACTEMAIL:john$ // On-demand contact data
  • $CONTACTGROUPMEMBERS:linux-admins$ // On-demand contactgroup data
  • $HOSTGROUPALIAS:linux-servers$ // On-demand hostgroup data
  • $SERVICEGROUPALIAS:DNS-Cluster$ // On-demand servicegroup data

 

Custom Variable datas


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

PropertyValue
Namelinuxbox
address192.168.1.1
_MACADDRESS00:01:02:03:04:05

 

The "_MACADDRESS" custom variable would be available in a data called "$_HOSTMACADDRESS$".

Data Cleansing

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:

  • $HOSTOUTPUT$
  • $LONGHOSTOUTPUT$
  • $HOSTPERFDATA$
  • $HOSTACKAUTHOR$
  • $HOSTACKCOMMENT$
  • $SERVICEOUTPUT$
  • $LONGSERVICEOUTPUT$
  • $SERVICEPERFDATA$
  • $SERVICEACKAUTHOR$

...