Module: check_mk
Branch: master
Commit: f88eda79a20768f79dae7793c7d906463fa4a8a2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f88eda79a20768…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jun 16 17:07:10 2017 +0200
4758 FIX Fixed site status and master control snapin not displaying states of sites
The master control snapin was hiding sites with communication errors completely.
It is now displaying a box with the occured error message.
The site status snapin was showing the site, but displaying a site as "online"
while it was reported as "dead" by the livestatus connection. This appeared
when
an error was found in a query, for example when a queried table does not exist.
Change-Id: I44aa10019a7b78fa381bdb3ebac1719c4ab22576
---
.werks/4758 | 16 ++++++++++++++++
web/htdocs/sites.py | 21 +++++++++++++--------
web/plugins/sidebar/shipped.py | 15 +++++++++++++++
3 files changed, 44 insertions(+), 8 deletions(-)
diff --git a/.werks/4758 b/.werks/4758
new file mode 100644
index 0000000..500f81c
--- /dev/null
+++ b/.werks/4758
@@ -0,0 +1,16 @@
+Title: Fixed site status and master control snapin not displaying states of sites
+Level: 2
+Component: multisite
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1497625512
+
+The master control snapin was hiding sites with communication errors completely.
+It is now displaying a box with the occured error message.
+
+The site status snapin was showing the site, but displaying a site as "online"
+while it was reported as "dead" by the livestatus connection. This appeared
when
+an error was found in a query, for example when a queried table does not exist.
diff --git a/web/htdocs/sites.py b/web/htdocs/sites.py
index 3c22398..a216496 100644
--- a/web/htdocs/sites.py
+++ b/web/htdocs/sites.py
@@ -166,14 +166,9 @@ def _connect_multiple_sites():
})
_live.set_prepend_site(False)
- # Get exceptions in case of dead sites
- for site_id, deadinfo in _live.dead_sites().items():
- shs = deadinfo.get("status_host_state")
- _update_site_status(site_id, {
- "exception" : deadinfo["exception"],
- "status_host_state" : shs,
- "state" : _status_host_state_name(shs),
- })
+ # TODO(lm): Find a better way to make the Livestatus object trigger the update
+ # once self.deadsites is updated.
+ update_site_states_from_dead_sites()
def _get_enabled_and_disabled_sites():
@@ -189,6 +184,16 @@ def _get_enabled_and_disabled_sites():
return enabled_sites, disabled_sites
+def update_site_states_from_dead_sites():
+ # Get exceptions in case of dead sites
+ for site_id, deadinfo in _live.dead_sites().items():
+ status_host_state = deadinfo.get("status_host_state")
+ _update_site_status(site_id, {
+ "exception" : deadinfo["exception"],
+ "status_host_state" : status_host_state,
+ "state" : _status_host_state_name(status_host_state),
+ })
+
def _status_host_state_name(shs):
if shs == None:
diff --git a/web/plugins/sidebar/shipped.py b/web/plugins/sidebar/shipped.py
index 902f357..bf5c5ef 100644
--- a/web/plugins/sidebar/shipped.py
+++ b/web/plugins/sidebar/shipped.py
@@ -482,9 +482,13 @@ def render_sitestatus():
if config.is_multisite():
html.open_table(cellspacing=0, class_="sitestate")
+ sites.update_site_states_from_dead_sites()
+
for sitename, sitealias in config.sorted_sites():
site = config.site(sitename)
+
state = sites.state(sitename, {})
+
if state.get("state") == None:
state = "missing"
text = _("Missing site")
@@ -1239,6 +1243,17 @@ def render_master_control():
if not config.is_single_local_site():
html.end_foldable_container()
+ # Also show the dead sites
+ for site_id, site_status in sorted(sites.live().dead_sites().items()):
+ if not config.is_single_local_site():
+ sitealias = config.site(site_id)["alias"]
+ html.begin_foldable_container("master_control", site_id, True,
sitealias)
+
+ html.show_error(site_status["exception"])
+
+ if not config.is_single_local_site():
+ html.end_foldable_container()
+
sidebar_snapins["master_control"] = {
"title" : _("Master Control"),