Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto...

43
Centreon Auto Discovery Documentation Release 19.10 CENTREON March 16, 2020

Transcript of Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto...

Page 1: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

Centreon Auto DiscoveryDocumentation

Release 19.10

CENTREON

March 16, 2020

Page 2: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery
Page 3: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

Contents

i

Page 4: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

ii

Page 5: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

The Centreon Auto Discovery module offers the possibility of importing hosts and services as well as keeping yourCentreon supervision configuration up-to-date.

Contents:

ContentsCENTREON 46-52 RUE ALBERT FR75014 PARIS

1

Page 6: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

2CENTREON 46-52 RUE ALBERT FR75014 PARIS

Contents

Page 7: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

CHAPTER 1

Introduction

Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality.

The Auto Discovery module uses the plugins to get a list of new resources to monitor: new hosts or new services.These resources can then be configured in Centreon using host templates or service templates.

Host Discovery Rules and Service Discovery Rules instruct Centreon how to connect to an equipment and get the listof resources that could be monitored. These discovery rules are included in the Plugin Packs.

For example, ESX nodes and virtual machines can be automatically discovered in a VMware cluster. Or networkinterfaces and disk volumes in a Linux server.

For all hosts or services for which discovery rules are available, the Centreon configuration user interface propose toconnect to the equipment and fetch a list of available resources with their associated template, ready to be configuredin Centreon.

This discovery mechanism can also be scheduled and automatically executed. New automatically discovered resourcesmay optionally automatically be configured in Centreon.

The same discovery mechanism may apply to resources that would no longer be available. They can be listed andoptionally disabled from the configuration.

Contacts may be associated to a discovery rule to be notified when any configuration change occurs.

1.1 Prerequisits

The Centreon Auto Discovery module is an add-on to the Centreon IMP and Centreon EMS solution. A valid EPPLicense or IMP subscription is required to access the Auto Discovery functionalities.

1.2 Screenshots

3

Page 8: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

Figure 1.1: Hosts discovery rules

Figure 1.2: Manual services discovery

4CENTREON 46-52 RUE ALBERT FR75014 PARIS

Chapter 1. Introduction

Page 9: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

Figure 1.3: Services discovery rules

1.2. ScreenshotsCENTREON 46-52 RUE ALBERT FR75014 PARIS

5

Page 10: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

6CENTREON 46-52 RUE ALBERT FR75014 PARIS

Chapter 1. Introduction

Page 11: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

CHAPTER 2

Release notes

2.1 Release note 19.10.x

2.1.1 Centreon Auto Discovery 19.10.2

BugFix

