]> granicus.if.org Git - icinga2/commitdiff
Make checkers configurable.
authorGunnar Beutner <gunnar.beutner@netways.de>
Mon, 2 Jul 2012 14:19:43 +0000 (16:19 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Mon, 2 Jul 2012 14:19:43 +0000 (16:19 +0200)
cib/service.cpp
cib/service.h
components/compat/compatcomponent.cpp

index 4953410686e85563eb62cc1e16da5b68780a0cff..64e042a4284053439e519d0000e55c4e74265d98 100644 (file)
@@ -107,6 +107,13 @@ Dictionary::Ptr Service::GetGroups(void) const
        return value;
 }
 
+Dictionary::Ptr Service::GetCheckers(void) const
+{
+       Dictionary::Ptr value;
+       GetConfigObject()->GetProperty("checkers", &value);
+       return value;
+}
+
 void Service::SetNextCheck(time_t nextCheck)
 {
        GetConfigObject()->SetTag("next_check", (long)nextCheck);
@@ -302,6 +309,19 @@ string Service::StateTypeToString(ServiceStateType type)
 
 bool Service::IsAllowedChecker(const string& checker) const
 {
-       /* TODO: check config */
-       return true;
+       Dictionary::Ptr checkers = GetCheckers();
+
+       if (!checkers)
+               return true;
+
+       Dictionary::Iterator it;
+       for (it = checkers->Begin(); it != checkers->End(); it++) {
+               string pattern = it->second;
+
+               if (Utility::Match(pattern, checker))
+                       return true;
+       }
+
+       return false;
 }
+
index 8e7874348e1b6458fbd4cfbf59523b7a39372a73..4f524b68677614a7e821f012627f09f91872ad97 100644 (file)
@@ -43,6 +43,7 @@ public:
        long GetFreshnessInterval(void) const;
        Dictionary::Ptr GetDependencies(void) const;
        Dictionary::Ptr GetGroups(void) const;
+       Dictionary::Ptr GetCheckers(void) const;
 
        void SetNextCheck(time_t nextCheck);
        time_t GetNextCheck(void);
index 197edc563dba0d7fe2b9a4ce8fed2618fff7971c..a5bda76c916a02ee74595950c4f0725d260180ad 100644 (file)
@@ -47,6 +47,7 @@ void CompatComponent::Start(void)
        m_StatusTimer->OnTimerExpired.connect(boost::bind(&CompatComponent::StatusTimerHandler, this));
        m_StatusTimer->Start();
 
+       CIB::RequireInformation(CIB_Configuration);
        CIB::RequireInformation(CIB_ProgramStatus);
        CIB::RequireInformation(CIB_ServiceStatus);
 }