From: Michael Friedrich Date: Mon, 21 Aug 2017 15:20:56 +0000 (+0200) Subject: API: Add execution_{start,end} attribute to 'process-check-result' action X-Git-Tag: v2.8.0~102^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e88b97079c7305f15bb31e72c8dfdcc21e9e0390;p=icinga2 API: Add execution_{start,end} attribute to 'process-check-result' action fixes #5002 --- diff --git a/doc/12-icinga2-api.md b/doc/12-icinga2-api.md index ab14ff65a..89ec60e7e 100644 --- a/doc/12-icinga2-api.md +++ b/doc/12-icinga2-api.md @@ -805,6 +805,8 @@ Send a `POST` request to the URL endpoint `/v1/actions/process-check-result`. performance\_data | string array | **Optional.** The performance data. check\_command | string array | **Optional.** The first entry should be the check commands path, then one entry for each command line option followed by an entry for each of its argument. check\_source | string | **Optional.** Usually the name of the `command_endpoint` + execution\_start | timestamp | **Optional.** The timestamp where a script/process started its execution. + execution\_end | timestamp | **Optional.** The timestamp where a script/process ended its execution. This timestamp is used in features to determine e.g. the metric timestamp. In addition to these parameters a [filter](12-icinga2-api.md#icinga2-api-filters) must be provided. The valid types for this action are `Host` and `Service`. diff --git a/lib/icinga/apiactions.cpp b/lib/icinga/apiactions.cpp index d488cd599..9d900524a 100644 --- a/lib/icinga/apiactions.cpp +++ b/lib/icinga/apiactions.cpp @@ -103,6 +103,12 @@ Dictionary::Ptr ApiActions::ProcessCheckResult(const ConfigObject::Ptr& object, cr->SetOutput(HttpUtility::GetLastParameter(params, "plugin_output")); cr->SetState(state); + if (params->Contains("execution_start")) + cr->SetExecutionStart(HttpUtility::GetLastParameter(params, "execution_start")); + + if (params->Contains("execution_end")) + cr->SetExecutionEnd(HttpUtility::GetLastParameter(params, "execution_end")); + cr->SetCheckSource(HttpUtility::GetLastParameter(params, "check_source")); cr->SetPerformanceData(params->Get("performance_data")); cr->SetCommand(params->Get("check_command"));