Merge pull request #7861 from Icinga/bugfix/command-endpoint-check-timeout

Fix 'check_timeout' not being forwarded to agent command endpoints
This commit is contained in:
Noah Hilverling 2020-02-28 17:42:22 +01:00 committed by GitHub
commit b6b7856796
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 7 deletions

View File

@ -1742,13 +1742,14 @@ params | Dictionary
##### Params
Key | Type | Description
--------------|---------------|------------------
host | String | Host name.
service | String | Service name.
command\_type | String | `check_command` or `event_command`.
command | String | CheckCommand or EventCommand name.
macros | Dictionary | Command arguments as key/value pairs for remote execution.
Key | Type | Description
---------------|---------------|------------------
host | String | Host name.
service | String | Service name.
command\_type | String | `check_command` or `event_command`.
command | String | CheckCommand or EventCommand name.
check\_timeout | Number | Check timeout of the checkable object, if specified as `check_timeout` attribute.
macros | Dictionary | Command arguments as key/value pairs for remote execution.
##### Functions

View File

@ -569,6 +569,13 @@ void Checkable::ExecuteCheck()
if (service)
params->Set("service", service->GetShortName());
/*
* If the host/service object specifies the 'check_timeout' attribute,
* forward this to the remote endpoint to limit the command execution time.
*/
if (!GetCheckTimeout().IsEmpty())
params->Set("check_timeout", GetCheckTimeout());
params->Set("macros", macros);
ApiListener::Ptr listener = ApiListener::GetInstance();

View File

@ -124,6 +124,14 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons
attrs->Set("__name", params->Get("host"));
attrs->Set("type", "Host");
/*
* Override the check timeout if the parent caller provided the value. Compatible with older versions not
* passing this inside the cluster message.
* This happens with host/service command_endpoint agents and the 'check_timeout' attribute being specified.
*/
if (params->Contains("check_timeout"))
attrs->Set("check_timeout", params->Get("check_timeout"));
Deserialize(host, attrs, false, FAConfig);
if (params->Contains("service"))