Module: check_mk
Branch: master
Commit: 408a0967c56f1bc052cba0bd2e1cfe9e5e8a1d44
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=408a0967c56f1b…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Feb 23 12:19:18 2012 +0100
Do buffering in HTML creation per default
This greatly reduces network traffic, esp. via HTTPS
You can deactivate this by setting
buffered_http_stream = False in multisite.mk
---
ChangeLog | 1 +
web/htdocs/config.py | 3 +++
web/htdocs/htmllib.py | 9 ++++++++-
web/htdocs/index.py | 1 +
web/plugins/wato/check_mk_configuration.py | 12 ++++++++++++
5 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 361c05f..92a90a5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -77,6 +77,7 @@
* Retry livestatus connect until timeout is used up. This avoids
error messages when the core is being restarted
* Events view now shows icon and text for "flapping" events
+ * Use buffer for HTML creation (this speeds up esp. HTTPS a lot)
Livestatus:
* Add missing column check_freshness to services table
diff --git a/web/htdocs/config.py b/web/htdocs/config.py
index 8273b6e..3677e31 100644
--- a/web/htdocs/config.py
+++ b/web/htdocs/config.py
@@ -580,6 +580,9 @@ auth_type = 'basic'
# always all buttons to be shown
context_buttons_to_show = 5
+# Buffering of HTML output stream
+buffered_http_stream = True
+
# __ ___ _____ ___
# \ \ / / \|_ _/ _ \
# \ \ /\ / / _ \ | || | | |
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 807f7f0..f7de478 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -173,6 +173,10 @@ class html:
self.form_vars = []
self.context_buttons_open = False
self.mobile = False
+ self.buffering = True
+
+ def set_buffering(self, b):
+ self.buffering = b
def plugin_stylesheets(self):
global plugin_stylesheets
@@ -199,7 +203,10 @@ class html:
def write(self, text):
if type(text) == unicode:
text = text.encode("utf-8")
- self.req.write(text)
+ if self.buffering:
+ self.req.write(text, 0)
+ else:
+ self.req.write(text)
def heading(self, text):
self.write("<h2>%s</h2>\n" % text)
diff --git a/web/htdocs/index.py b/web/htdocs/index.py
index 42e7c03..8aadb0b 100644
--- a/web/htdocs/index.py
+++ b/web/htdocs/index.py
@@ -199,6 +199,7 @@ def handler(req, profiling = True):
config.load_config() # load multisite.mk
if html.var("debug"): # Debug flag may be set via URL
config.debug = True
+ html.set_buffering(config.buffered_http_stream)
# profiling can be enabled in multisite.mk
if profiling and config.profile:
diff --git a/web/plugins/wato/check_mk_configuration.py
b/web/plugins/wato/check_mk_configuration.py
index f1c46c2..fc52c27 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -61,6 +61,18 @@ register_configvar(group,
domain = "multisite")
register_configvar(group,
+ "buffered_http_stream",
+ Checkbox(title = _("Buffered HTTP stream"),
+ label = _("enable buffering"),
+ help = _("When buffering the HTTP stream is enabled, then Multisite
"
+ "will not send single TCP segments for each particle of HTML
"
+ "output but try to make larger segments. This saves bandwidth
"
+ "especially when using HTTPS. On the backside there might be
"
+ "a higher latency for the beginning of pages being
displayed."),
+ default_value = True),
+ domain = "multisite")
+
+register_configvar(group,
"show_livestatus_errors",
Checkbox(title = _("Show MK Livestatus error messages"),
label = _("show errors"),