A discovery rule allows to dynamically create services and to link them to a
host, based on the elements discovered by the probes. The created unit services
will be attached to a service template so that Centreon’s functionalities can
be used (inheritance, overloading and more).

To create a rule, go to Configuration > Services > Auto Discovery > Rules
and click on the Add button:

Fill the first fields:

Here is the description of the firsts fields located inside the General tab:

Command Discover: discovery command which will be executed to enumerate the elements

Service template: the service template used to dynamically create new services based
on the discovery

Go to the second Inclusions / Exclusions & Macros tab. You should see available XML attributes:

Come back to the first General tab, define the Service display name and
select values for the other fields:

Define the name of the service that will be created.

Note

The service name can contain a macro corresponding to an XML stream’s attribute.
For example: when looking for network interfaces, the interface name will be
given by the name attribute. Traffic-$name$ will be replaced by
Traffic-eth0 if the interface’s name is eth0. The XML attribute’s
name must be described between two $ characters.
You can use many XML attributes to build the service name.

Here is the description of the other fields located inside the General tab:

Hosts templates: the templates used to retrieve the list of
hosts for which a discovery rule should be run

Linked Instances: execute only the rule for host attached to selected instances.

Note

Keep empty to execute rule for any instance.

Contacts: contacts that will be notified about creation or deactivation during a discovery

Contact groups: contact groups that will be notified about
creation or deactivation during a discovery

Disable elements not found: let the module deactivate services
associated to elements that cannot be found anymore

The Inclusions / Exclusions part allows elements to be included or excluded
during the discovery. This inclusion/exclusion is relative to an XML attribute.

The inclusion/exclusion rules, are defined using the following algorithm:

If only inclusion rules are present, the attribute’s value corresponding to at least one inclusion will be considered

If only exclusion rules are present, every element will be considered, except the ones corresponding to an exclusion

If both types are present, the process checks if the element corresponds to an inclusion and then checks if it is not listed into the exclusion list

The second part Macros allows to define matches between an XML attribute
and a service’s template macro. For all created services the macros’ values
will be replaced by the attributes’ values.

Note

On the image above all macros will be created for the service because the
checkbox Empty are selected. To don’t create them do not check the Empty checkbox.
The $_SERVICEINTERFACEID macro created on the service will contain the value
of $interfaceid from the value of XML element.