Module: check_mk
Branch: master
Commit: 46b6aabdc769a6481fc650cd6ac6ea06bf211721
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=46b6aabdc769a6…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Thu Jun 9 16:54:07 2016 +0200
3635 FIX get_average: fixed overflow error
---
.werks/3635 | 10 ++++++++++
ChangeLog | 1 +
modules/check_mk_base.py | 32 ++++++++++++++++++++------------
3 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/.werks/3635 b/.werks/3635
new file mode 100644
index 0000000..16994f6
--- /dev/null
+++ b/.werks/3635
@@ -0,0 +1,10 @@
+Title: get_average: fixed overflow error
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i1
+Date: 1465484004
+
+
diff --git a/ChangeLog b/ChangeLog
index 447eae5..0d28548 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -263,6 +263,7 @@
* 3541 FIX: esx_vsphere_hostsystem.state: no longer crashes when data is missing...
* 3590 FIX: mssql.vbs: Completely removed plugin timeout...
* 3643 FIX: Fixed check_mkevents active check....
+ * 3635 FIX: get_average: fixed overflow error
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index f2d9189..fc63a14 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -1147,18 +1147,26 @@ def get_average(itemname, this_time, this_val, backlog_minutes,
initialize_zero
if timedif < 0:
timedif = 0
- # Compute the weight: We do it like this: First we assume that
- # we get one sample per minute. And that backlog_minutes is the number
- # of minutes we should average over. Then we want that the weight
- # of the values of the last average minutes have a fraction of W%
- # in the result and the rest until infinity the rest (1-W%).
- # Then the weight can be computed as backlog_minutes'th root of 1-W
- percentile = 0.50
-
- weight_per_minute = (1 - percentile) ** (1.0 / backlog_minutes)
-
- # now let's compute the weight per second. This is done
- weight = weight_per_minute ** (timedif / 60.0)
+ # Overflow error occurs if weigth exceeds 1e308 or falls below 1e-308
+ # Under the conditions 0<=percentile<=1, backlog_minutes>=1 and
timedif>=0
+ # first case is not possible because weigth is max. 1.
+ # In the second case weigth goes to zero.
+ try:
+ # Compute the weight: We do it like this: First we assume that
+ # we get one sample per minute. And that backlog_minutes is the number
+ # of minutes we should average over. Then we want that the weight
+ # of the values of the last average minutes have a fraction of W%
+ # in the result and the rest until infinity the rest (1-W%).
+ # Then the weight can be computed as backlog_minutes'th root of 1-W
+ percentile = 0.50
+
+ weight_per_minute = (1 - percentile) ** (1.0 / backlog_minutes)
+
+ # now let's compute the weight per second. This is done
+ weight = weight_per_minute ** (timedif / 60.0)
+
+ except OverflowError:
+ weight = 0
new_val = last_val * weight + this_val * (1 - weight)