]> granicus.if.org Git - icinga2/commitdiff
Bugfixes.
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 3 Jul 2012 13:01:09 +0000 (15:01 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 3 Jul 2012 13:01:09 +0000 (15:01 +0200)
cib/service.cpp
cib/service.h
components/compat/compatcomponent.cpp
components/delegation/delegationcomponent.cpp

index 7ca10d6e35b280e733e0eddb7f5e3f729054c962..0b29e8b6f75784a17e2ad5fde7e3fb5c76238ffa 100644 (file)
@@ -186,22 +186,35 @@ void Service::InvalidateDependencyCache(void)
        m_DependencyCacheValid = false;
 }
 
-ServiceStatusMessage Service::CalculateCombinedStatus(ServiceStatusMessage *input, const vector<Service>& parents)
+ServiceStatusMessage Service::CalculateCombinedStatus(Service *current, ServiceStatusMessage *input, const vector<Service>& parents)
 {
        vector<Service> failedServices;
 
        time_t nextCheck = -1;
-       time_t lastChange = -1;
 
        vector<Service>::const_iterator it;
        for (it = parents.begin(); it != parents.end(); it++) {
                Service parent = *it;
 
-               if (parent.GetState() != StateOK && parent.GetState() != StateWarning)
-                       failedServices.push_back(parent);
+               if (current && current->GetName() == parent.GetName())
+                       continue;
+
+               if (!parent.HasLastCheckResult())
+                       continue;
+
+               string svcname;
+               ServiceState state = StateUnknown;
+               ServiceStateType type = StateTypeHard;
+               if (input && input->GetService(&svcname) && svcname == parent.GetName()) {
+                       input->GetState(&state);
+                       input->GetStateType(&type);
+               } else {
+                       state = parent.GetState();
+                       type = parent.GetStateType();
+               }
 
-               if (lastChange == -1 || parent.GetLastStateChange() > lastChange)
-                       lastChange = parent.GetLastStateChange();
+               if (state != StateOK && state != StateWarning && type == StateTypeHard)
+                       failedServices.push_back(parent);
 
                if (nextCheck == -1 || parent.GetNextCheck() < nextCheck)
                        nextCheck = parent.GetNextCheck();
index 95796b8e03b1f9f635fe637a048955f0cc1f8812..431849ce7aebcece1106f663b97e87d1b5bf1550 100644 (file)
@@ -50,7 +50,7 @@ public:
        static void UpdateDependencyCache(void);
        static void InvalidateDependencyCache(void);
 
-       static ServiceStatusMessage CalculateCombinedStatus(ServiceStatusMessage *input, const vector<Service>& parents);
+       static ServiceStatusMessage CalculateCombinedStatus(Service *current, ServiceStatusMessage *input, const vector<Service>& parents);
 
        void SetNextCheck(time_t nextCheck);
        time_t GetNextCheck(void);
index 9809bf81b5b2b44b80ecbf519848499f2dd9803c..17ae39249fb3b107090e0104b253f9767cdb7388 100644 (file)
@@ -113,6 +113,9 @@ void CompatComponent::DumpServiceStatus(ofstream& fp, Service service)
 
        int state = service.GetState();
 
+       if (state == StateUnreachable)
+               state = StateCritical;
+
        if (state >= StateUnknown)
                state = StateUnknown;
 
index ec9f6f61608a8030673d71c50e257a609ba676d9..beef490f1293e21412a133e2d4c69178adcc4f94 100644 (file)
@@ -315,7 +315,7 @@ void DelegationComponent::CheckResultRequestHandler(const Endpoint::Ptr& sender,
                vector<Service> affectedServices = child.GetParents();
                affectedServices.push_back(child);
 
-               ServiceStatusMessage statusmsg = Service::CalculateCombinedStatus(NULL, affectedServices);
+               ServiceStatusMessage statusmsg = Service::CalculateCombinedStatus(&child, NULL, affectedServices);
                statusmsg.SetService(child.GetName());
 
                ServiceState state = StateUnreachable;
@@ -335,7 +335,7 @@ void DelegationComponent::CheckResultRequestHandler(const Endpoint::Ptr& sender,
        rm.SetMethod("delegation::ServiceStatus");
 
        vector<Service> parents = service.GetParents();
-       ServiceStatusMessage statusmsg = Service::CalculateCombinedStatus(&params, parents);
+       ServiceStatusMessage statusmsg = Service::CalculateCombinedStatus(&service, &params, parents);
        statusmsg.SetService(service.GetName());
 
        rm.SetParams(statusmsg);