From b4d6fe2c8dc7c97477b870abd060023cc8210428 Mon Sep 17 00:00:00 2001 From: Mattia Codato Date: Tue, 21 Jul 2020 16:33:52 +0200 Subject: [PATCH] Check if the node accept commands only if the origin is not local --- lib/icinga/clusterevents-check.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/icinga/clusterevents-check.cpp b/lib/icinga/clusterevents-check.cpp index 83d73c487..69cdf7636 100644 --- a/lib/icinga/clusterevents-check.cpp +++ b/lib/icinga/clusterevents-check.cpp @@ -154,7 +154,7 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons }; } - if (!listener->GetAcceptCommands()) { + if (!listener->GetAcceptCommands() && !origin->IsLocal()) { Log(LogWarning, "ApiListener") << "Ignoring command. '" << listener->GetName() << "' does not accept commands."; @@ -172,16 +172,12 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons executedParams->Set("start", now); executedParams->Set("end", now); - if (origin->IsLocal()) { - ClusterEvents::ExecutedCommandAPIHandler(origin, executedParams); - } else { - Dictionary::Ptr executedMessage = new Dictionary(); - executedMessage->Set("jsonrpc", "2.0"); - executedMessage->Set("method", "event::ExecutedCommand"); - executedMessage->Set("params", executedParams); + Dictionary::Ptr executedMessage = new Dictionary(); + executedMessage->Set("jsonrpc", "2.0"); + executedMessage->Set("method", "event::ExecutedCommand"); + executedMessage->Set("params", executedParams); - listener->SyncSendMessage(sourceEndpoint, executedMessage); - } + listener->SyncSendMessage(sourceEndpoint, executedMessage); } else { Host::Ptr host = new Host(); Dictionary::Ptr attrs = new Dictionary();