]> granicus.if.org Git - icinga2/commitdiff
Add check authority to service.
authorMichael Friedrich <Michael.Friedrich@netways.de>
Thu, 26 Sep 2013 19:53:43 +0000 (21:53 +0200)
committerMichael Friedrich <Michael.Friedrich@netways.de>
Thu, 26 Sep 2013 19:53:43 +0000 (21:53 +0200)
fixes #4762

components/compat/statusdatawriter.cpp
lib/icinga/compatutility.cpp
lib/icinga/service-check.cpp
lib/icinga/service.cpp
lib/icinga/service.h

index 0c4bcc1319b37ab66fe5c90e4e72421a987116ce..56a98506c036aa5d4801f3f0cc832c39e42e9cd9 100644 (file)
@@ -334,6 +334,7 @@ void StatusDataWriter::DumpServiceStatusAttrs(std::ostream& fp, const Service::P
           << "\t" << "plugin_output=" << attrs->Get("plugin_output") << "\n"
           << "\t" << "long_plugin_output=" << attrs->Get("long_plugin_output") << "\n"
           << "\t" << "performance_data=" << attrs->Get("performance_data") << "\n"
+          << "\t" << "check_source=" << attrs->Get("check_source") << "\n"
           << "\t" << "last_check=" << static_cast<long>(attrs->Get("last_check")) << "\n"
           << "\t" << "next_check=" << static_cast<long>(attrs->Get("next_check")) << "\n"
           << "\t" << "current_attempt=" << attrs->Get("current_attempt") << "\n"
index 103f8cf1f749601c88720191d70bac26fe1c80ae..1932b1d5683458c0d07b46274a551b67017e76d3 100644 (file)
@@ -285,6 +285,10 @@ 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 5d4fe64edd7e5dd7d990ba9965620b5484c2ff1d..ca22a56b48157a40a76b57dbf452f9eb67564153 100644 (file)
@@ -603,6 +603,9 @@ 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 465befd990180be9eb8be0bd7dbae4c29f22db9c..7dcb94cfe3e153759dc40b4e181e301bb0e06ea4 100644 (file)
@@ -328,6 +328,19 @@ 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 "(local)";
+       else
+               return m_CheckResultAuthority;
+}
+
 bool Service::ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const
 {
        if (macro == "SERVICEDESC") {
index 4d4203c5df7c7da207ed57ac5dc47d227b3235a0..1fbcfc86500a09f00be51a19fa454bbdcdd42099 100644 (file)
@@ -142,6 +142,9 @@ 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;
@@ -352,6 +355,7 @@ private:
        Value m_AcknowledgementExpiry;
        String m_HostName;
        Value m_Volatile;
+       String m_CheckResultAuthority;
 
        /* Checks */
        String m_CheckCommand;