From: Michael Friedrich Date: Sat, 5 Sep 2015 13:18:10 +0000 (+0200) Subject: Use the command_endpoint name as check_source value if defined X-Git-Tag: v2.4.0~337 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3403765900553ab7939556b74f9aab5b5d1473e8;p=icinga2 Use the command_endpoint name as check_source value if defined fixes #9218 --- diff --git a/lib/icinga/checkable-check.cpp b/lib/icinga/checkable-check.cpp index aee39db96..6cead527d 100644 --- a/lib/icinga/checkable-check.cpp +++ b/lib/icinga/checkable-check.cpp @@ -115,13 +115,27 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig if (cr->GetExecutionEnd() == 0) cr->SetExecutionEnd(now); - if (!origin || origin->IsLocal()) + if (!origin || origin->IsLocal()) { + Log(LogDebug, "Checkable") + << "No origin or local origin for object '" << GetName() + << "', setting " << IcingaApplication::GetInstance()->GetNodeName() + << " as check_source."; cr->SetCheckSource(IcingaApplication::GetInstance()->GetNodeName()); + } Endpoint::Ptr command_endpoint = GetCommandEndpoint(); + /* override check source if command_endpoint was defined */ + if (command_endpoint && !GetExtension("agent_check")) { + Log(LogDebug, "Checkable") + << "command_endpoint found for object '" << GetName() + << "', setting " << command_endpoint->GetName() + << " as check_source."; + cr->SetCheckSource(command_endpoint->GetName()); + } + + /* agent checks go through the api */ if (command_endpoint && GetExtension("agent_check")) { - /* agent checks go through the api */ ApiListener::Ptr listener = ApiListener::GetInstance(); if (listener) {