• Multiple mapping are not properly managed on pp upgrade (PR #145)

• Service discovery is run on disabled hosts (PR #174)

2.1.2 Centreon Auto Discovery 19.10.1

BugFix

• [Cron] cron for services discovery doesn’t exist if any rules are enable (PR/#155,#156)

Security

• Avoid exploitation of a RCE using the data sent by the JSON of Ajax requests - CVE-2019-17642

• Run autodiscovery cron with apache user - CVE-2019-1642

2.1.3 Centreon Auto Discovery 19.10.0

Enhancements

• [Configuration] Install host discovery providers using Plugin Packs

• [Hosts Discovery] Manage multiple mappings

• [Service Discovery] Sorting services for manual scan

• [Service Discovery] Execute discovery comands from poller behind Remote Server

• [UI] Manage frontend translation

7

Page 12: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

Bug fixes

• [Configuiration] Break loop once attribute is found

• [Cron] Do not run service discovery if module is not installed

• [Cron] Fix jobs being launched several times

• [Install] Remove topology_id field in SQL install script

• [Install] remove hardcoded centreon database name

• [Service Discvoery] Fix hash of discovered services causing services to be disabled

• [UI] Manage properly long labels in wizard form

• [UI] Include footer to avoid inception when license is not valid

• [UI] Avoid css collisions when loading react pages

Technical

• [Packaging] Update to PHP 7.2

• [Packaging] Set packages as noarch

• [Packaging] remove cipher engine fro mcron

• [SQL] Start compatibility with SQL strict mode

• [Upgrade] Update json to match new packs

• [Upgrade] Migrate properly provider name

• [Upgrade] Remove CREDENTIALS and DISCOVERY from macro

2.2 Release note 19.04.x

2.2.1 Centreon Auto Discovery 19.04.3

Bug fixes

• Multiple mapping are not properly managed on pp upgrade (PR #145)

• Service discovery is run on disabled hosts (PR #174)

2.2.2 Centreon Auto Discovery 19.04.2

Documentation

• Update rules creation documentation for the new splitted scripts

Bug fixes

• The auto-discovery cron command should not be run by root

• Cron for auto-discovery does not exist if any rule is enabled

8CENTREON 46-52 RUE ALBERT FR75014 PARIS

Chapter 2. Release notes

Page 13: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

Security

• Avoid exploitation of a RCE using the data sent by the JSON of Ajax requests - CVE-2019-17642

• Run autodiscovery cron with apache user - CVE-2019-16406

2.2.3 Centreon Auto Discovery 19.04.1

Enhancements

• Execute service discovery commands for poller behind a Remote Server

• Manage properly long labels in the wizard form

• Manage module translation

Bug fixes

• Correct “Update existing services” functionality is set to “Disable”

• Fix authentication token parsing method causing connection fail

• Fix poller filter from ui and command line

• Fix hash of discovered services causing services to be disabled

• Remove hardcoded centreon database name

• Do not run service discovery if module is not installe

• Include footer to avoid inception when license is not valid

2.2.4 Centreon Auto Discovery 19.04

Enhancements

• Add a host resource discovery for Amazon Web Services EC2

• Add a host resource discovery for Microsoft Azure Virtual Machines

• Add a host resource discovery for VMware ESX

• Add a host resource discovery for VMware VM

2.3 Release notes 18.10.x

2.3.1 Centreon Auto Discovery 18.10.8

Enhancement

• Execute service discovery commands for poller behind a Remote Server

• Update rules creation documentation

2.3. Release notes 18.10.xCENTREON 46-52 RUE ALBERT FR75014 PARIS

9

Page 14: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

Bug fixes

• Fix hash of discovered services causing services to be disabled

• Fix cron stop if no active service discovery rule

Security

• Run autodiscovery cron with apache user - CVE-2019-16406

• Correct RCE using the ajax filter - CVE-2019-17642

2.3.2 Centreon Auto Discovery 18.10.7

Bug fixes

• Correct “Update existing services” functionality is set to “Disable”

• Fix authentication token parsing method causing connection fail

• Fix poller filter from ui and command line

2.3.3 Centreon Auto Discovery 18.10.6

Enhancements

• Improve database management

• Display only hosttemplate linked to discovery rules in ‘Overview’ menu

• Possibility to define a dedicated CLAPI user for Centreon audit logs

Bug fixes

• Fix database disconnect

2.3.4 Centreon Auto Discovery 18.10.5

Bug fixes

• fix inclusion/exclusion when import and duplication of rule

2.3.5 Centreon Auto Discovery 18.10.4

Enhancement

• Change subject of mail using configuration file

• Possibility to do not update existing services

• Add option to disable certificate verification

• Import Centreon auto Discovery rule with Centreon Plugin Packs

10CENTREON 46-52 RUE ALBERT FR75014 PARIS

Chapter 2. Release notes

Page 15: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

• Explain all configuration file parameters in documentation

Bug fixes

• Correct search in “Overview” menu

2.3.6 Centreon Auto Discovery 18.10.3

Bug fixes

• Fix issue for user with ACL to access to list of host in manual scan

2.3.7 Centreon Auto Discovery 18.10.2

Bug fixes

• Use default config file if no config extra is given

2.3.8 Centreon Auto Discovery 18.10.1

Bug fixes

• Correct a kernel segfault when user start manual scan

• Fix save of macro value with manual scan

2.3.9 Centreon Auto Discovery 18.10.0

Change version number according to new Centreon Lifecycle Products Policy

2.4 Release notes

2.4.1 Centreon Auto Discovery 2.4.0

CHANGELOG

• Enhancement: Add Libssh-Session perl library to parallelize discovery

• Enhancement: Add new relation to bind rules to instances

• Not compatible anymore with Centreon Web < 2.8

2.4. Release notesCENTREON 46-52 RUE ALBERT FR75014 PARIS

11

Page 16: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

2.4.2 Centreon Auto Discovery 2.2.0

CHANGELOG

• Enhancement: Add capability to add specific code in rules configuration

• Enhancement: Add regexp modifier configuration

2.4.3 Centreon Auto Discovery 2.1.2

CHANGELOG

• Compatibility with Centreon Web 2.7 with the good path to Centreon Clapi binary

• Better management of special characters during manual discovery

2.4.4 Centreon Auto Discovery 2.1.0

This new version merge Centreon Disco and Centreon Auto Discovery modules.

Thus it is possible to perform the discovery of new indicators out manually or automated through rules.

CHANGELOG

• Compatibility with the new Centreon web 2.7 style

• Integration of the Centreon Disco functionalities in Centreon Auto Discovery module

2.4.5 Centreon Auto Discovery 2.0.0

Important notes

Centreon Plugins compatibility

Since this version the Centreon Auto Discovery module use the new Centreon Plugins system to discover items onhosts.

Please refer to the Centreon Plugins documentation to install and use these new monitoring plugins.

The Centreon Plugins allows to discover items using predefined mode like ‘–mode=list-interfaces’, ‘–mode=list-storage’ to get an XML flow needed by the Centreon Auto Discovery module just add ‘–disco-show’ option in com-mand line.

Example:

# /usr/lib/nagios/plugins/centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=list-interfaces --hostname=192.168.220.129 --snmp-version=2 --snmp-community=public --disco-show<?xml version="1.0" encoding="utf-8"?><data>

<label status="1" name="lo" total="10" interfaceid="1"/><label status="1" name="eth0" total="1000" interfaceid="2"/>

</data>

12CENTREON 46-52 RUE ALBERT FR75014 PARIS

Chapter 2. Release notes

Page 17: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

Warning: This new version is build to use new plugins from Centreon Plugins and disable all discovery ex-isting rules. Although it is still possible to use old rules (because rules and discovery plugins are not deleted),CENTREON recommends creating new rules based on the new plugins.

Warning: If a new rule is created from the definition of an old rule, check the name of established services isidentical with the old name. If not new services are created in duplicate.

CHANGELOG

• New cron to execute discovery rules

• Possibility to execute manually rules using –filter-host, –filter-rule, –dry-run options

• Centreon Plugins compatibility

• Correction of a bug to display disabled rules

• Possibility to use every XML attributes in inclusion/exclusion rules

• Possibility to change order of inclusion/exclusion in rule definition

• Possibility to use many XML attributes to build the service name created

• Possibility to apply regexp on XML attributes values and service name created

• Possibility to duplicate rules

2.4.6 Centreon Auto Discovery 1.2.1

Important notes

• Get “/” char for interface names of network devices

• $USERx$ macro is now created during installation

2.4.7 Centreon Auto Discovery 1.1.2

Important notes

Nagios compatibility

The default permissions applied to Nagios’ configuration files don’t allow the discovery module to update them. Tofix it, you will need to run the following commands:

$ cd /etc/nagios$ chown nagios:nagios *.cfg$ chmod g+w *.cfg

2.4. Release notesCENTREON 46-52 RUE ALBERT FR75014 PARIS

13

Page 18: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

14CENTREON 46-52 RUE ALBERT FR75014 PARIS

Chapter 2. Release notes

Page 19: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

CHAPTER 3

Installation

3.1 Prerequisites

3.1.1 License

Regardless of Centreon IMP or Centreon EPP mode, a license is required to manage Plugin Packs. If you use CentreonIMP in connected mode, your license will be directly downloaded to your server. Otherwise, contact the Centreonsupport team.

3.1.2 Software

Software Required versionCentreon IMP 19.04Plugin Packs latest version

3.2 Module installation

Execute the following command:

# yum install centreon-auto-discovery-server

3.2.1 Configuring Centreon API access

Edit the /etc/centreon/centreon_autodisco.pm file and configure the clapi_user and clapi_password pa-rameters, then save modifications and close the file.

3.2.2 Web installation

Connect to the Centreon’s web interface using an account allowed to administer products and go to the Administration> Extensions > Manager menu.

Click on the installation icon corresponding to the Centreon Auto Discovery module:

15

Page 20: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

The module is now installed:

3.2.3 Installing the Plugin Packs

To get discovery rules ready to use, please go to Configuration > Pluin Packs menu and install your first packs.

16CENTREON 46-52 RUE ALBERT FR75014 PARIS

Chapter 3. Installation

Page 21: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

CHAPTER 4

User guide

4.1 Hosts Discovery

Note: The discovery rules are provided from installation of Plugin Packs (MS Azure, Amazon Web Services,VMware, etc.). To know the complete list, please go to the Plugin Packs catalog.

Discovering new resources is done in two steps:

1. Start a discovery task

2. Analyze the result of a discovery task

4.1.1 Start a discovery task

Note: The discovery is made from the monitoring plugins. It’s mandatory to install needed plugin. Please read themonitoring procedure of the Plugin Pack and perform all actions.

Note: Currently resources discovery and monitoring can only be done from the central Centreon server.

Go to Configuration > Hosts > Discovery and click on the Add button:

17

Page 22: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

Select the discovery rule and click on the Next button:

18CENTREON 46-52 RUE ALBERT FR75014 PARIS

Chapter 4. User guide

Page 23: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

Enter a name to save the settings to reuse them:

4.1. Hosts DiscoveryCENTREON 46-52 RUE ALBERT FR75014 PARIS

19

Page 24: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

Enter remote API access settings, then click on the Next button:

20CENTREON 46-52 RUE ALBERT FR75014 PARIS

Chapter 4. User guide

Page 25: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

A discovery task had been created, you go back to the listing of discovery tasks:

Wait for the data recovery time.

4.1.2 Analyze the result of a discovery task

Go to the Configuration > Hosts > Discovery menu to access to the list of discovery tasks:

The legend is:

• Pending task

• Failed task

• Completed task & ready for analysis

Click on the name of the task to discover the result:

Available actions are:

• Filter by name of resources

• Select resources one by one or all visible resources

• Modify the selected monitoring template

• Delete the selection of all resources

• Back to the listing of tasks

Once the resources are selected, you can:

• Save: import resources in monitoring configuration.

• Save & monitor: import resources in monitoring configuration and start the monitoring of them.

4.1. Hosts DiscoveryCENTREON 46-52 RUE ALBERT FR75014 PARIS

21

Page 26: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

You back to the list of discovery tasks.

Regarding your choice, go to Configuration > Hosts > Hosts or Monitoring > Status Details > Services* menu tovisualize the result:

4.1.3 Reload a discovery task

During the first discovery task, the settings had been stored. So, it is possible to select them to create a new discoverytask:

22CENTREON 46-52 RUE ALBERT FR75014 PARIS

Chapter 4. User guide

Page 27: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

4.1. Hosts DiscoveryCENTREON 46-52 RUE ALBERT FR75014 PARIS

23

Page 28: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

4.1.4 FAQ

If any Plugin Packs containing discovery rules have been installed an error message prompts you to perform thisaction:

If a task is in failed status, place your cursor on the icon to know the reason:

4.2 Manual services discovery

After the discovery rules programmed it is possible to run them from the Centreon web interface. Go to the Configu-ration > Services > Auto Discovery > Scan menu.

Start to write the name of host and the web interface automatically complete the name:

Select the discovery command to run from the list that has just appeared:

24CENTREON 46-52 RUE ALBERT FR75014 PARIS

Chapter 4. User guide

Page 29: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

Note: If the list is empty it means that your host doesn’t belong to a group of hosts linked to a discovery rule.

Click on the Scan button and wait during the discovery:

The result is displayed. Select items to add to the monitoring and click on the Save button:

The items were added and it is no longer possible to select them:

4.2. Manual services discoveryCENTREON 46-52 RUE ALBERT FR75014 PARIS

25

Page 30: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

Note: In the list of result it is possible that some items can’t be selected. This indicates that they are already part ofthe configuration.

The services were added and can be displayed in the menu Configuration > Services > Services by host:

4.3 Automate discovery

All active rules are run every night to keep your configuration up-to-date. The execution time is programmed ina:ref:cron <sched_job>.

Note: Even if a rule is disabled, it is still possible to use it to manually discover services.

26CENTREON 46-52 RUE ALBERT FR75014 PARIS

Chapter 4. User guide

Page 31: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

CHAPTER 5

Configuration guide

5.1 Discovery rules

5.1.1 General options

A discovery rule allows to dynamically create services and to link them to a host, based on the elements discoveredby the probes. The created unit services will be attached to a service template so that Centreon’s functionalities can beused (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:

• Rule name: the rule’s name

• Command Macro: discovery command which allow to list available XML attributes

• 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.

27

Page 32: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

28CENTREON 46-52 RUE ALBERT FR75014 PARIS

Chapter 5. Configuration guide

Page 33: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

Note: The service name can contain a macro corresponding to an XML stream’s attribute. For example: when lookingfor network interfaces, the interface name will be given by the name attribute. Traffic-$name$ will be replaced byTraffic-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 foundanymore

• Update existing services: update created service property if enable (custom macro, etc.).

• Activate: activate or deactivate the rule (will be ignored by the discovery process if deactivated)

Click on the Save button to save the discovery rule.

5.1.2 Inclusions / Exclusions & Macros

The Inclusions / Exclusions & Macros tab works as follows:

The Inclusions / Exclusions part allows elements to be included or excluded during the discovery. This inclu-sion/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 anexclusion

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

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

5.1. Discovery rulesCENTREON 46-52 RUE ALBERT FR75014 PARIS

29

Page 34: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

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

5.1.3 Advanced options

On the last Advanced tab you can apply a regexp on the Service display name. Click on Add a new entry buttonand define Pattern and expression result:

The regexp can be apply on String field for:

• @SERVICENAME@: The name of service will be created

• All XML attributes defined by $attribute_name$

The second part Customize code allows to use Perl code.

Custom display scan gives you the capability to change the display of a manual scan. By default, manual scan displaythe service name. Here an example to add the size of the disk:

my ($value, $unit) = change_bytes(value => $total$);$description = "<span style=’color: red; font-weight: bold’>@SERVICENAME@</span> [size = <b>$value $unit</b>]";

Custom variables gives you the capability to create some custom macros. Here an example to have dynamic thresholdaccording the disk size:

my $total_gb = $total$ / 1000 / 1000 / 1000;if ($total_gb < 100) {

$warning$ = 80;$critical$ = 90;

} elsif ($total_gb < 500) {$warning$ = 90;$critical$ = 95;

} else {$warning$ = 95;$critical$ = 98;

}

Now, you could use $warning$ and $critical$ macro in Macros part.

30CENTREON 46-52 RUE ALBERT FR75014 PARIS

Chapter 5. Configuration guide

Page 35: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

5.2 Discovery commands

A discovery commands is a command line to execute a discovery plugin.

For each discovery plugins you need to define two commands:

• The first one to get the list of available XML attributes

• The second one to discover items on a host

5.2.1 Command to list available XML attributes

Go to Configuration > Commands > Discovery menu and click on Add button to create the first command.

Fill the fileds:

• Command Name: Name of your command

• Command type: check Discovery option

• Command Line: Define the command to get the list of XML attributes

Note: All commands using Centreon Plugin project need to set the hostname option so add –hostname=127.0.0.1 inyour command line

This is an example of the command line executed in a shell:

# /usr/lib/centreon/plugins/centreon_linux_snmp.pl --mode=list-interfaces --hostname=127.0.0.1 --disco-format<?xml version="1.0" encoding="utf-8"?><data>

<element>name</element><element>total</element><element>status</element><element>interfaceid</element>

</data>

Save the command.

5.2. Discovery commandsCENTREON 46-52 RUE ALBERT FR75014 PARIS

31

Page 36: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

5.2.2 Command to get the list of items on a host

Go to Configuration > Commands > Discovery menu and click on Add button to create the first command.

Fill the fileds:

• Command Name: Name of your command

• Command type: check Discovery option

• Command Line: Define the command to get the list of items.

This is an example of the command line executed in a shell:

# /usr/lib/centreon/plugins/centreon_linux_snmp.pl --mode=list-interfaces --hostname=192.168.220.129 --snmp-version=2 --snmp-community=public --disco-show<?xml version="1.0" encoding="utf-8"?><data>

<label status="1" name="lo" total="10" interfaceid="1"/><label status="1" name="eth0" total="1000" interfaceid="2"/>

</data>

Save the command.

5.3 Discovery plugins

A discovery plugin (also called plugin) is a script that lists a set of similar elements such as file systems or networkinterfaces on a given equipment.

This plugins must be executable from the command line (shell) by the centreon user (or the user running the monitor-ing engine). It can be run locally or remotely using protocols such as SSH or NRPE.

The result must be a valid XML stream where each element must be described as an attribute of a XML node. Thisexecution must be available using an option. The Centreon Plugins use ‘–mode=xxx –disco-show’.

For example:

# /usr/lib/centreon/plugins/centreon_linux_snmp.pl --mode=list-interfaces --hostname=192.168.220.129 --snmp-version=2 --snmp-community=public --disco-show<?xml version="1.0" encoding="utf-8"?><data>

<label status="1" name="lo" total="10" interfaceid="1"/><label status="1" name="eth0" total="1000" interfaceid="2"/>

</data>

In the previous example, the name attribute corresponds to the network interface. The status describes the IFOP-ERSTATUS, total describes the IFSPEED of the interface and interfaceid describes the IFINDEX.

32CENTREON 46-52 RUE ALBERT FR75014 PARIS

Chapter 5. Configuration guide

Page 37: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

The discovery plugin should also list (XML output) the available XML attributes using an option. The The CentreonPlugins use ‘–mode=xxx –disco-format’.

For example:

# /usr/lib/centreon/plugins/centreon_linux_snmp.pl --mode=list-interfaces --hostname=127.0.0.1 --disco-format<?xml version="1.0" encoding="utf-8"?><data>

<element>name</element><element>total</element><element>status</element><element>interfaceid</element>

</data>

Here, four attributes are available: name, total, status and interfaceid.

5.4 Manually test a rule

You can run manually discovery using following options:

• --filter-rule=<rule_name>: Run selected rule

• --filter-host=<host_name>: Run all rules linked to hosttemplates used by host

• --filter-poller=<poller_name>: Run rules for ressources linked to the poller

• --dry-run: Run tests without configuration change

Note: You can combine --filter-*=<value> options. --dry-run option is an independant option.

5.4.1 Examples

Run all rules:

# /usr/share/centreon/www//modules/centreon-autodiscovery-server/cron/centreon_autodisco

Test all rules:

# /usr/share/centreon/www//modules/centreon-autodiscovery-server/cron/centreon_autodisco --dry-run

Test specific rule:

# /usr/share/centreon/www//modules/centreon-autodiscovery-server/cron/centreon_autodisco --filter-rule="OS-Linux-SNMP-Network-Interfaces-Discovery" --dry-run

Test all rules linked to hosttemplates used by specific host:

# /usr/share/centreon/www//modules/centreon-autodiscovery-server/cron/centreon_autodisco --filter-host="centreon-server" --dry-run

Test specific rule on predifined host:

# /usr/share/centreon/www//modules/centreon-autodiscovery-server/cron/centreon_autodisco --filter-rule="OS-Linux-SNMP-Network-Interfaces-Discovery" --filter-host="centreon-server" --dry-run

5.4. Manually test a ruleCENTREON 46-52 RUE ALBERT FR75014 PARIS

33

Page 38: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

34CENTREON 46-52 RUE ALBERT FR75014 PARIS

Chapter 5. Configuration guide

Page 39: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

CHAPTER 6

Administration

6.1 Update

6.1.1 Centreon Enterprise Server

Central server

To update the module, run the following command:

$ yum update centreon-auto-discovery-server

If an update is available, you will be asked for a confirmation. Just answer yes to the question.

6.1.2 Module update via Centreon’s web interface

Connect to the Centreon’s web interface using an account allowed to administer products and go to the Administration> Extensions > Manager menu.

Click on the update icon corresponding to the Centreon Auto Discovery module:

The module is now updated:

35

Page 40: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

6.2 Uninstallation

Connect to the Centreon’s web interface using an account allowed to administer products and go to the Administration> Extensions > Manager menu.

Click on the delete icon corresponding to the Centreon Auto Discovery module:

A confirmation popup will appear, confirm the action:

36CENTREON 46-52 RUE ALBERT FR75014 PARIS

Chapter 6. Administration

Page 41: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

The module is now uninstalled:

Warning: Uninstalling the module will also remove all the associated data. Data won’t be restorable unless adatabase backup has been made.

6.3 Module’s architecture

The Centreon Auto Discovery module contains 3 parts:

• The web UI: rules creation, administration and exploitation of the module

• Discovery plugins

• Scheduled job (cron) which executes discovery rules

The discovery plugins look for new elements to monitor, see Discovery plugins for more detail.

6.3. Module’s architectureCENTREON 46-52 RUE ALBERT FR75014 PARIS

37

Page 42: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

The rules, managed through the web UI, are saved into Centreon‘s database and are executed periodically (every nightat 10:30 PM) by the cron jon. See Discovery job pour more detail.

The following figure describes the general functioning of this module:

Figure 6.1: Functioning schema

6.4 Scheduled job

All the active discovery rules are periodically executed through a scheduled job managed by the cron daemon. Theexecution’s description is available into the /etc/cron.d/centreon-auto-disco file:

###################################### Centreon Auto Discovery#

30 22 * * * centreon /usr/share/centreon/www/modules/centreon-autodiscovery-server//cron/centreon_autodisco --config=’/etc/centreon/conf.pm’ --config-extra=’/etc/centreon/centreon_autodisco.pm’ --severity=error >> /var/log/centreon/centreon_auto_discovery.log 2>&1

The default configuration runs the discovery every day at 10:30 PM.

Information and errors relative to the execution will be saved into the /var/log/centreon/centreon_auto_discovery.logfile.

6.5 Configuring the discovery engine

Here is an example of a complete possible configuration of the /etc/centreon/centreon_autodisco.pm file:

%centreon_autodisco_config = (internal_com_type => ’ipc’,internal_com_path => ’/tmp/centreonautodisco/routing.ipc’,# Execute rules in parallel (0) or sequential (1)sequential => 1,timeout_wait => 60,# Use to connect to a Centreon pollerssh_password => ’’,

38CENTREON 46-52 RUE ALBERT FR75014 PARIS

Chapter 6. Administration

Page 43: Centreon Auto Discovery Documentation · 2020-03-16 · CHAPTER 1 Introduction Centreon Auto Discovery is an add-on to the Enterprise Plugin Pack functionality. The Auto Discovery

ssh_extra_options => {user => ’centreon’,stricthostkeycheck => 0,sshdir => ’/var/www/.ssh/’,knownhosts => ’/dev/null’,timeout => 60,

},ssh_exec_options => {

timeout => 60,timeout_no_data => 120,parallel => 8, #Max.: 8

},# Centreon CLAPI parametersclapi_cmd => ’/usr/bin/centreon’,clapi_user => ’admin’,clapi_password => ’centreon’,clapi_reload => ’POLLERRELOAD’,# Parameters to send email report if enable in rulemail_subject => ’Centreon Auto Discovery’,mail_from => ’centreon-autodisco’,mail_command => ’/bin/mail’,

);

1;

6.6 Distributed architecture

When a host is monitored by a remote collector, the discovery will be made from it. Thus to executed distant commandsit is necessary to allow the Apache process to access the centreon SSH keys user. To do this run the followingcommands:

# mkdir /var/www/.ssh/# cp /var/spool/centreon/.ssh/* /var/www/.ssh/# chown -R apache. /var/www/.ssh# chmod 600 /var/www/.ssh/id_rsa

6.6. Distributed architectureCENTREON 46-52 RUE ALBERT FR75014 PARIS

39