From b30960fda5d1245a997a81a35100adea8f2ac4d3 Mon Sep 17 00:00:00 2001 From: Mattia Codato Date: Thu, 23 Jul 2020 13:03:30 +0200 Subject: [PATCH] Add try catch for ExecuteEventHandler --- lib/icinga/clusterevents-check.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/icinga/clusterevents-check.cpp b/lib/icinga/clusterevents-check.cpp index af124cb32..646a7bd39 100644 --- a/lib/icinga/clusterevents-check.cpp +++ b/lib/icinga/clusterevents-check.cpp @@ -295,7 +295,18 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons Log(LogCritical, "checker", output); } } else if (command_type == "event_command") { - host->ExecuteEventHandler(macros, true); + try { + host->ExecuteEventHandler(macros, true); + } catch (const std::exception& ex) { + if (params->Contains("source")) { + String output = "Exception occurred while executing event command '" + command + "' for '" + + host->GetName() + "': " + DiagnosticInformation(ex); + + double now = Utility::GetTime(); + ServiceState state = ServiceUnknown; + SendEventExecuteCommand(params, state, output, now, now, listener, origin, sourceEndpoint); + } + } } else if (command_type == "notification_command") { /* Get user */ User::Ptr user = new User();