Module: check_mk
Branch: master
Commit: 81a356aa0379cf6ebd1782aa36a97c17bb28d9d4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=81a356aa0379cf…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri May 19 10:30:02 2017 +0200
4729 Add service cache information to action menu entry
Services that are based on cached agent data can not be rescheduled
through the GUI. In case of such a service a message is displayed.
This message is now showing information about the age of the cache
like this:
Cache generated 67 m ago, cache interval: 30.0 s, elapsed cache lifespan: 13527.6%
Change-Id: I1a5f5327e0afb58b9a9230aeaedbff6ee08ef8e9
---
.werks/4729 | 15 +++++++++++++++
web/htdocs/pages.css | 1 +
web/plugins/icons/builtin.py | 7 +++++--
web/plugins/views/painters.py | 27 +++++++++++++++------------
4 files changed, 36 insertions(+), 14 deletions(-)
diff --git a/.werks/4729 b/.werks/4729
new file mode 100644
index 0000000..3dd7a70
--- /dev/null
+++ b/.werks/4729
@@ -0,0 +1,15 @@
+Title: Add service cache information to action menu entry
+Level: 1
+Component: multisite
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1495182507
+Class: feature
+
+Services that are based on cached agent data can not be rescheduled
+through the GUI. In case of such a service a message is displayed.
+This message is now showing information about the age of the cache
+like this:
+
+Cache generated 67 m ago, cache interval: 30.0 s, elapsed cache lifespan: 13527.6%
diff --git a/web/htdocs/pages.css b/web/htdocs/pages.css
index da71d05..beb8e8d 100644
--- a/web/htdocs/pages.css
+++ b/web/htdocs/pages.css
@@ -1121,6 +1121,7 @@ body.main .popup_menu {
border-color: #9bc #367 #367 #9bc;
box-shadow: 0.5px 0.5px 16px #467;
border-radius: 5px;
+ white-space: normal;
}
body.main .popup_menu img {
diff --git a/web/plugins/icons/builtin.py b/web/plugins/icons/builtin.py
index 42e2b30..a4f11ba 100644
--- a/web/plugins/icons/builtin.py
+++ b/web/plugins/icons/builtin.py
@@ -133,7 +133,10 @@ multisite_icons_and_actions['icon_image'] = {
def paint_reschedule(what, row, tags, host_custom_vars):
if what == "service" and row["service_cached_at"]:
- return "cannot_reschedule", _("This service is based on cached
agent data and cannot be rescheduled"), None
+ output = _("This service is based on cached agent data and cannot be
rescheduled.")
+ output += " %s" % render_cache_info(what, row)
+
+ return "cannot_reschedule", output, None
# Reschedule button
if row[what + "_check_type"] == 2:
@@ -164,7 +167,7 @@ def paint_reschedule(what, row, tags, host_custom_vars):
multisite_icons_and_actions['reschedule'] = {
'columns': [ 'check_type', 'active_checks_enabled',
'check_command' ],
- 'service_columns': [ 'cached_at' ],
+ 'service_columns': [ 'cached_at', 'cache_interval' ],
'paint': paint_reschedule,
'toplevel': False,
}
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index 994e610..a2c98f8 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -791,22 +791,25 @@ multisite_painters["svc_check_age"] = {
"paint" : lambda row: paint_checked("service", row),
}
+def render_cache_info(what, row):
+ cached_at = row["service_cached_at"]
+ cache_interval = row["service_cache_interval"]
+ cache_age = time.time() - cached_at
+
+ 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
+
def paint_cache_info(row):
if not row["service_cached_at"]:
return "", ""
else:
- cached_at = row["service_cached_at"]
- cache_interval = row["service_cache_interval"]
- cache_age = time.time() - cached_at
-
- 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
+ return "", render_cache_info("service", row)
multisite_painters["svc_check_cache_info"] = {
"title" : _("Cached agent data"),