Centreon Gorgone RestAPI

Documentation Powered by ReDoc

# Centreon Gorgone RestAPI (1.0)

URL: https://www.centreon.com License: Apache 2.0
You can contact us on our community Slack

# Information

Centreon Gorgone and his "gorgoned" daemon is a lightweight, distributed, modular tasks handler.

It provides a set of actions like:

- Execute commands
- Send files/directories,
- Schedule cron-like tasks,
- Push or execute tasks through SSH.

The daemon can be installed on Centreon environments like Centreon Central, Remote and Poller servers.

It uses ZeroMQ library.

# Authentication

## Basic Authentication

Security Scheme Type | HTTP
HTTP Authorization Scheme | basic

# Internal

Internal events.

## Get nodes connection status

Get the connection status of all nodes managed by the Gorgone daemon.

##### Authorizations:

Basic Authentication

### Responses

200

OK

401

Unauthorized

403

Forbidden

get/internal/constatus

Local Gorgone instance

{protocol}://{server}:{port}/api/internal/constatus

Remote Gorgone instance

{protocol}://{server}:{port}/api/nodes/{id}/internal/constatus

### Response samples

- 200
- 401
- 403

Content type
application/json
Copy
Expand all Collapse all
`
{

- "action": "constatus",
- "message": "ok",
- "data":
  {
  - "id":
    {
    - "last_ping_sent": 1577726040,
    - "type": "push_zmq",
    - "nodes": { },
    - "last_ping_recv": 1577726040
    }
  }

}`

## Get runtime informations and statistics

Get informations and statistics about loaded modules, available endpoints and number of events computed at runtime.

##### Authorizations:

Basic Authentication

### Responses

200

OK

401

Unauthorized

403

Forbidden

get/internal/information

Local Gorgone instance

{protocol}://{server}:{port}/api/internal/information

Remote Gorgone instance

{protocol}://{server}:{port}/api/nodes/{id}/internal/information

### Response samples

- 200
- 401
- 403

Content type
application/json
Copy
Expand all Collapse all
`
{

- "action": "information",
- "message": "ok",
- "data":
  {
  - "modules":
    {
    - "httpserver": "gorgone::modules::core::httpserver::hooks",
    - "dbcleaner": "gorgone::modules::core::dbcleaner::hooks",
    - "cron": "gorgone::modules::core::cron::hooks",
    - "engine": "gorgone::modules::centreon::engine::hooks",
    - "action": "gorgone::modules::core::action::hooks",
    - "statistics": "gorgone::modules::centreon::statistics::hooks",
    - "nodes": "gorgone::modules::centreon::nodes::hooks",
    - "legacycmd": "gorgone::modules::centreon::legacycmd::hooks",
    - "proxy": "gorgone::modules::core::proxy::hooks"
    },
  - "api_endpoints":
    {
    - "POST_/internal/logger": "BCASTLOGGER",
    - "GET_/centreon/statistics/broker": "BROKERSTATS",
    - "GET_/internal/thumbprint": "GETTHUMBPRINT",
    - "GET_/core/cron/definitions": "GETCRON",
    - "GET_/internal/information": "INFORMATION",
    - "POST_/core/cron/definitions": "ADDCRON",
    - "POST_/core/action/command": "COMMAND",
    - "POST_/core/proxy/remotecopy": "REMOTECOPY",
    - "POST_/centreon/engine/command": "ENGINECOMMAND",
    - "PATCH_/core/cron/definitions": "UPDATECRON",
    - "DELETE_/core/cron/definitions": "DELETECRON",
    - "GET_/internal/constatus": "CONSTATUS"
    },
  - "counters":
    {
    - "total": 40210,
    - "external":
      {
      - "total": 0
      },
    - "internal":
      {
      - "legacycmdready": 1,
      - "setlogs": 7841,
      - "enginecommand": 20,
      - "registernodes": 443,
      - "pong": 3397,
      - "proxyready": 5,
      - "statisticsready": 1,
      - "addcron": 1,
      - "cronready": 1,
      - "getthumbprint": 2,
      - "centreonnodesready": 1,
      - "httpserverready": 1,
      - "command": 4446,
      - "putlog": 9809,
      - "dbcleanerready": 1,
      - "information": 6,
      - "brokerstats": 4446,
      - "constatus": 1,
      - "total": 40210,
      - "setcoreid": 443,
      - "getlog": 8893,
      - "engineready": 1,
      - "unregisternodes": 443,
      - "actionready": 1
      },
    - "proxy":
      {
      - "enginecommand": 10,
      - "getlog": 4446,
      - "total": 8902,
      - "command": 4446
      }
    }
  }

}`

