Module: check_mk
Branch: master
Commit: cb4c50bab878f02432de146c8e6b7b04ca1584de
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cb4c50bab878f0…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Mar 17 10:10:58 2017 +0100
4503 FIX Graph designer: Show warnings when all or single sites use incompatible cores
Change-Id: Ifaf94126a44773334e17e2ad3c2179a6c3af1d7f
---
.werks/4503 | 10 ++++++++++
web/htdocs/sites.py | 30 ++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/.werks/4503 b/.werks/4503
new file mode 100644
index 0000000..ced4001
--- /dev/null
+++ b/.werks/4503
@@ -0,0 +1,10 @@
+Title: Graph designer: Show warnings when all or single sites use incompatible cores
+Level: 1
+Component: metrics
+Compatible: compat
+Edition: cee
+Version: 1.5.0i1
+Date: 1489741823
+Class: fix
+
+
diff --git a/web/htdocs/sites.py b/web/htdocs/sites.py
index 003cd7d..3c22398 100644
--- a/web/htdocs/sites.py
+++ b/web/htdocs/sites.py
@@ -72,6 +72,36 @@ def disconnect():
_site_status = None
+def sites_using_foreign_cores():
+ site_ids = []
+ for site_id, core in cores_by_site().items():
+ if core not in [ "cmc", None ]:
+ site_ids.append(site_id)
+
+ return sorted(site_ids)
+
+
+def all_sites_use_foreign_cores():
+ for site_id, core in cores_by_site().items():
+ if core == "cmc":
+ return False
+
+ return True
+
+
+def cores_by_site():
+ cores = {}
+ for site_id, site_state in states().items():
+ # Offline sites don't provide core info. Assume CMC is this case
+ if site_state["state"] == "dead":
+ state = "cmc"
+ else:
+ state = site_state.get("core")
+
+ cores[site_id] = state
+
+ return cores
+
#.
# .--Internal------------------------------------------------------------.
# | ___ _ _ |