]> granicus.if.org Git - icinga2/commitdiff
Make check_source a check result attribute.
authorGunnar Beutner <gunnar@beutner.name>
Fri, 27 Sep 2013 05:34:08 +0000 (07:34 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Fri, 27 Sep 2013 05:34:08 +0000 (07:34 +0200)
lib/icinga/compatutility.cpp
lib/icinga/service-check.cpp
lib/icinga/service.cpp
lib/icinga/service.h

index 1932b1d5683458c0d07b46274a551b67017e76d3..a0a65101b8e7ad080cb3da362bbccbaf40f577c8 100644 (file)
@@ -178,6 +178,7 @@ Dictionary::Ptr CompatUtility::GetServiceStatusAttributes(const Service::Ptr& se
        String output;
        String long_output;
        String perfdata;
+       String check_source;
        double schedule_end = -1;
 
        String check_period_str;
@@ -194,6 +195,8 @@ Dictionary::Ptr CompatUtility::GetServiceStatusAttributes(const Service::Ptr& se
                output = output_bag->Get("output");
                long_output = output_bag->Get("long_output");
 
+               check_source = cr->Get("check_source");
+
                perfdata = GetCheckResultPerfdata(cr);
                schedule_end = cr->Get("schedule_end");
        }
@@ -260,6 +263,7 @@ Dictionary::Ptr CompatUtility::GetServiceStatusAttributes(const Service::Ptr& se
        attr->Set("plugin_output", output);
        attr->Set("long_plugin_output", long_output);
        attr->Set("performance_data", perfdata);
+       attr->Set("check_source", check_source);
        attr->Set("check_type", (service->GetEnableActiveChecks() ? 1 : 0));
        attr->Set("last_check", schedule_end);
        attr->Set("next_check", service->GetNextCheck());
@@ -285,10 +289,6 @@ Dictionary::Ptr CompatUtility::GetServiceStatusAttributes(const Service::Ptr& se
        attr->Set("next_notification", next_notification);
        attr->Set("current_notification_number", notification_number);
 
-       String authority = service->GetCheckResultAuthority();
-       if (!authority.IsEmpty())
-               attr->Set("check_source", authority);
-
        return attr;
 }
 
index ca22a56b48157a40a76b57dbf452f9eb67564153..01048a10145877dcdced3f024bb35b674acfb597 100644 (file)
@@ -456,6 +456,9 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr, const String& author
        if (!cr->Contains("execution_end"))
                cr->Set("execution_end", now);
 
+       if (!cr->Contains("check_source"))
+               cr->Set("check_source", authority);
+
        bool reachable = IsReachable();
 
        Host::Ptr host = GetHost();
@@ -603,9 +606,6 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr, const String& author
        olock.Lock();
        SetLastCheckResult(cr);
 
-       if (!authority.IsEmpty())
-               SetCheckResultAuthority(authority);
-
        bool was_flapping, is_flapping;
 
        was_flapping = IsFlapping();
index ac54517551d8e1ff157f41698ebc840fadb27695..465befd990180be9eb8be0bd7dbae4c29f22db9c 100644 (file)
@@ -328,19 +328,6 @@ std::set<Service::Ptr> Service::GetParentServices(void) const
        return parents;
 }
 
-void Service::SetCheckResultAuthority(const String& authority)
-{
-       m_CheckResultAuthority = authority;
-}
-
-String Service::GetCheckResultAuthority(void) const
-{
-       if (m_CheckResultAuthority.IsEmpty())
-               return "(i2 local)";
-       else
-               return m_CheckResultAuthority;
-}
-
 bool Service::ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const
 {
        if (macro == "SERVICEDESC") {
index 1fbcfc86500a09f00be51a19fa454bbdcdd42099..4d4203c5df7c7da207ed57ac5dc47d227b3235a0 100644 (file)
@@ -142,9 +142,6 @@ public:
        void AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, double expiry = 0, const String& authority = String());
        void ClearAcknowledgement(const String& authority = String());
 
-       void SetCheckResultAuthority(const String& authority);
-       String GetCheckResultAuthority(void) const;
-
        /* Checks */
        shared_ptr<CheckCommand> GetCheckCommand(void) const;
        long GetMaxCheckAttempts(void) const;
@@ -355,7 +352,6 @@ private:
        Value m_AcknowledgementExpiry;
        String m_HostName;
        Value m_Volatile;
-       String m_CheckResultAuthority;
 
        /* Checks */
        String m_CheckCommand;