## Get public key thumbprint

Get the thumbprint of the public key of the Gorgone daemon.

##### Authorizations:

Basic Authentication

### Responses

200

OK

401

Unauthorized

403

Forbidden

get/internal/thumbprint

Local Gorgone instance

{protocol}://{server}:{port}/api/internal/thumbprint

Remote Gorgone instance

{protocol}://{server}:{port}/api/nodes/{id}/internal/thumbprint

### Response samples

- 200
- 401
- 403

Content type
application/json
Copy
Expand all Collapse all
`
{

- "action": "getthumbprint",
- "message": "ok",
- "data":
  {
  - "thumbprint": "cS4B3lZq96qcP4FTMhVMuwAhztqRBQERKyhnEitnTFM"
  }

}`

## Set logger severity level

Set the logger severity level for all modules.

##### Authorizations:

Basic Authentication

##### Request Body schema: application/json

severity | string Enum: "info" "error" "debug" Severity level to be defined for all loaded modules

### Responses

204

OK

401

Unauthorized

403

Forbidden

post/internal/logger

Local Gorgone instance

{protocol}://{server}:{port}/api/internal/logger

Remote Gorgone instance

{protocol}://{server}:{port}/api/nodes/{id}/internal/logger

### Request samples

- Payload

Content type
application/json
Copy
Expand all Collapse all
`
{

- "severity": "info"

}`

### Response samples

- 401
- 403

Content type
application/json
Copy
Expand all Collapse all
`
{

- "error": "http_error_401",
- "message": "unauthorized"

}`

# Logs

Logs management.

## Retrieve event's logs

Retrieve the event's logs based on event's token.

##### Authorizations:

Basic Authentication

##### path Parameters

token required | string Example: 1d48a26a0fc37c1d8658222378044007d9c12311ba49b214de633739be05353415eee946f41b43babb6cb2a083a45c0d6359f361874af39a45b07542de8e2165 Token of the event

##### query Parameters

code | integer Enum: 0 1 2 Example: code=2 Only retrieve logs with defined code
limit | integer >= 1 Example: limit=1 Only retrieve the last x logs
ctime | integer <int64> Example: ctime=1577726040 Only retrieve logs with a creation time equal or superior to a timestamp
etime | integer <int64> Example: etime=1577726040 Only retrieve logs of an event time superior to a timestamp

### Responses

200

OK

401

Unauthorized

403

Forbidden

get/log/{token}

Local Gorgone instance

{protocol}://{server}:{port}/api/log/{token}

Remote Gorgone instance

{protocol}://{server}:{port}/api/nodes/{id}/log/{token}

### Response samples

- 200
- 401
- 403

Content type
application/json
Example
Logs
Copy
Expand all Collapse all
`
{

- "message": "Logs found",
- "token": "03008486ba50b52e529ff5828d1432e5578dd18bb530c145b133dc902c8cfa6b8aac4d58fffb0c5ed44b943d2acbfb7cd1b18c55fcebce62e51999db460112c7",
- "data":
  [
  - {
    - "ctime": 1577727699,
    - "etime": 1577727699,
    - "id": 101483,
    - "instant": 0,
    - "data": { },
    - "token": "03008486ba50b52e529ff5828d1432e5578dd18bb530c145b133dc902c8cfa6b8aac4d58fffb0c5ed44b943d2acbfb7cd1b18c55fcebce62e51999db460112c7",
    - "code": 2
    }
  ]

}`

# Cron

Module aiming to reproduce a cron-like scheduler that can send events to other Gorgone modules.

## List definitions

List all cron definitions.

##### Authorizations:

Basic Authentication

### Responses

200

OK

401

Unauthorized

403

Forbidden

get/core/cron/definitions

Local Gorgone instance

{protocol}://{server}:{port}/api/core/cron/definitions

Remote Gorgone instance

{protocol}://{server}:{port}/api/nodes/{id}/core/cron/definitions

### Response samples

- 200
- 401
- 403

Content type
application/json
Example
Token
Copy
Expand all Collapse all
`
{

- "token": "1d48a26a0fc37c1d8658222378044007d9c12311ba49b214de633739be05353415eee946f41b43babb6cb2a083a45c0d6359f361874af39a45b07542de8e2165"

}`

