Skip to main content
Updated December 2026

Journey of a service discovery rule

Journey of a service discovery rule: finding network interfaces on a Linux server​

This topic follows a service discovery from its trigger to the moment the discovered services are monitored. It uses the discovery of network interfaces on a Linux server as an example.

The steps where the Monitoring Connector is involved are marked From the Monitoring Connector. The other steps are handled by Centreon's own components.

It follows on from Journey of a host discovery job: the host srv-linux-01 has been created with the host template OS-Linux-SNMP-custom.

Example used in this topic​

ItemValue
Hostsrv-linux-01 (192.168.1.20)
Host templateOS-Linux-SNMP-custom
Discovery ruleOS-Linux-SNMP-Traffic-Name
Discovery modelist-interfaces
Service template appliedOS-Linux-Traffic-Generic-Name-SNMP-custom
Services createdTraffic-eth0, Traffic-eth1

Note: Rule names, service templates, macros and XML attributes depend on your Monitoring Connector version. The commands and outputs below are simplified examples.

Host discovery and service discovery​

Host discovery and service discovery are two different mechanisms of the Auto Discovery module:

  • Host discovery uses jobs: it scans a network, a cloud account or a hypervisor to find hosts.
  • Service discovery uses rules: it looks inside hosts that already exist to find items to monitor, such as network interfaces, disks or file systems, and creates one service per item.

Overview​

Step 1: The rule is defined​

Discovery rules are listed in Configuration > Services > Rules. Most Monitoring Connectors provide ready-made rules. The rule used here contains:

SettingValue in this examplePurpose
Command MacroOS-Linux-SNMP-Traffic-NameCommand used to enumerate the items
Command Discoveros-linux-snmp-list-interfacesCommand that lists items on the host
Service templateOS-Linux-Traffic-Generic-Name-SNMP-customTemplate used for each new service
Service display nameTraffic-$name$Name of each new service, built from an XML attribute
Host templatesOS-Linux-SNMP-customThe rule applies to every host using this template
Disable elements not foundEnabledDisables services whose item disappeared
Update existing servicesEnabledUpdates macros of services already created
Contact groupsSupervisorsNotified when services are created or disabled
ActivateEnabledInactive rules are ignored

Because srv-linux-01 uses OS-Linux-SNMP-custom, this rule applies to it with no extra configuration.

From the Monitoring Connector: the rule itself, installed with the Linux SNMP Monitoring Connector, with its discovery commands, its service template, its link to the host template and its default inclusions and exclusions. You can adapt it, for example to change the inclusions or to activate it.

Step 2: The discovery is triggered​

A service discovery can start in three ways:

  • Scheduled: Gorgone's cron module runs all active rules periodically. By default, every day at 10:30 PM, as defined in /etc/centreon-gorgone/config.d/cron.d/41-service-discovery.yaml:

    - id: service_discovery
    timespec: "30 22 * * *"
    action: LAUNCHSERVICEDISCOVERY
  • Manual scan: in Configuration > Services > Scan, select a host and run the discovery to see and choose the results.

  • API: send a request to the Gorgone API, optionally filtered by rule, host or poller. Use dry_run to test without changing the configuration:

    curl --request POST "http://localhost:8085/api/centreon/autodiscovery/services" \
    --header "Content-Type: application/json" \
    --data '{"filter_rules": ["OS-Linux-SNMP-Traffic-Name"], "filter_hosts": ["srv-linux-01"], "dry_run": 1}'

Step 3: Gorgone finds which hosts and rules to run​

Gorgone on the central server lists the active rules, then the hosts that use the host templates linked to each rule. Here, it finds that OS-Linux-SNMP-Traffic-Name must run on srv-linux-01.

Gorgone resolves the rule's command with the host's values (address, SNMP community, macros) and sends it to Gorgone on the poller that monitors the host, poller-01.

Step 4: The poller runs the discovery plugin​

Gorgone on poller-01 runs the plugin in a list- mode with the --disco-show option:

