Module: check_mk
Branch: master
Commit: b6681ac92dd35f973fce539bd380874a30908d91
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b6681ac92dd35f…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Oct 20 14:44:15 2017 +0200
Overhauled ListColumn handling.
The previous isEmpty() and makeContains() methods were not flexible enough
to handle upcoming features like regexp matching, so they were replaced by a
more general mechanism: Every ListColumn now knows how to calculate their
contents as a stream of strings. As a first approximation, we simply use a
vector for this stream, we can later improve performance by replacing that
with a range or iterators.
Several bugs regarding AuthUser were fixed on the way: Often the AuthUser
was just used for rendering a column, but omitted for filtering.
Change-Id: I773150c8e6e7f5c29951d762314b56eb504b766c
---
livestatus/src/CommentColumn.cc | 39 +++++--------------
livestatus/src/CommentColumn.h | 10 ++---
livestatus/src/ContactGroupsColumn.cc | 51 ++++++------------------
livestatus/src/ContactGroupsColumn.h | 28 +++-----------
livestatus/src/ContactGroupsMemberColumn.cc | 17 ++++++--
livestatus/src/ContactGroupsMemberColumn.h | 19 +++++----
livestatus/src/ContactsColumn.cc | 60 -----------------------------
livestatus/src/ContactsColumn.h | 55 --------------------------
livestatus/src/DowntimeColumn.cc | 35 ++++-------------
livestatus/src/DowntimeColumn.h | 8 ++--
livestatus/src/HostContactsColumn.cc | 16 ++++++--
livestatus/src/HostContactsColumn.h | 19 +++++----
livestatus/src/HostGroupsColumn.cc | 49 ++++++-----------------
livestatus/src/HostGroupsColumn.h | 11 ++----
livestatus/src/ListColumn.cc | 5 +--
livestatus/src/ListColumn.h | 19 +++++----
livestatus/src/ListFilter.cc | 29 +++++++-------
livestatus/src/ListFilter.h | 9 +----
livestatus/src/Makefile.am | 1 -
livestatus/src/ServiceContactsColumn.cc | 16 ++++++--
livestatus/src/ServiceContactsColumn.h | 19 +++++----
livestatus/src/ServiceGroupsColumn.cc | 50 ++++++------------------
livestatus/src/ServiceGroupsColumn.h | 11 ++----
livestatus/src/TableEventConsole.cc | 1 +
livestatus/src/TableEventConsole.h | 31 +++------------
livestatus/src/TableHosts.cc | 2 +-
livestatus/src/TableServices.cc | 2 +-
27 files changed, 182 insertions(+), 430 deletions(-)
Diff: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=b6681ac92d…
Module: check_mk
Branch: master
Commit: 770ce6172598994a608be2b4584f2c2c2f2d5688
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=770ce617259899…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Mon Oct 23 08:26:02 2017 +0200
Make a more secure check for existing chroot user
Only match the exact username within word boundaries. Prevents
accidental matches with substrings especially with our two-character
usernames that can match almost whatever in /etc/passwd.
Change-Id: I2053e484462f7a6de1891f0076003658dbc3ec46
---
agents/windows/make-chroot | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/agents/windows/make-chroot b/agents/windows/make-chroot
index 1236f0c..df319a9 100755
--- a/agents/windows/make-chroot
+++ b/agents/windows/make-chroot
@@ -148,8 +148,9 @@ if [ ! -h $CHROOT_PATH/usr/bin/python ] ; then
ln -sf python2.7 $CHROOT_PATH/usr/bin/python
fi
-# Add user for building windows agent without root privileges
-if ! grep -q $SUDO_USER "$CHROOT_PATH/etc/passwd" ; then
+# Add user for building windows agent without root privileges.
+# Check that user does not exist before since SUDO_USER may be root, as well.
+if ! grep -q "\<${SUDO_USER}\>" "$CHROOT_PATH/etc/passwd" ; then
./do-chroot "useradd -lmo -u $(id -u $SUDO_USER) -s /bin/bash $SUDO_USER"
fi
Module: check_mk
Branch: master
Commit: 0309afc0c256986a1a0425fc2032b676cddca8d7
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0309afc0c25698…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed May 31 08:14:19 2017 +0200
4753 Inactive browser windows/tabs are not updated until focused again
This change should be a performance improvement to reduce the load of the
sites webserver.
While a Check_MK GUI page is opened in the browser several parts are updating
themselfs in the background, for example sidebar snapins, dashlets and views.
A lot of users open several instances of the GUI in different browser tabs
(or windows) and leave them inactive in the background. They open different
tabs and keep the others in background or even leave their computer running
and just lock their user session.
In such situation the browser keeps updating the page elements even when no
one looks at the information.
We have now implemented a mechanism to detect whether or not a page is
visible or hidden to the user. In later case the updates are stopped until
the user opens the page again, then the updates are immediately done.
This change should be seamless for the user in most cases because the updates
are immediately done when the user focuses the page again, but it might happen
that you see a "grayed out" page for a short time. This grayed out page
visualizes that the information is outdated. If you should see this for several
seconds there is something wrong. But you can always tell your browser to
reload the page which should resolve this.
Change-Id: I6a6f2483aa9fb440f52cbf12c2c5f04ae732c4bf
---
.werks/4753 | 33 +++++++++++++++++
web/htdocs/check_mk.css | 11 ++++++
web/htdocs/htmllib.py | 1 +
web/htdocs/js/checkmk.js | 91 ++++++++++++++++++++++++++++++++++++++++++++++
web/htdocs/js/dashboard.js | 7 ++++
web/htdocs/js/sidebar.js | 7 ++++
6 files changed, 150 insertions(+)
diff --git a/.werks/4753 b/.werks/4753
new file mode 100644
index 0000000..141dc47
--- /dev/null
+++ b/.werks/4753
@@ -0,0 +1,33 @@
+Title: Inactive browser windows/tabs are not updated until focused again
+Level: 2
+Component: multisite
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1496242418
+Class: feature
+
+This change should be a performance improvement to reduce the load of the
+sites webserver.
+
+While a Check_MK GUI page is opened in the browser several parts are updating
+themselfs in the background, for example sidebar snapins, dashlets and views.
+
+A lot of users open several instances of the GUI in different browser tabs
+(or windows) and leave them inactive in the background. They open different
+tabs and keep the others in background or even leave their computer running
+and just lock their user session.
+
+In such situation the browser keeps updating the page elements even when no
+one looks at the information.
+
+We have now implemented a mechanism to detect whether or not a page is
+visible or hidden to the user. In later case the updates are stopped until
+the user opens the page again, then the updates are immediately done.
+
+This change should be seamless for the user in most cases because the updates
+are immediately done when the user focuses the page again, but it might happen
+that you see a "grayed out" page for a short time. This grayed out page
+visualizes that the information is outdated. If you should see this for several
+seconds there is something wrong. But you can always tell your browser to
+reload the page which should resolve this.
diff --git a/web/htdocs/check_mk.css b/web/htdocs/check_mk.css
index bfa3ed4..fced2d8 100644
--- a/web/htdocs/check_mk.css
+++ b/web/htdocs/check_mk.css
@@ -67,6 +67,17 @@ body a, body a:link, body a:visited {
color: white;
}
+body.hidden:after {
+ content: "";
+ background-color: rgba(0, 0, 0, .5);
+ display: block;
+ width: 100%;
+ height: 100%;
+ position: absolute;
+ top: 0;
+ left: 0;
+}
+
/* Default font size for the complete Multisite GUI */
button, input, td, th, select, textarea {
font-size: 9pt;
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index d9c8e79..f5f3cb1 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -2001,6 +2001,7 @@ class html(HTMLGenerator, RequestHandler):
json.dumps(self.keybindings))
if self.final_javascript_code:
self.javascript(self.final_javascript_code)
+ self.javascript("initialize_visibility_detection();")
self.close_body()
self.close_html()
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 1790116..afcbab8 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -1149,6 +1149,13 @@ function stop_reload_timer()
function do_reload(url)
{
+ // Reschedule the reload in case the browser window / tab is not visible
+ // for the user. Retry after short time.
+ if (!is_window_active()) {
+ setTimeout(function(){ do_reload(url); }, 250);
+ return;
+ }
+
// Nicht mehr die ganze Seite neu laden, wenn es ein DIV "data_container" gibt.
// In dem Fall wird die aktuelle URL aus "window.location.href" geholt, für den Refresh
// modifiziert, der Inhalt neu geholt und in das DIV geschrieben.
@@ -3705,3 +3712,87 @@ function hide_job_detail_msg()
if (msg)
msg.parentNode.removeChild(msg);
}
+
+//#.
+//# .--Visibility----------------------------------------------------------.
+//# | __ ___ _ _ _ _ _ _ |
+//# | \ \ / (_)___(_) |__ (_) (_) |_ _ _ |
+//# | \ \ / /| / __| | '_ \| | | | __| | | | |
+//# | \ V / | \__ \ | |_) | | | | |_| |_| | |
+//# | \_/ |_|___/_|_.__/|_|_|_|\__|\__, | |
+//# | |___/ |
+//# +----------------------------------------------------------------------+
+//# | Code for detecting the visibility of the current browser window/tab |
+//# '----------------------------------------------------------------------'
+
+var g_visibility_detection_enabled = true;
+
+// Whether or not the current browser window/tab is visible to the user
+function is_window_active()
+{
+ return !has_class(document.body, "hidden");
+}
+
+function initialize_visibility_detection()
+{
+ var hidden_attr_name = "hidden";
+
+ // Standards:
+ if (hidden_attr_name in document)
+ document.addEventListener("visibilitychange", on_visibility_change);
+ else if ((hidden_attr_name = "mozHidden") in document)
+ document.addEventListener("mozvisibilitychange", on_visibility_change);
+ else if ((hidden_attr_name = "webkitHidden") in document)
+ document.addEventListener("webkitvisibilitychange", on_visibility_change);
+ else if ((hidden_attr_name = "msHidden") in document)
+ document.addEventListener("msvisibilitychange", on_visibility_change);
+
+ // This feature will not support IE 9 and lower or other incompatible
+ // browsers. By enabling the code below we could add the support, but
+ // we need to be sure that these assignments don't conflict with other
+ // already registered event handlers.
+ //else if ("onfocusin" in document) {
+ // // IE 9 and lower:
+ // document.onfocusin = document.onfocusout = onchange;
+ //}
+ //else {
+ // // All others:
+ // window.onpageshow = window.onpagehide
+ // = window.onfocus = window.onblur = onchange;
+ //}
+
+ window.addEventListener("beforeunload", disable_visibility_detection);
+
+ function disable_visibility_detection(evt) {
+ g_visibility_detection_enabled = false;
+ }
+
+ function on_visibility_change(evt) {
+ var v = "visible", h = "hidden",
+ evtMap = {
+ focus:v, focusin:v, pageshow:v, blur:h, focusout:h, pagehide:h
+ };
+
+ if (!g_visibility_detection_enabled)
+ return;
+
+ remove_class(document.body, "visible");
+ remove_class(document.body, "hidden");
+
+ evt = evt || window.event;
+
+ var new_class;
+ if (evt.type in evtMap) {
+ new_class = evtMap[evt.type];
+ } else {
+ new_class = this[hidden_attr_name] ? "hidden" : "visible";
+ }
+
+ //console.log([evt.type, new_class, document.hidden, location.href]);
+ add_class(document.body, new_class);
+ }
+
+ // set the initial state (but only if browser supports the Page Visibility API)
+ if (document[hidden_attr_name] !== undefined)
+ on_visibility_change({type: document[hidden_attr_name] ? "blur" : "focus"});
+}
diff --git a/web/htdocs/js/dashboard.js b/web/htdocs/js/dashboard.js
index 4b7cb11..658442b 100644
--- a/web/htdocs/js/dashboard.js
+++ b/web/htdocs/js/dashboard.js
@@ -312,6 +312,13 @@ function calculate_dashboard() {
}
function dashboard_scheduler(initial) {
+ // Stop reload of the dashlets in case the browser window / tab is not visible
+ // for the user. Retry after short time.
+ if (!is_window_active()) {
+ setTimeout(function(){ dashboard_scheduler(initial); }, 250);
+ return;
+ }
+
var timestamp = Date.parse(new Date()) / 1000;
var newcontent = "";
for(var i = 0; i < refresh_dashlets.length; i++) {
diff --git a/web/htdocs/js/sidebar.js b/web/htdocs/js/sidebar.js
index eaab460..5882a8c 100644
--- a/web/htdocs/js/sidebar.js
+++ b/web/htdocs/js/sidebar.js
@@ -694,6 +694,13 @@ function sidebar_scheduler() {
else
g_seconds_to_update -= 1;
+ // Stop reload of the snapins in case the browser window / tab is not visible
+ // for the user. Retry after short time.
+ if (!is_window_active()) {
+ setTimeout(function(){ sidebar_scheduler(); }, 250);
+ return;
+ }
+
var newcontent = "";
var to_be_updated = [];
Module: check_mk
Branch: master
Commit: 9b9e72c3a966658d5a9ac9f1ee3dc06d3744ff30
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9b9e72c3a96665…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Oct 20 13:24:40 2017 +0200
Cleanup special case in notification logging: Use LOG core command for nagios too
Change-Id: I0c2a70a08cae904a47c8cdf59860f457dc9f03cc
---
cmk_base/notify.py | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/cmk_base/notify.py b/cmk_base/notify.py
index 95035de..dd7955b 100644
--- a/cmk_base/notify.py
+++ b/cmk_base/notify.py
@@ -1808,13 +1808,5 @@ def core_notification_log(plugin, plugin_context):
log_message = "%s NOTIFICATION: %s;%s;%s;%s;%s" % (
what, contact, spec, state, plugin or "plain email", output)
- if config.monitoring_core == "cmc":
- livestatus_send_command("LOG;" + log_message.encode("utf-8"))
- else:
- # Nagios and friends do not support logging via an
- # external command. We write the files into a help file
- # in var/check_mk/notify. If the users likes he can
- # replace that file with a symbolic link to the nagios
- # log file. But note: Nagios logging might not atomic.
- file(notification_core_log, "a").write("[%d] %s\n" % (time.time(), log_message.encode("utf-8")))
+ livestatus_send_command("LOG;" + log_message.encode("utf-8"))