From 730d959374c9c34fbc67f7bffbb49b678c9f5b00 Mon Sep 17 00:00:00 2001 From: Rune Darrud Date: Mon, 25 Jul 2016 16:01:44 +0200 Subject: [PATCH] Set min_latency and min_execution_time to 0 when there have been no checkresults processed fixes #12216 Signed-off-by: Gunnar Beutner --- lib/icinga/cib.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/icinga/cib.cpp b/lib/icinga/cib.cpp index ccdbc177e..1ea4233dd 100644 --- a/lib/icinga/cib.cpp +++ b/lib/icinga/cib.cpp @@ -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()) { 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()) { 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;