Module: check_mk
Branch: master
Commit: 16434f8cd4af2962144877dd66d6f2ce0175750f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=16434f8cd4af29…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jun 21 17:33:14 2017 +0200
Started adding log level config for liveproxyd
Change-Id: I06b88acbb3f2cf97be91fc9f6b04ea64d27ab035
---
web/htdocs/watolib.py | 96 +++++++++++++++++++++++++++++++++++++++------------
1 file changed, 74 insertions(+), 22 deletions(-)
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index 13d53a5..8bf310c 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -402,6 +402,64 @@ class ConfigDomainEventConsole(ConfigDomain):
+
+class ConfigDomainLiveproxy(ConfigDomain):
+ needs_sync = False
+ needs_activation = False
+ ident = "liveproxyd"
+ in_global_settings = True
+
+
+ @classmethod
+ def enabled(self):
+ return config.liveproxyd_enabled
+
+
+ def config_file(self, site_specific):
+ return cmk.paths.default_config_dir + "/liveproxyd.mk"
+
+
+ # The load() and save() method only deal with the "global settings" and
not
+ # the "sites" option that is saved by editing the sites. This must be
merged
+ def load(self):
+ cfg = self.load_full_liveproxyd_config()
+
+ try:
+ del cfg["sites"]
+ except KeyError:
+ pass
+
+ return cfg
+
+
+ def save(self, settings, site_specific=False):
+ if site_specific:
+ raise NotImplementedError()
+
+ cfg = self.load_full_liveproxyd_config()
+ cfg.update(settings)
+ super(ConfigDomainLiveproxy, self).save(cfg, site_specific=site_specific)
+
+ self.activate()
+
+
+ def load_full_liveproxyd_config(self):
+ return store.load_mk_file(self.config_file(site_specific=False),
{"sites": {}})
+
+
+ def activate(self):
+ log_audit(None, "liveproxyd-activate",
+ _("Activating changes of liveproxyd configuration"))
+ try:
+ pidfile = cmk.paths.livestatus_unix_socket + "proxyd.pid"
+ pid = int(file(pidfile).read().strip())
+ os.kill(pid, 10)
+ except Exception, e:
+ log_exception()
+ html.show_error(_("Warning: cannot reload Livestatus Proxy-Daemon:
%s") % e)
+
+
+
class ConfigDomainCACertificates(ConfigDomain):
needs_sync = True
needs_activation = True
@@ -3651,7 +3709,6 @@ class SiteManagement(object):
return {}
-
@staticmethod
def save_sites(sites, activate=True):
make_nagios_directory(multisite_dir)
@@ -3676,6 +3733,21 @@ class SiteManagement(object):
@staticmethod
+ def save_liveproxyd_config(sites):
+ config_domain = ConfigDomainLiveproxy()
+ cfg = config_domain.load()
+
+ site_cfg = {}
+ for siteid, siteconf in sites.items():
+ s = siteconf.get("socket")
+ if type(s) == tuple and s[0] == "proxy":
+ site_cfg[siteid] = s[1]
+
+ cfg["sites"] = site_cfg
+ config_domain.save(cfg)
+
+
+ @staticmethod
def delete_site(site_id):
all_sites = SiteManagement.load_sites()
if site_id not in all_sites:
@@ -3703,30 +3775,10 @@ class SiteManagement(object):
SiteManagement.save_sites(all_sites)
clear_site_replication_status(site_id)
add_change("edit-sites", _("Deleted site %s") %
html.render_tt(site_id),
- domains=[ConfigDomainGUI], sites=[default_site()])
+ domains=[ConfigDomainGUI,ConfigDomainLiveproxy],
sites=[default_site()])
return None
- @staticmethod
- def save_liveproxyd_config(sites):
- path = cmk.paths.default_config_dir + "/liveproxyd.mk"
-
- conf = {}
- for siteid, siteconf in sites.items():
- s = siteconf.get("socket")
- if type(s) == tuple and s[0] == "proxy":
- conf[siteid] = s[1]
-
- store.save_to_mk_file(path, "sites", conf)
-
- try:
- pidfile = cmk.paths.livestatus_unix_socket + "proxyd.pid"
- pid = int(file(pidfile).read().strip())
- os.kill(pid, 10)
- except Exception, e:
- html.show_error(_("Warning: cannot reload Livestatus Proxy-Daemon:
%s") % e)
-
-
def get_login_secret(create_on_demand = False):
path = var_dir + "automation_secret.mk"