]> granicus.if.org Git - icinga2/commitdiff
Use the command_endpoint name as check_source value if defined
authorMichael Friedrich <michael.friedrich@gmail.com>
Sat, 5 Sep 2015 13:18:10 +0000 (15:18 +0200)
committerMichael Friedrich <michael.friedrich@gmail.com>
Sat, 5 Sep 2015 13:35:38 +0000 (15:35 +0200)
fixes #9218

lib/icinga/checkable-check.cpp

index 13f0b28088ae43c8a33f892b3bcdaed61a206a54..f2b1e757c27979346842668f170ce66f58f5e4e6 100644 (file)
@@ -255,13 +255,27 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
        if (cr->GetExecutionEnd() == 0)
                cr->SetExecutionEnd(now);
 
-       if (origin.IsLocal())
+       if (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) {