Module: check_mk
Branch: master
Commit: 2dc44c24d1a66d669b5767b3309800cf9eff6cc3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2dc44c24d1a66d…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Jul 2 15:41:12 2013 +0200
prediction: Fixed several problems with incomplete RRDs
---
modules/prediction.py | 8 +++++---
web/htdocs/prediction.py | 25 ++++++++++++++++---------
2 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/modules/prediction.py b/modules/prediction.py
index 8d9a741..bf114d3 100644
--- a/modules/prediction.py
+++ b/modules/prediction.py
@@ -182,9 +182,11 @@ def compute_prediction(pred_file, timegroup, params, period_info,
from_time, dsn
# print "PUNKT %d --------------------------------------" % i
point_line = []
for from_time, scale, data in slices:
- d = data[int(i / float(scale))]
- if d != None:
- point_line.append(d)
+ idx = int(i / float(scale))
+ if idx < len(data):
+ d = data[idx]
+ if d != None:
+ point_line.append(d)
# else:
# date_str = time.strftime("%Y-%m-%d %H:%M", time.localtime(fr
+ ((un - fr) * i / float(num_points))))
# print "Keine Daten fur %s / %d/%s/ %.2f " % (date_str, i,
float(scale),i/float(scale))
diff --git a/web/htdocs/prediction.py b/web/htdocs/prediction.py
index 2574961..534bce4 100644
--- a/web/htdocs/prediction.py
+++ b/web/htdocs/prediction.py
@@ -203,13 +203,20 @@ def swap_and_compute_levels(tg_data, tg_info):
row = dict(zip(columns, step))
for k, v in row.items():
swapped[k].append(v)
- upper, lower = compute_levels(tg_info, row["average"],
row["stdev"])
- if upper[0] != None:
- swapped.setdefault("upper_warn", []).append(upper[0])
- swapped.setdefault("upper_crit", []).append(upper[1])
- if lower[0] != None:
- swapped.setdefault("lower_warn", []).append(lower[0])
- swapped.setdefault("lower_crit", []).append(lower[1])
+ if row["average"] != None and row["stdev"] != None:
+ upper, lower = compute_levels(tg_info, row["average"],
row["stdev"])
+ if upper[0] != None:
+ swapped.setdefault("upper_warn", []).append(upper[0])
+ swapped.setdefault("upper_crit", []).append(upper[1])
+ if lower[0] != None:
+ swapped.setdefault("lower_warn", []).append(lower[0])
+ swapped.setdefault("lower_crit", []).append(lower[1])
+ else:
+ swapped.setdefault("upper_warn", []).append(0)
+ swapped.setdefault("upper_crit", []).append(0)
+ swapped.setdefault("lower_warn", []).append(0)
+ swapped.setdefault("lower_crit", []).append(0)
+
return swapped
def stack(apoints, bpoints, scale):
@@ -243,8 +250,8 @@ def compute_levels(params, ref_value, stdev):
def compute_vertical_range(swapped):
mmin, mmax = 0.0, 0.0
for name, points in swapped.items():
- mmax = max(mmax, max(points))
- mmin = min(mmin, min(points))
+ mmax = max(mmax, max(points)) or 0.0 # convert None into 0.0
+ mmin = min(mmin, min(points)) or 0.0
return mmin, mmax
def create_graph(name, size, range, v_range, legend):