Module: check_mk
Branch: master
Commit: 0fd195170c966a7e152948508601625b5ceef05d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0fd195170c966a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Feb 9 11:43:03 2017 +0100
8703 Livestatus proxy: Can now connect via unix socket to the local site
The livestatus proxy daemon can now be configured also for the local site.
Even when this is the local site, this makes sense, because the proxy daemon
can now also multiplex connections and cache queries for the local site.
Change-Id: I05b5a24042f16a9b8bb4dc2557cf728efaefb217
---
web/htdocs/config.py | 11 +++++++++--
web/htdocs/wato.py | 23 ++++++++++++++++++-----
web/htdocs/watolib.py | 8 +++++++-
3 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/web/htdocs/config.py b/web/htdocs/config.py
index cdd4f2f..3c3d631 100644
--- a/web/htdocs/config.py
+++ b/web/htdocs/config.py
@@ -666,11 +666,18 @@ def site(site_id):
return s
-# TODO: Does this work when using liveproxyd locally?
def site_is_local(site_name):
s = sites.get(site_name, {})
sock = s.get("socket")
- return not sock or sock == "unix:" + cmk.paths.livestatus_unix_socket
+
+ if not sock or sock == "unix:" + cmk.paths.livestatus_unix_socket:
+ return True
+
+ if type(s["socket"]) == tuple and s["socket"][0] ==
"proxy" \
+ and s["socket"][1]["socket"] is None:
+ return True
+
+ return False
def default_site():
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 10aeedd..17f76a8 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -9388,14 +9388,17 @@ def mode_edit_site(phase):
TextAscii(label = _("Host:"), allow_empty = False, size=15),
Integer(label = _("Port:"), minvalue=1, maxvalue=65535,
default_value=6557),
])
+
conn_choices = [
- ( None, _("Connect to the local site") ),
- ( "tcp", _("Connect via TCP"), vs_tcp_port),
- ( "unix", _("Connect via UNIX socket"), TextAscii(
+ (None, _("Connect to the local site")),
+ ("tcp", _("Connect via TCP"), vs_tcp_port),
+ ("unix", _("Connect via UNIX socket"), TextAscii(
label = _("Path:"),
size = 40,
- allow_empty = False)),
+ allow_empty = False)
+ ),
]
+
if config.liveproxyd_enabled:
conn_choices[2:2] = [
( "proxy", _("Use Livestatus Proxy-Daemon"),
@@ -9403,7 +9406,17 @@ def mode_edit_site(phase):
optional_keys = False,
columns = 1,
elements = [
- ( "socket", vs_tcp_port ),
+ ("socket", Alternative(
+ title = _("Connect to"),
+ style = "dropdown",
+ elements = [
+ FixedValue(None,
+ title = _("Connect to the local site"),
+ totext = "",
+ ),
+ vs_tcp_port,
+ ],
+ )),
( "channels",
Integer(
title = _("Number of channels to keep open"),
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index 9ee642b..083aa4a 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -3333,7 +3333,13 @@ def create_nagvis_backends(sites):
# Handle special data format of livestatus proxy config
if type(site['socket']) == tuple:
- socket = 'tcp:%s:%d' % site['socket'][1]['socket']
+ if type(site['socket'][1]['socket']) == tuple:
+ socket = 'tcp:%s:%d' %
site['socket'][1]['socket']
+ elif site['socket'][1]['socket'] is None:
+ socket = 'unix:%s' % cmk.paths.livestatus_unix_socket
+ else:
+ raise NotImplementedError()
+
else:
socket = site['socket']