This module aims to extend Centreon Autodiscovery server functionalities.
Directive
Description
Default value
global_timeout
Time in seconds before a discovery command is considered timed out
300
check_interval
Time in seconds defining frequency at which results will be search for
15
name : autodiscovery
package : " gorgone::modules::centreon::autodiscovery::hooks"
enable : true
global_timeout : 60
check_interval : 10
Event
Description
AUTODISCOVERYREADY
Internal event to notify the core
HOSTDISCOVERYLISTENER
Internal event to get host discovery results
SERVICEDISCOVERYLISTENER
Internal event to get service discovery results
ADDHOSTDISCOVERYJOB
Add a host discovery job
DELETEHOSTDISCOVERYJOB
Delete a host discovery job
LAUNCHHOSTDISCOVERY
Execute a host discovery job
LAUNCHSERVICEDISCOVERY
Execute a service discovery job
Endpoint
Method
/centreon/autodiscovery/hosts
POST
Headers
Header
Value
Accept
application/json
Content-Type
application/json
Key
Value
job_id
ID of the Host Discovery job
target
Identifier of the target on which to execute the command
command_line
Command line to execute to perform the discovery
timeout
Time in seconds before the command is considered timed out
execution
Execution settings
post_execution
Post-execution settings
With the following keys for the execution entry:
Key
Value
mode
Execution mode ('0': immediate, '1': scheduled)
parameters
Parameters needed by execution mode
With the following keys for the post_execution entry:
Key
Value
commands
Array of commands to be executed
{
"job_id" : " <id of the job>" ,
"target" : " <target id>" ,
"command_line" : " <command to execute>" ,
"timeout" : " <timeout in seconds>" ,
"execution" : {
"mode" : " <execution mode>" ,
"parameters" : " <execution parameters>" ,
},
"post_execution" : {
"commands" : " <array of commands>" ,
}
}
Execute immediately without post-execution commands
curl --request POST " https://hostname:8443/api/centreon/autodiscovery/hosts" \
--header " Accept: application/json" \
--header " Content-Type: application/json" \
--data " {
\" job_id\" : 14,
\" target\" : 3,
\" command_line\" : \" perl /usr/lib/centreon/plugins/centreon_generic_snmp.pl --plugin=os::linux::local::plugin --mode=discovery-snmp --subnet='10.1.2.3/24' --snmp-port='161' --snmp-version='2c' --snmp-community='public'\" ,
\" timeout\" : 300,
\" execution\" : {
\" mode\" : 0,
\" parameters\" : {}
},
\" post_execution\" : {}
}"
Execute immediately with post-execution commands
curl --request POST " https://hostname:8443/api/centreon/autodiscovery/hosts" \
--header " Accept: application/json" \
--header " Content-Type: application/json" \
--data " {
\" job_id\" : 14,
\" target\" : 3,
\" command_line\" : \" perl /usr/lib/centreon/plugins/centreon_generic_snmp.pl --plugin=os::linux::local::plugin --mode=discovery-snmp --subnet='10.1.2.3/24' --snmp-port='161' --snmp-version='2c' --snmp-community='public'\" ,
\" timeout\" : 300,
\" execution\" : {
\" mode\" : 0,
\" parameters\" : {}
},
\" post_execution\" : {
\" commands\" : [
{
\" action\" : \" COMMAND\" ,
\" command_line\" : \" /usr/share/centreon/www/modules/centreon-autodiscovery-server/script/run_save_discovered_host --job-id=14\"
}
]
}
}"
Schedule execution without post-execution commands
curl --request POST " https://hostname:8443/api/centreon/autodiscovery/hosts" \
--header " Accept: application/json" \
--header " Content-Type: application/json" \
--data " {
\" job_id\" : 14,
\" target\" : 3,
\" command_line\" : \" perl /usr/lib/centreon/plugins/centreon_generic_snmp.pl --plugin=os::linux::local::plugin --mode=discovery-snmp --subnet='10.1.2.3/24' --snmp-port='161' --snmp-version='2c' --snmp-community='public'\" ,
\" timeout\" : 300,
\" execution\" : {
\" mode\" : 1,
\" parameters\" : {
\" cron_definition\" : \" */10 * * * *\"
}
},
\" post_execution\" : {}
}"
Schedule execution with post-execution commands
curl --request POST " https://hostname:8443/api/centreon/autodiscovery/hosts" \
--header " Accept: application/json" \
--header " Content-Type: application/json" \
--data " {
\" job_id\" : 14,
\" target\" : 3,
\" command_line\" : \" perl /usr/lib/centreon/plugins/centreon_generic_snmp.pl --plugin=os::linux::local::plugin --mode=discovery-snmp --subnet='10.1.2.3/24' --snmp-port='161' --snmp-version='2c' --snmp-community='public'\" ,
\" timeout\" : 300,
\" execution\" : {
\" mode\" : 1,
\" parameters\" : {
\" cron_definition\" : \" */10 * * * *\"
}
},
\" post_execution\" : {
\" commands\" : [
{
\" action\" : \" COMMAND\" ,
\" command_line\" : \" /usr/share/centreon/www/modules/centreon-autodiscovery-server/script/run_save_discovered_host --job-id=14\"
}
]
}
}"
Launch a host discovery job
Endpoint
Method
/centreon/autodiscovery/hosts/:id/schedule
GET
Headers
Header
Value
Accept
application/json
Variable
Description
id
Identifier of the job
curl --request GET " https://hostname:8443/api/centreon/autodiscovery/hosts/:id/schedule" \
--header " Accept: application/json"
Delete a host discovery job
Endpoint
Method
/centreon/autodiscovery/hosts/:token
DELETE
Headers
Header
Value
Accept
application/json
Variable
Description
token
Token of the scheduled job
curl --request DELETE " https://hostname:8443/api/centreon/autodiscovery/hosts/discovery_14_6b7d1bb8" \
--header " Accept: application/json"
Execute a service discovery job
Endpoint
Method
/centreon/autodiscovery/services
POST
Headers
Header
Value
Accept
application/json
Content-Type
application/json
Key
Value
filter_rules
Array of rules to use for discovery (empty means all)
force_rule
Run disabled rules ('0': not forced, '1': forced)
filter_hosts
Array of hosts against which run the discovery (empty means all)
filter_pollers
Array of pollers for which linked hosts will be discovered against (empty means all)
manual
Run discovery for manual scan from web UI ('0': automatic, '1': manual)
dry_run
Run discovery without configuration change ('0': changes, '1': dry run)
no_generate_config
No configuration generation (even if there is some changes) ('0': generation, '1': no generation)
{
"filter_rules" : " <array of rules>" ,
"force_rule" : " <run disabled rules>" ,
"filter_hosts" : " <array of hosts>" ,
"filter_pollers" : " <array of pollers>" ,
"manual" : " <manual scan>" ,
"dry_run" : " <run without changes>" ,
"no_generate_config" : " <no configuration generation>"
}
Execute discovery with defined rules (even if disabled)
curl --request POST " https://hostname:8443/api/centreon/autodiscovery/services" \
--header " Accept: application/json" \
--header " Content-Type: application/json" \
--data " {
\" filter_rules\" : [
\" OS-Linux-SNMP-Disk-Name\" ,
\" OS-Linux-SNMP-Traffic-Name\"
],
\" force_rule\" : 1
}"
Execute discovery for defined hosts
curl --request POST " https://hostname:8443/api/centreon/autodiscovery/services" \
--header " Accept: application/json" \
--header " Content-Type: application/json" \
--data " {
\" filter_hosts\" : [
\" Host-1\" ,
\" Host-2\" ,
\" Host-3\"
]
}"
Execute discovery for defined poller (without changes)
curl --request POST " https://hostname:8443/api/centreon/autodiscovery/services" \
--header " Accept: application/json" \
--header " Content-Type: application/json" \
--data " {
\" filter_pollers\" : [
\" Poller-1\"
],
\" dry_run\" : 1
}"