Details
| ID | Centreon |
|---|---|
| Provider | Centreon |
| Category | Case Management |
| From Version | 5.0.0 |
| Docker Image | demisto/python3:3.12.13.10116658 |
| Supported Modules | Agentix XSIAM |
README
Overview
Use Centreon to check the status of hosts and services.
This integration was integrated and tested with Centreon v2.8.20.
NOTE: Cortex XSOAR only works for Centreon v2.8.14 and later.
Use Cases
- Check the status of hosts.
- Check the status of services.
Configure Centreon on Cortex XSOAR
- Navigate to Settings > Integrations > Servers & Services.
- Search for Centreon.
- Click Add instance to create and configure a new integration instance.
- Name: a textual name for the integration instance
- Server URL (http://147.75.33.100:20016/)
- Username
- Do not validate server certificate (not secure)
- Click Test to validate the URLs and connection.
Commands
You can execute these commands from the Cortex XSOAR CLI, as part of an automation, or in a playbook. After you successfully execute a command, a DBot message appears in the War Room with the command details.
Get host status: centreon-get-host-status
Command Example
!centreon-get-host-status viewType=all fields=id,name limit=10
Inputs
| Parameter | Description |
| viewType |
Predefined filter (like in the monitoring view).
|
| fields |
List of fields that you want to get. Fields are separated from each other with a comma. For example: fields=id,name,alias,address. |
| status |
Status of the host you want to get.
|
| hostgroup |
Hostgroup ID filter. For example: hostgroup=2. |
| instance |
Instance ID filter. For example: instance=2. |
| search |
Search pattern applied on host name. For example: search="localhost". |
| criticality | A specific criticality. |
| sortType |
Sorting method.
|
| limit | Number of lines that you want. |
| number | Page number. |
Context Output
| Path | Description |
| Centreon.Host.Output | Host output |
| Centreon.Host.Name | Host name |
| Centreon.Host.State | Host state |
| Centreon.Host.Address | Host address |
| Centreon.Host.Id | Host ID |
Raw Output
{
"Host":[
{
"Acknowledged":"0",
"Address":"127.0.0.1",
"Alias":"Localhost",
"CheckAttempt":"1",
"Criticality":"",
"Id":"17",
"InstanceName":"Central",
"LastCheck":"1524487617",
"LastHardStateChange":"",
"LastStateChange":"",
"MaxCheckAttempts":"3",
"Name":"Localhost",
"Output":"OK - 127.0.0.1: rta 0.076ms, lost 0%",
"State":"0",
"StateType":"1"
},
{
"Acknowledged":"0",
"Address":"192.168.1.22",
"Alias":"jumphost",
"CheckAttempt":"1",
"Criticality":"",
"Id":"37",
"InstanceName":"Central",
"LastCheck":"1524487822",
"LastHardStateChange":"1523986444",
"LastStateChange":"1523986444",
"MaxCheckAttempts":"3",
"Name":"jumphost",
"Output":"OK - 192.168.1.22: rta 0.379ms, lost 0%",
"State":"0",
"StateType":"1"
},
{
"Acknowledged":"0",
"Address":"192.168.1.22",
"Alias":"jumphost",
"CheckAttempt":"1",
"Criticality":"",
"Id":"38",
"InstanceName":"Central",
"LastCheck":"1524487722",
"LastHardStateChange":"1523987517",
"LastStateChange":"1523987517",
"MaxCheckAttempts":"3",
"Name":"jumphost_1",
"Output":"OK - 192.168.1.22: rta 0.389ms, lost 0%",
"State":"0",
"StateType":"1"
}
]
}
Get service status: centreon-get-service-status
Command Example
!centreon-get-service-status status=ok fields=id,host_id limit=5 sortType=asc
Inputs
| Parameter | Description |
| viewType |
Predefined filter (like in the monitoring view).
|
| fields |
The list of fields that you want to get, each field separated by a comma. For example: fields=id,name,alias,address. |
| status |
Status of the host you want to get.
|
| hostgroup |
Hostgroup ID filter. For example: hostgroup=2. |
| servicegroup | Servicegroup ID filter. |
| instance |
Instance ID filter. For example: instance=2. |
| search | Search pattern applied on service. |
| searchHost | Search pattern applied on host. |
| searchOutput | Search pattern applied on output. |
| criticality | A specific criticality. |
| sortType |
Sorting method.
|
| limit | Number of lines that you want. |
| number | Page number. |
Context Output
| Path | Description |
| Centreon.Service.Output | Service output |
| Centreon.Service.Name | Service name |
| Centreon.Service.State | Service state |
| Centreon.Service.Description | Service description |
| Centreon.Service.Id | Service ID |
Raw Output
{
"Service": [
{
"Acknowledged": "0",
"CheckAttempt": "1",
"Criticality": "",
"Description": "Ping",
"HostId": "37",
"LastCheck": "1524487467",
"LastHardStateChange": "1523986444",
"LastStateChange": "1523986444",
"MaxCheckAttempts": "3",
"Name": "jumphost",
"Output": "OK - 192.168.1.22: rta 0.185ms, lost 0%",
"Perfdata": "rta=0.185ms;200.000;400.000;0; pl=0%;20;50;; rtmax=0.398ms;;;; rtmin=0.106ms;;;;",
"ServiceId": "132",
"State": "0",
"StateType": "1"
},
{
"Acknowledged": "0",
"CheckAttempt": "1",
"Criticality": "",
"Description": "Ping",
"HostId": "38",
"LastCheck": "1524487617",
"LastHardStateChange": "1523987517",
"LastStateChange": "1523987517",
"MaxCheckAttempts": "3",
"Name": "jumphost_1",
"Output": "OK - 192.168.1.22: rta 0.235ms, lost 0%",
"Perfdata": "rta=0.235ms;200.000;400.000;0; pl=0%;20;50;; rtmax=0.514ms;;;; rtmin=0.134ms;;;;",
"ServiceId": "133",
"State": "0",
"StateType": "1"
}
]
}
Configuration parameters
server— Server URL (e.g. http://147.75.33.100:20016/) (required)credentials— Username (required)insecure— Trust any certificate (not secure)proxy— Use system proxy settings
Commands (2)
-
centreon-get-host-statusAll the monitoring information regarding hosts.
-
centreon-get-service-statusAll the monitoring information regarding services.
import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 """ IMPORTS """ import urllib3 # disable insecure warnings urllib3.disable_warnings() """ GLOBAL VARS """ SERVER_NAME = demisto.params()["server"] USERNAME = demisto.params()["credentials"]["identifier"] PASSWORD = demisto.params()["credentials"]["password"] BASE_URL = SERVER_NAME + "centreon/api/index.php?" USE_SSL = not demisto.params().get("insecure") DEFAULT_HEADERS = {"Content-Type": "application/json"} """ HELPER FUNCTIONS """ def httpRequest(method, urlSuffix, data, headers): # pragma: no cover data = {} if data is None else data url = BASE_URL + urlSuffix LOG(f"running {method} request with url={url}\theaders={headers}") try: res = requests.request(method, url, verify=USE_SSL, params=data, headers=headers) res.raise_for_status() return res.json() except Exception as e: LOG(e) raise e def httpPost(urlSuffix, data=None, files=None): # pragma: no cover data = {} if data is None else data url = BASE_URL + urlSuffix LOG(f"running request with url={url}\tdata={data}\tfiles={files}") try: res = requests.post(url, data=data, verify=USE_SSL) res.raise_for_status() return res.json() except Exception as e: LOG(e) raise e def login(): # retrieves an authentication token from Centreon cmd_url = "action=authenticate" data = {"username": USERNAME, "password": PASSWORD} result = httpPost(cmd_url, data=data) return result["authToken"] def transform_host_vals(key, value): # "down" and "unreachable" states can be added here after their value would be known host_service_status = {"0": "Up", "4": "Pending"} if key == "State" and value in host_service_status: return host_service_status[value] return value def to_upper_camel_case(word): return "".join(x.capitalize() or "_" for x in word.split("_")) """ COMMANDS FUNCTIONS """ def get_host_status(): """Returns the status of the connected hosts.""" args = demisto.args() token = login() DEFAULT_HEADERS["centreon-auth-token"] = token cmd_url = "object=centreon_realtime_hosts&action=list" return httpRequest("GET", cmd_url, args, DEFAULT_HEADERS) def get_host_status_command(): """corresponds to 'centreon-get-host-status' command. Brings the status of the connected hosts.""" response = get_host_status() if len(response) == 0: return "No Hosts found" # changing the keys from underscore notation to UpperCamelCase notation camel_case_response = [{to_upper_camel_case(k): v for k, v in dic.items()} for dic in response] # for the human readable - only including keys which has values. Also, transforming values from ints to readable text list_for_md = [{k: transform_host_vals(k, v) for k, v in dic.items() if v == 0 or v} for dic in camel_case_response] entry = { "Type": entryTypes["note"], "Contents": camel_case_response, "ContentsFormat": formats["json"], "ReadableContentsFormat": formats["markdown"], "HumanReadable": tableToMarkdown("Centreon Hosts status", list_for_md), "EntryContext": {"Centreon.Host(val.Id==obj.Id)": camel_case_response}, } return entry def get_service_status(): """Returns the status of the connected services.""" args = demisto.args() token = login() DEFAULT_HEADERS["centreon-auth-token"] = token cmd_url = "object=centreon_realtime_services&action=list" return httpRequest("GET", cmd_url, args, DEFAULT_HEADERS) def get_service_status_command(): """corresponds to 'centreon-get-service-status' command. Brings the status of the connected services.""" response = get_service_status() if len(response) == 0: return "No Services found" # changing the keys from underscore notation to UpperCamelCase notation camel_case_response = [{to_upper_camel_case(k): v for k, v in dic.items()} for dic in response] # for the human readable - only including keys which has values. Also, transforming values from ints to readable text list_for_md = [{k: transform_host_vals(k, v) for k, v in dic.items() if v == 0 or v} for dic in camel_case_response] entry = { "Type": entryTypes["note"], "Contents": camel_case_response, "ContentsFormat": formats["json"], "ReadableContentsFormat": formats["markdown"], "HumanReadable": tableToMarkdown("Centreon Services status", list_for_md), "EntryContext": {"Centreon.Service(val.ServiceId==obj.ServiceId)": camel_case_response}, } return entry """ EXECUTION CODE """ LOG(f"command is {demisto.command()}") try: handle_proxy() if demisto.command() == "test-module": # This is the call made when pressing the integration test button. if get_host_status(): demisto.results("ok") else: demisto.results("test failed") elif demisto.command() == "centreon-get-host-status": demisto.results(get_host_status_command()) elif demisto.command() == "centreon-get-service-status": demisto.results(get_service_status_command()) except Exception as e: LOG(str(e)) LOG.print_log() raise