Module: check_mk
Branch: master
Commit: 979cd19e97b0ff473c23bd5918a5500ba9b3c7d4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=979cd19e97b0ff…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Sep 29 12:20:56 2017 +0200
5216 FIX Failed notification checking is now limited to 7 days
This change fixes a GUI (sidebar) rendering performance issue which
was caused by the check for failed notifications. For individual
admin users the GUI could be very slow because the core was searching
far in the past of the monitoring history.
The failed notification checking is now being limited by a configurable
"Failed notification horizon" which is set to 7 days be default. You can
configure this value according to your needs in the Global settings.
Change-Id: If372bc9560343432c00376a3f983ec1df68c0a33
---
.werks/5216 | 18 ++++++++++++++++++
web/htdocs/default_permissions.py | 8 ++++----
web/htdocs/notifications.py | 12 ++++++++++--
web/plugins/config/builtin.py | 2 ++
web/plugins/wato/globals_notification.py | 13 +++++++++++++
5 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/.werks/5216 b/.werks/5216
new file mode 100644
index 0000000..0c8a0bb
--- /dev/null
+++ b/.werks/5216
@@ -0,0 +1,18 @@
+Title: Failed notification checking is now limited to 7 days
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1506680272
+
+This change fixes a GUI (sidebar) rendering performance issue which
+was caused by the check for failed notifications. For individual
+admin users the GUI could be very slow because the core was searching
+far in the past of the monitoring history.
+
+The failed notification checking is now being limited by a configurable
+"Failed notification horizon" which is set to 7 days be default. You can
+configure this value according to your needs in the Global settings.
diff --git a/web/htdocs/default_permissions.py b/web/htdocs/default_permissions.py
index 4fe4b53..fe89f56 100644
--- a/web/htdocs/default_permissions.py
+++ b/web/htdocs/default_permissions.py
@@ -150,7 +150,7 @@ def load_plugins(force):
config.declare_permission("general.see_failed_notifications_24h",
_("See failed Notifications (last 24 hours)"),
- _("If check_mk is unable to notify users about problems, the site will warn
about this situation "
+ _("If Check_MK is unable to notify users about problems, the site will warn
about this situation "
"very visibly inside the UI (both in the Tactical Overview and the
Dashboard). This affects only "
"users with this permission. Users with this permission will only see
failed notifications "
"that occured within the last 24 hours."),
@@ -158,10 +158,10 @@ def load_plugins(force):
config.declare_permission("general.see_failed_notifications",
_("See failed Notifications (all)"),
- _("If check_mk is unable to notify users about problems, the site will warn
about this situation "
+ _("If Check_MK is unable to notify users about problems, the site will warn
about this situation "
"very visibly inside the UI (both in the Tactical Overview and the
Dashboard). This affects only "
- "users with this permission. Users with this permission will also see
failed notifications "
- "older than 24 hours."),
+ "users with this permission. Users with this permission will see failed
notifications between now "
+ "and the configured <a
href=\"wato.py?mode=edit_configvar&varname=failed_notification_horizon\">Failed
notification horizon</a>."),
[ "admin" ])
loaded_with_language = current_language
diff --git a/web/htdocs/notifications.py b/web/htdocs/notifications.py
index 65386e5..d6e217b 100644
--- a/web/htdocs/notifications.py
+++ b/web/htdocs/notifications.py
@@ -106,8 +106,14 @@ def load_failed_notifications(before=None, after=None,
stat_only=False, extra_he
query_filters.append("time <= %d" % before)
if after is not None:
query_filters.append("time >= %d" % after)
- if may_see_notifications and not
config.user.may("general.see_failed_notifications"):
- query_filters.append("time > %d" % (int(time.time()) - 86400))
+
+ if may_see_notifications:
+ if config.user.may("general.see_failed_notifications"):
+ horizon = config.failed_notification_horizon
+ else:
+ horizon = 86400
+
+ query_filters.append("time > %d" % (int(time.time()) - horizon))
query = ["GET log"]
if stat_only:
@@ -119,6 +125,8 @@ def load_failed_notifications(before=None, after=None,
stat_only=False, extra_he
query = "\n".join(query)
+ html.debug(query)
+
if extra_headers is not None:
query += extra_headers
diff --git a/web/plugins/config/builtin.py b/web/plugins/config/builtin.py
index 32e6963..e66a917 100644
--- a/web/plugins/config/builtin.py
+++ b/web/plugins/config/builtin.py
@@ -87,6 +87,8 @@ quicksearch_dropdown_limit = 80
# Quicksearch search order
quicksearch_search_order = [("h", "continue"), ("al",
"continue"), ("ad", "continue"), ("s",
"continue")]
+failed_notification_horizon = 7 * 60 * 60 * 24
+
# _ _ _ _
# | | (_)_ __ ___ (_) |_ ___
# | | | | '_ ` _ \| | __/ __|
diff --git a/web/plugins/wato/globals_notification.py
b/web/plugins/wato/globals_notification.py
index 3f8e3ef..abcaa76 100644
--- a/web/plugins/wato/globals_notification.py
+++ b/web/plugins/wato/globals_notification.py
@@ -150,3 +150,16 @@ register_configvar(group,
allow_reset = False,
)
+
+register_configvar(group,
+ "failed_notification_horizon",
+ Age(
+ title = _("Failed notification horizon"),
+ help = _("The tactical overview snapin is reporing about notifications that
could not be sent "
+ "by Check_MK. Users with the permission \"See failed
Notifications (all)\" get the number "
+ "of failed notification within the configured horizon."),
+ default_value = 60*60*24*7,
+ display = ["days"],
+ minvalue = 60*60*24,
+ ),
+ domain = "multisite")