Return the process result parameters instead of the check result

This commit is contained in:
Mattia Codato 2020-07-15 18:40:37 +02:00
parent 4255fd9494
commit 50f803c042
2 changed files with 22 additions and 21 deletions

View File

@ -158,24 +158,15 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons
<< pr.ExitStatus << ", output: " << pr.Output;
}
String output = pr.Output.Trim();
std::pair<String, String> co = PluginUtility::ParseCheckOutput(output);
CheckResult::Ptr cr = new CheckResult();
cr->SetCommand(commandLine);
cr->SetOutput(co.first);
cr->SetPerformanceData(PluginUtility::SplitPerfdata(co.second));
cr->SetState(PluginUtility::ExitStatusToState(pr.ExitStatus));
cr->SetExitStatus(pr.ExitStatus);
cr->SetExecutionStart(pr.ExecutionStart);
cr->SetExecutionEnd(pr.ExecutionEnd);
Dictionary::Ptr executedParams = new Dictionary();
executedParams->Set("execution", params->Get("source"));
executedParams->Set("host", params->Get("host"));
if (params->Contains("service"))
executedParams->Set("service", params->Get("service"));
executedParams->Set("check_result", Serialize(cr));
executedParams->Set("exit", pr.ExitStatus);
executedParams->Set("output", pr.Output);
executedParams->Set("start", pr.ExecutionStart);
executedParams->Set("end", pr.ExecutionEnd);
if (origin->IsLocal()) {
ClusterEvents::ExecutedCommandAPIHandler(origin, executedParams);
@ -216,7 +207,10 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons
executedParams->Set("host", params->Get("host"));
if (params->Contains("service"))
executedParams->Set("service", params->Get("service"));
executedParams->Set("check_result", Serialize(cr));
double now = Utility::GetTime();
executedParams->Set("error", cr->GetOutput());
executedParams->Set("start", now);
executedParams->Set("end", now);
if (origin->IsLocal()) {
ClusterEvents::ExecutedCommandAPIHandler(origin, executedParams);

View File

@ -1010,14 +1010,21 @@ Value ClusterEvents::ExecutedCommandAPIHandler(const MessageOrigin::Ptr& origin,
return Empty;
}
if (!params->Contains("check_result")) {
Log(LogNotice, "ClusterEvents")
<< "Discarding 'update executions API handler' message for checkable '" << checkable->GetName()
<< "' from '" << origin->FromClient->GetIdentity() << "': No check result available.";
return Empty;
}
if (params->Contains("error"))
execution->Set("error", params->Get("error"));
if (params->Contains("exit"))
execution->Set("exit", params->Get("exit"));
if (params->Contains("output"))
execution->Set("output", params->Get("output"));
if (params->Contains("start"))
execution->Set("start", params->Get("start"));
if (params->Contains("end"))
execution->Set("end", params->Get("end"));
execution->Set("check_result", params->Get("check_result"));
execution->Set("pending", false);
/* Broadcast the update */