/usr/lib/centreon/plugins/centreon_linux_snmp.pl --mode=list-interfaces \
--hostname=192.168.1.20 --snmp-version=2c --snmp-community=public --disco-show

From the Monitoring Connector: the plugin and its list-interfaces mode. It is the same plugin as the one used for the host's checks, so it is already installed on the poller that monitors the host.

Step 5: The plugin reads the server's interfaces​

The plugin queries the interface table of srv-linux-01 over SNMP and gets every interface with its name, status and speed.

poller-01 → SNMP walk interface table → 192.168.1.20
poller-01 ← lo (up)
poller-01 ← eth0 (up, 1000 Mb/s)
poller-01 ← eth1 (up, 1000 Mb/s)
poller-01 ← eth2 (down)

Step 6: The plugin returns an XML list​

With --disco-show, the plugin returns one XML element per item. Each piece of information is an XML attribute:

<?xml version="1.0" encoding="utf-8"?>
<data>
<label name="lo" status="up" total="10" interfaceid="1"/>
<label name="eth0" status="up" total="1000" interfaceid="2"/>
<label name="eth1" status="up" total="1000" interfaceid="3"/>
<label name="eth2" status="down" total="1000" interfaceid="4"/>
</data>

To know which attributes a mode returns, run it with --disco-format instead of --disco-show. The same attributes are shown in the rule's Inclusions / Exclusions & Macros tab.

From the Monitoring Connector: the list of XML attributes, which is defined by the plugin's mode. They are what you can filter on and map to macros in the rule.

Gorgone on the poller sends the list back to Gorgone on the central server.

Step 7: Inclusions and exclusions filter the list​

The rule's inclusions and exclusions are applied to the XML attributes:

RuleAttributeValueEffect
Exclusionname^lo$lo is removed
Inclusionstatusupeth2 is removed

Two items remain: eth0 and eth1.

Step 8: Each item becomes a service​

For each remaining item, the rule builds a service:

  • Name: Traffic-$name$ gives Traffic-eth0 and Traffic-eth1.
  • Template: OS-Linux-Traffic-Generic-Name-SNMP-custom.
  • Macros: XML attributes are mapped to service macros. For example, name fills the INTERFACENAME macro, so Traffic-eth0 monitors eth0.

The services are created on srv-linux-01. Items already in the configuration are skipped, or updated if Update existing services is enabled.

With a manual scan, nothing is created until you select the items and save.

From the Monitoring Connector: the service template OS-Linux-Traffic-Generic-Name-SNMP-custom, which brings the check command, the macros and the default thresholds of each new service.

Step 9: Missing items are disabled​

Disable elements not found is enabled, so Gorgone compares the discovered items with the services created by this rule on previous runs. If an interface has disappeared, its service is disabled.

The Supervisors contact group receives an email listing the services created and disabled.

Step 10: The configuration is deployed​

The poller configuration is exported and Centreon Engine on poller-01 is reloaded. Traffic-eth0 and Traffic-eth1 are now scheduled like any other service.

From here, each check follows the journey described in Journey of a service check.

Host discovery versus service discovery​

Host discoveryService discovery
Configured asJobs (Configuration > Hosts > Discovery)Rules (Configuration > Services > Rules)
ScopeA network, account or platformHosts using the rule's host templates
Triggered byJob schedule or Force executionGorgone cron (daily by default), manual scan or API
Run byGorgoneGorgone
Provided by the Monitoring ConnectorThe discovery providerThe discovery rules
Plugin outputJSONXML (--disco-show)
Results turned into objects byMappersInclusions, exclusions and macros
CreatesHosts (and their template services)Services on existing hosts
Removes what's goneNo (only excluded hosts can be disabled)Yes, with Disable elements not found

Behavior to keep in mind​

  • A rule only runs on hosts whose host templates are linked to it. If a host is missing from the results, check its templates first.
  • A rule must be activated to run from the cron or the API.
  • If you rename the services a rule creates (by changing Service display name), the next run creates new services instead of matching the old ones, which leads to duplicates.
  • Test changes with a manual scan or the API's dry_run option before letting the scheduled run apply them.