This commit is contained in:
Mattia Codato 2020-08-25 17:35:34 +02:00
parent 9c2cc1169b
commit 3b4c008c81
1 changed files with 7 additions and 7 deletions

View File

@ -1535,9 +1535,9 @@ $ curl -k -s -u root:icinga -H 'Accept: application/json' \
} }
``` ```
### execute-command ### execute-command <a id="icinga2-api-actions-execute-command"></a>
This API can be used to execute a particular check/notification/event-command on a particular Executes a particular check/notification/event-command on a particular
endpoint in the context of a particular checkable. endpoint in the context of a particular checkable.
Send a `POST` request to the URL endpoint `/v1/actions/execute-command`. Send a `POST` request to the URL endpoint `/v1/actions/execute-command`.
@ -1546,18 +1546,18 @@ Send a `POST` request to the URL endpoint `/v1/actions/execute-command`.
--------------|------------|-------------- --------------|------------|--------------
ttl | Number | **Required.** The time to live of the execution expressed in seconds. ttl | Number | **Required.** The time to live of the execution expressed in seconds.
command_type | String | **Optional.** The command type: `CheckCommand` or `EventCommand` or `NotificationCommand`. Default: `EventCommand` command_type | String | **Optional.** The command type: `CheckCommand` or `EventCommand` or `NotificationCommand`. Default: `EventCommand`
command | String | **Optional.** The command to execute. Its type must the same as `command_type`. It can be a macro string. Default: depending on the `command_type` it can be `$check_command$`, `$event_command$` or `$notification_command$` command | String | **Optional.** The command to execute. Its type must the same as `command_type`. It can be a macro string. Default: depending on the `command_type` it's either `$check_command$`, `$event_command$` or `$notification_command$`
endpoint | String | **Optional.** The endpoint to execute the command on. It can be a macro string. Default: `$command_endpoint`. endpoint | String | **Optional.** The endpoint to execute the command on. It can be a macro string. Default: `$command_endpoint$`.
macros | Dictionary | **Optional**. A serialized object used to resolve the macro strings. Default: `{}` macros | Dictionary | **Optional**. A serialized object used to resolve the macro strings. It overrides also macros of other parameter. e.g. {"http_ssl": false}. Default: `{}`
user | String | **Optional.** The user used for the notification command. user | String | **Optional.** The user used for the notification command.
notification | String | **Optional.** The notification used for the notification command. notification | String | **Optional.** The notification used for the notification command.
Example: Example:
``` ```
$ curl -k -s -u root:icinga -H 'Accept: application/json' \ $ curl -k -s -S -i -u root:icinga -H 'Accept: application/json' \
-X POST 'https://localhost:5665/v1/actions/execute-command' \ -X POST 'https://localhost:5665/v1/actions/execute-command' \
-d '{"type":"Service", "service": "agent!custom_service", "ttl":"15", "macros": { "command_endpoint":"master", "ls_dir":"/tmp/foo" }, "command": "custom_command", "command_type": "CheckCommand" }' -d '{"type": "Service", "service": "agent!custom_service", "ttl": 15, "macros": { "command_endpoint": "master", "ls_dir": "/tmp/foo" }, "command": "custom_command", "command_type": "CheckCommand" }'
{ {
"results": [ "results": [
{ {