Module: check_mk
Branch: master
Commit: dba10b6390bc624ab0de79dd69c23f70f60bd55d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dba10b6390bc62…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Tue May 8 10:17:14 2018 +0200
Fixed unintended loss of precision in staleness calculation.
Change-Id: Ie953882964b550f1972bf15346da643f1b210216
---
livestatus/src/HostSpecialDoubleColumn.cc | 2 +-
livestatus/src/ServiceSpecialDoubleColumn.cc | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/livestatus/src/HostSpecialDoubleColumn.cc
b/livestatus/src/HostSpecialDoubleColumn.cc
index 0574c19..e8b33be 100644
--- a/livestatus/src/HostSpecialDoubleColumn.cc
+++ b/livestatus/src/HostSpecialDoubleColumn.cc
@@ -49,7 +49,7 @@ double HostSpecialDoubleColumn::getValue(Row row) const {
switch (_type) {
case Type::staleness: {
extern int interval_length;
- return (time(nullptr) - hst->last_check) /
+ return static_cast<double>(time(nullptr) - hst->last_check) /
((hst->check_interval == 0 ? 1 : hst->check_interval) *
interval_length);
}
diff --git a/livestatus/src/ServiceSpecialDoubleColumn.cc
b/livestatus/src/ServiceSpecialDoubleColumn.cc
index 0266947..20bcb30 100644
--- a/livestatus/src/ServiceSpecialDoubleColumn.cc
+++ b/livestatus/src/ServiceSpecialDoubleColumn.cc
@@ -47,7 +47,8 @@ double ServiceSpecialDoubleColumn::getValue(Row row) const {
switch (_type) {
case Type::staleness: {
extern int interval_length;
- time_t check_result_age = time(nullptr) - svc->last_check;
+ double check_result_age =
+ static_cast<double>(time(nullptr) - svc->last_check);
if (svc->check_interval != 0) {
return check_result_age /
(svc->check_interval * interval_length);