## Add definitions

Add one or multiple cron definitions to runtime.

##### Authorizations:

Basic Authentication

##### Request Body schema: application/json

Array

timespec required | string Cron-like time specification
id required | string Unique identifier of the cron definition
action required | string Action/event to call at job execution
parameters required | object Parameters needed by the called action/event
keep_token | boolean Boolean to define whether or not the ID of the definition will be used as token for the command

### Responses

200

OK

401

Unauthorized

403

Forbidden

post/core/cron/definitions

Local Gorgone instance

{protocol}://{server}:{port}/api/core/cron/definitions

Remote Gorgone instance

{protocol}://{server}:{port}/api/nodes/{id}/core/cron/definitions

### Request samples

- Payload

Content type
application/json
Copy
Expand all Collapse all
`
[

- {
  - "timespec": "string",
  - "id": "string",
  - "action": "string",
  - "parameters": { },
  - "keep_token": true
  }

]`

### Response samples

- 200
- 401
- 403

Content type
application/json
Example
Token
Copy
Expand all Collapse all
`
{

- "token": "1d48a26a0fc37c1d8658222378044007d9c12311ba49b214de633739be05353415eee946f41b43babb6cb2a083a45c0d6359f361874af39a45b07542de8e2165"

}`

## Get a definition

List cron definition identified by id.

##### Authorizations:

Basic Authentication

##### path Parameters

definition_id required | string Example: broker_stats ID of the definition

### Responses

200

OK

401

Unauthorized

403

Forbidden

get/core/cron/definitions/{definition_id}

Local Gorgone instance

{protocol}://{server}:{port}/api/core/cron/definitions/{definition_id}

Remote Gorgone instance

{protocol}://{server}:{port}/api/nodes/{id}/core/cron/definitions/{definition_id}

### Response samples

- 200
- 401
- 403

Content type
application/json
Example
Token
Copy
Expand all Collapse all
`
{

- "token": "1d48a26a0fc37c1d8658222378044007d9c12311ba49b214de633739be05353415eee946f41b43babb6cb2a083a45c0d6359f361874af39a45b07542de8e2165"

}`

## Update a definition

Update a cron definition.

##### Authorizations:

Basic Authentication

##### path Parameters

definition_id required | string Example: broker_stats ID of the definition

##### Request Body schema: application/json

timespec required | string Cron-like time specification
id required | string Unique identifier of the cron definition
action required | string Action/event to call at job execution
parameters required | object Parameters needed by the called action/event
keep_token | boolean Boolean to define whether or not the ID of the definition will be used as token for the command

### Responses

200

OK

401

Unauthorized

403

Forbidden

patch/core/cron/definitions/{definition_id}

Local Gorgone instance

{protocol}://{server}:{port}/api/core/cron/definitions/{definition_id}

Remote Gorgone instance

{protocol}://{server}:{port}/api/nodes/{id}/core/cron/definitions/{definition_id}

### Request samples

- Payload

Content type
application/json
Copy
Expand all Collapse all
`
{

- "timespec": "string",
- "id": "string",
- "action": "string",
- "parameters": { },
- "keep_token": true

}`

### Response samples

- 200
- 401
- 403

Content type
application/json
Example
Token
Copy
Expand all Collapse all
`
{

- "token": "1d48a26a0fc37c1d8658222378044007d9c12311ba49b214de633739be05353415eee946f41b43babb6cb2a083a45c0d6359f361874af39a45b07542de8e2165"

}`

## Delete a definition

Delete a cron definition.

##### Authorizations:

Basic Authentication

##### path Parameters

definition_id required | string Example: broker_stats ID of the definition

### Responses

200

OK

401

Unauthorized

403

Forbidden

delete/core/cron/definitions/{definition_id}

Local Gorgone instance

{protocol}://{server}:{port}/api/core/cron/definitions/{definition_id}

Remote Gorgone instance

{protocol}://{server}:{port}/api/nodes/{id}/core/cron/definitions/{definition_id}

### Response samples

- 200
- 401
- 403

Content type
application/json
Example
Token
Copy
Expand all Collapse all
`
{

- "token": "1d48a26a0fc37c1d8658222378044007d9c12311ba49b214de633739be05353415eee946f41b43babb6cb2a083a45c0d6359f361874af39a45b07542de8e2165"

}`

## Get a definition status

