mirror of https://github.com/Icinga/icinga2.git
Send error as command execution result
This commit is contained in:
parent
461b4e2176
commit
f59c60f85f
|
@ -180,21 +180,7 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons
|
||||||
Log(LogWarning, "ApiListener")
|
Log(LogWarning, "ApiListener")
|
||||||
<< "Ignoring command. '" << listener->GetName() << "' does not accept commands.";
|
<< "Ignoring command. '" << listener->GetName() << "' does not accept commands.";
|
||||||
|
|
||||||
Host::Ptr host = new Host();
|
String output = "Endpoint '" + Endpoint::GetLocalEndpoint()->GetName() + "' does not accept commands.";
|
||||||
Dictionary::Ptr attrs = new Dictionary();
|
|
||||||
|
|
||||||
attrs->Set("__name", params->Get("host"));
|
|
||||||
attrs->Set("type", "Host");
|
|
||||||
attrs->Set("enable_active_checks", false);
|
|
||||||
|
|
||||||
Deserialize(host, attrs, false, FAConfig);
|
|
||||||
|
|
||||||
if (params->Contains("service"))
|
|
||||||
host->SetExtension("agent_service_name", params->Get("service"));
|
|
||||||
|
|
||||||
CheckResult::Ptr cr = new CheckResult();
|
|
||||||
cr->SetState(ServiceUnknown);
|
|
||||||
cr->SetOutput("Endpoint '" + Endpoint::GetLocalEndpoint()->GetName() + "' does not accept commands.");
|
|
||||||
|
|
||||||
if (params->Contains("source")) {
|
if (params->Contains("source")) {
|
||||||
Dictionary::Ptr executedParams = new Dictionary();
|
Dictionary::Ptr executedParams = new Dictionary();
|
||||||
|
@ -203,7 +189,8 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons
|
||||||
if (params->Contains("service"))
|
if (params->Contains("service"))
|
||||||
executedParams->Set("service", params->Get("service"));
|
executedParams->Set("service", params->Get("service"));
|
||||||
double now = Utility::GetTime();
|
double now = Utility::GetTime();
|
||||||
executedParams->Set("error", cr->GetOutput());
|
executedParams->Set("exit", 126);
|
||||||
|
executedParams->Set("output", output);
|
||||||
executedParams->Set("start", now);
|
executedParams->Set("start", now);
|
||||||
executedParams->Set("end", now);
|
executedParams->Set("end", now);
|
||||||
|
|
||||||
|
@ -218,6 +205,22 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons
|
||||||
listener->SyncSendMessage(sourceEndpoint, executedMessage);
|
listener->SyncSendMessage(sourceEndpoint, executedMessage);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Host::Ptr host = new Host();
|
||||||
|
Dictionary::Ptr attrs = new Dictionary();
|
||||||
|
|
||||||
|
attrs->Set("__name", params->Get("host"));
|
||||||
|
attrs->Set("type", "Host");
|
||||||
|
attrs->Set("enable_active_checks", false);
|
||||||
|
|
||||||
|
Deserialize(host, attrs, false, FAConfig);
|
||||||
|
|
||||||
|
if (params->Contains("service"))
|
||||||
|
host->SetExtension("agent_service_name", params->Get("service"));
|
||||||
|
|
||||||
|
CheckResult::Ptr cr = new CheckResult();
|
||||||
|
cr->SetState(ServiceUnknown);
|
||||||
|
cr->SetOutput(output);
|
||||||
|
|
||||||
Dictionary::Ptr message = MakeCheckResultMessage(host, cr);
|
Dictionary::Ptr message = MakeCheckResultMessage(host, cr);
|
||||||
listener->SyncSendMessage(sourceEndpoint, message);
|
listener->SyncSendMessage(sourceEndpoint, message);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue