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@netways.de>
This commit is contained in:
Rune Darrud 2016-07-25 16:01:44 +02:00 committed by Gunnar Beutner
parent 4125591cc0
commit 730d959374
1 changed files with 18 additions and 0 deletions

View 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;