[icinga-checkins] icinga.org: icinga2/master: Set min_latency and min_execution_time to 0 when there have been no checkresults processed

git at icinga.org git at icinga.org
Tue Jul 26 09:54:18 CEST 2016


Module: icinga2
Branch: master
Commit: 730d959374c9c34fbc67f7bffbb49b678c9f5b00
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=730d959374c9c34fbc67f7bffbb49b678c9f5b00

Author: Rune Darrud <theflyingcorpse at gmail.com>
Date:   Mon Jul 25 16:01:44 2016 +0200

Set min_latency and min_execution_time to 0 when there have been no checkresults processed

fixes #12216

Signed-off-by: Gunnar Beutner <gunnar.beutner at netways.de>

---

 lib/icinga/cib.cpp |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/lib/icinga/cib.cpp b/lib/icinga/cib.cpp
index ccdbc17..1ea4233 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<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;



More information about the icinga-checkins mailing list