Module: check_mk
Branch: master
Commit: 9bf6849b41cbdfcedd21e16d7432b35a57eddd04
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9bf6849b41cbdf…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Feb 20 16:09:39 2017 +0100
4389 FIX Views: Fixed "Cached" column when cache interval is reported to be 0
A "ZeroDivisionError (float division by zero)" exception could occur in views
containing the "Cached agent data" painter.
Change-Id: Iddf29141c5aad3c2b78b74f399dd205095aac21e
---
.werks/4389 | 11 +++++++++++
web/plugins/views/painters.py | 12 +++++++++---
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/.werks/4389 b/.werks/4389
new file mode 100644
index 0000000..dea4664
--- /dev/null
+++ b/.werks/4389
@@ -0,0 +1,11 @@
+Title: Views: Fixed "Cached" column when cache interval is reported to be 0
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.5.0i1
+Date: 1487603291
+
+A "ZeroDivisionError (float division by zero)" exception could occur in views
+containing the "Cached agent data" painter.
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index 8c1c541..90f134f 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -798,9 +798,15 @@ def paint_cache_info(row):
cached_at = row["service_cached_at"]
cache_interval = row["service_cache_interval"]
cache_age = time.time() - cached_at
- percentage = 100.0 * cache_age / cache_interval
- return "", _("Cache generated %s ago, cache interval: %s, elapsed
cache lifespan: %s") % (
- age_human_readable(cache_age), age_human_readable(cache_interval),
percent_human_redable(percentage))
+
+ text = _("Cache generated %s ago, cache interval: %s") % \
+ (age_human_readable(cache_age), age_human_readable(cache_interval))
+
+ if cache_interval:
+ percentage = 100.0 * cache_age / cache_interval
+ text += _(", elapsed cache lifespan: %s") %
percent_human_redable(percentage)
+
+ return "", text
multisite_painters["svc_check_cache_info"] = {
"title" : _("Cached agent data"),