Get a definition execution status.

##### Authorizations:

Basic Authentication

##### path Parameters

definition_id required | string Example: broker_stats ID of the definition

### Responses

200

OK

401

Unauthorized

403

Forbidden

get/core/cron/definitions/{definition_id}/status

Local Gorgone instance

{protocol}://{server}:{port}/api/core/cron/definitions/{definition_id}/status

Remote Gorgone instance

{protocol}://{server}:{port}/api/nodes/{id}/core/cron/definitions/{definition_id}/status

### Response samples

- 200
- 401
- 403

Content type
application/json
Example
Token
Copy
Expand all Collapse all
`
{

- "token": "1d48a26a0fc37c1d8658222378044007d9c12311ba49b214de633739be05353415eee946f41b43babb6cb2a083a45c0d6359f361874af39a45b07542de8e2165"

}`

# Action

Module aiming to execute actions on the server running the Gorgone daemon or remotly using SSH.

## Execute one or several command lines

Execute a command or a set of commands on server running Gorgone.

##### Authorizations:

Basic Authentication

##### Request Body schema: application/json

Array

command required | string Command to execute
timeout | integer Default: 30 Time in seconds before a command is considered timed out
continue_on_error | boolean Default: false Behaviour in case of execution issue

### Responses

200

OK

401

Unauthorized

403

Forbidden

post/core/action/command

Local Gorgone instance

{protocol}://{server}:{port}/api/core/action/command

Remote Gorgone instance

{protocol}://{server}:{port}/api/nodes/{id}/core/action/command

### Request samples

- Payload

Content type
application/json
Copy
Expand all Collapse all
`
[

- {
  - "command": "echo data > /tmp/date.log",
  - "timeout": 5,
  - "continue_on_error": true
  }

]`

### Response samples

- 200
- 401
- 403

Content type
application/json
Example
Token
Copy
Expand all Collapse all
`
{

- "token": "1d48a26a0fc37c1d8658222378044007d9c12311ba49b214de633739be05353415eee946f41b43babb6cb2a083a45c0d6359f361874af39a45b07542de8e2165"

}`

# Engine

Module aiming to provide a bridge to communicate with Centreon Engine daemon.

## Send one or several external commands

Send an external command or a set of external commands to a running Centreon Engine instance using command file pipe. This method needs the commands to be preformatted as Nagios external commands format.

##### Authorizations:

Basic Authentication

##### Request Body schema: application/json

command_file | string Path to the Centreon Engine command file pipe
command | Array of strings

### Responses

200

OK

401

Unauthorized

403

Forbidden

post/centreon/engine/command

Local Gorgone instance

{protocol}://{server}:{port}/api/centreon/engine/command

Remote Gorgone instance

{protocol}://{server}:{port}/api/nodes/{id}/centreon/engine/command

### Request samples

- Payload

Content type
application/json
Copy
Expand all Collapse all
`
{

- "command_file": "/var/lib/centreon-engine/rw/centengine.cmd",
- "command":
  [
  - "[653284380] SCHEDULE_SVC_CHECK;host1;service1;653284380"
  ]

}`

### Response samples

- 200
- 401
- 403

Content type
application/json
Example
Token
Copy
Expand all Collapse all
`
{

- "token": "1d48a26a0fc37c1d8658222378044007d9c12311ba49b214de633739be05353415eee946f41b43babb6cb2a083a45c0d6359f361874af39a45b07542de8e2165"

}`

# Statistics

Module aiming to deal with statistics collection of Centreon Engine and Broker.

## Launch Broker statistics collection

Launch Broker statistics collection and store the result on disk.

##### Authorizations:

Basic Authentication

### Responses

200

OK

401

Unauthorized

403

Forbidden

get/centreon/statistics/broker

Local Gorgone instance

{protocol}://{server}:{port}/api/centreon/statistics/broker

Remote Gorgone instance

{protocol}://{server}:{port}/api/nodes/{id}/centreon/statistics/broker

### Response samples

- 200
- 401
- 403

Content type
application/json
Example
Token
Copy
Expand all Collapse all
`
{

- "token": "1d48a26a0fc37c1d8658222378044007d9c12311ba49b214de633739be05353415eee946f41b43babb6cb2a083a45c0d6359f361874af39a45b07542de8e2165"

}`

## Launch Broker statistics collection of a specific monitoring server

Launch Broker statistics collection and store the result on disk.

##### Authorizations:

