]> granicus.if.org Git - icinga2/commitdiff
Set min_latency and min_execution_time to 0 when there have been no checkresults...
authorRune Darrud <theflyingcorpse@gmail.com>
Mon, 25 Jul 2016 14:01:44 +0000 (16:01 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 26 Jul 2016 07:54:08 +0000 (09:54 +0200)
fixes #12216

Signed-off-by: Gunnar Beutner <gunnar.beutner@netways.de>
lib/icinga/cib.cpp

index ccdbc177efee854bdaa8d8f78317b38e344ac77c..1ea4233dd905976ba589ab003811514a311a626c 100644 (file)
@@ -80,6 +80,7 @@ CheckableCheckStatistics CIB::CalculateHostCheckStats(void)
        int count_latency = 0;
        double min_execution_time = -1, max_execution_time = 0, sum_execution_time = 0;
        int count_execution_time = 0;
+       bool checkresult = false;
 
        BOOST_FOREACH(const Host::Ptr& host, ConfigType::GetObjectsByType<Host>()) {
                ObjectLock olock(host);
@@ -89,6 +90,9 @@ CheckableCheckStatistics CIB::CalculateHostCheckStats(void)
                if (!cr)
                        continue;
 
+               /* set to true, we have a checkresult */
+               checkresult = true;
+
                /* latency */
                double latency = cr->CalculateLatency();
 
@@ -114,6 +118,11 @@ CheckableCheckStatistics CIB::CalculateHostCheckStats(void)
                count_execution_time++;
        }
 
+       if (!checkresult) {
+               min_latency = 0;
+               min_execution_time = 0;
+       }
+
        CheckableCheckStatistics ccs;
 
        ccs.min_latency = min_latency;
@@ -132,6 +141,7 @@ CheckableCheckStatistics CIB::CalculateServiceCheckStats(void)
        int count_latency = 0;
        double min_execution_time = -1, max_execution_time = 0, sum_execution_time = 0;
        int count_execution_time = 0;
+       bool checkresult = false;
 
        BOOST_FOREACH(const Service::Ptr& service, ConfigType::GetObjectsByType<Service>()) {
                ObjectLock olock(service);
@@ -141,6 +151,9 @@ CheckableCheckStatistics CIB::CalculateServiceCheckStats(void)
                if (!cr)
                        continue;
 
+               /* set to true, we have a checkresult */
+               checkresult = true;
+
                /* latency */
                double latency = cr->CalculateLatency();
 
@@ -166,6 +179,11 @@ CheckableCheckStatistics CIB::CalculateServiceCheckStats(void)
                count_execution_time++;
        }
 
+       if (!checkresult) {
+               min_latency = 0;
+               min_execution_time = 0;
+       }
+
        CheckableCheckStatistics ccs;
 
        ccs.min_latency = min_latency;