Basic Authentication

##### path Parameters

monitoring_server_id required | integer Example: 2 ID of the monitoring server

### Responses

200

OK

401

Unauthorized

403

Forbidden

get/centreon/statistics/broker/{monitoring_server_id}

Local Gorgone instance

{protocol}://{server}:{port}/api/centreon/statistics/broker/{monitoring_server_id}

Remote Gorgone instance

{protocol}://{server}:{port}/api/nodes/{id}/centreon/statistics/broker/{monitoring_server_id}

### Response samples

- 200
- 401
- 403

Content type
application/json
Example
Token
Copy
Expand all Collapse all
`
{

- "token": "1d48a26a0fc37c1d8658222378044007d9c12311ba49b214de633739be05353415eee946f41b43babb6cb2a083a45c0d6359f361874af39a45b07542de8e2165"

}`

# Autodiscovery

Module aiming to extend Centreon Autodiscovery server functionalities.

## Add a host discovery job

Add one Centreon Autodiscovery job to discover hosts.

##### Authorizations:

Basic Authentication

##### Request Body schema: application/json

job_id required | integer ID of the Host Discovery job
target required | integer Identifier of the target on which to execute the command
command_line required | string Command line to execute to perform the discovery
timeout | integer Time in seconds before the command is considered timed out
execution required | object Execution mode of this job ('0': execute immediately, '1': schedule with cron)
post_execution | object Post-execution settings

### Responses

200

OK

401

Unauthorized

403

Forbidden

post/centreon/autodiscovery/hosts

Local Gorgone instance

{protocol}://{server}:{port}/api/centreon/autodiscovery/hosts

Remote Gorgone instance

{protocol}://{server}:{port}/api/nodes/{id}/centreon/autodiscovery/hosts

### Request samples

- Payload

Content type
application/json
Copy
Expand all Collapse all
`
{

- "job_id": 14,
- "target": 2,
- "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":
    {
    - "cron_definition": "*/10 * * * *"
    }
  },
- "post_execution":
  {
  - "commands":
    [
    - {
      - "action": "COMMAND",
      - "command_line": "/usr/share/centreon/bin/run_save_discovered_host --job-id=14"
      }
    ]
  }

}`

### Response samples

- 200
- 401
- 403

Content type
application/json
Example
Token
Copy
Expand all Collapse all
`
{

- "token": "1d48a26a0fc37c1d8658222378044007d9c12311ba49b214de633739be05353415eee946f41b43babb6cb2a083a45c0d6359f361874af39a45b07542de8e2165"

}`

## Launch a host discovery job

Launch a host discovery job identified by id (even if in cron mode).

##### Authorizations:

Basic Authentication

##### path Parameters

job_id required | integer Example: 2 ID of the job

### Responses

200

OK

401

Unauthorized

403

Forbidden

get/centreon/autodiscovery/hosts/{job_id}/schedule

Local Gorgone instance

{protocol}://{server}:{port}/api/centreon/autodiscovery/hosts/{job_id}/schedule

Remote Gorgone instance

{protocol}://{server}:{port}/api/nodes/{id}/centreon/autodiscovery/hosts/{job_id}/schedule

### Response samples

- 200
- 401
- 403

Content type
application/json
Example
Token
Copy
Expand all Collapse all
`
{

- "token": "1d48a26a0fc37c1d8658222378044007d9c12311ba49b214de633739be05353415eee946f41b43babb6cb2a083a45c0d6359f361874af39a45b07542de8e2165"

}`

## Delete a host discovery job

Delete one Centreon Autodiscovery scheduled job.

##### Authorizations:

Basic Authentication

##### path Parameters

token required | string Example: discovery_14_6b7d1bb8 Token of the scheduled job

### Responses

200

OK

401

Unauthorized

403

Forbidden

delete/centreon/autodiscovery/hosts/{token}

Local Gorgone instance

{protocol}://{server}:{port}/api/centreon/autodiscovery/hosts/{token}

Remote Gorgone instance

{protocol}://{server}:{port}/api/nodes/{id}/centreon/autodiscovery/hosts/{token}

### Response samples

- 200
- 401
- 403

Content type
application/json
Example
Token
Copy
Expand all Collapse all
`
{

- "token": "1d48a26a0fc37c1d8658222378044007d9c12311ba49b214de633739be05353415eee946f41b43babb6cb2a083a45c0d6359f361874af39a45b07542de8e2165"

}`