Module: check_mk
Branch: master
Commit: da1a24323ec31d7de3d9811586af2b974fd13c2a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=da1a24323ec31d…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Feb 8 18:09:41 2016 +0100
Fix broken PNP graphs on CEE with Nagios core
---
web/htdocs/metrics.py | 30 +++++++++++++++++++++++-------
web/plugins/icons/builtin.py | 4 ++--
web/plugins/views/painters.py | 2 +-
3 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index 7927856..b6fd6ac 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -1257,14 +1257,30 @@ def render_graph_pnp(graph_template, translated_metrics):
# '----------------------------------------------------------------------'
-def cmk_graphs_possible():
+def cmk_graphs_possible(site_id = None):
try:
- render_graph_html
- return not config.force_pnp_graphing and browser_supports_canvas() and not
html.is_mobile()
+ render_graph_html # Will throw exception if missing
+ return not config.force_pnp_graphing \
+ and browser_supports_canvas() \
+ and site_is_running_cmc(site_id) \
+ and not html.is_mobile()
except:
return False
+# If site_id is None then we return True if at least
+# one site is running CMC
+def site_is_running_cmc(site_id):
+ if site_id:
+ return site_id in html.site_status \
+ and
html.site_status[site_id].get("program_version").startswith("Check_MK")
+ else:
+ for status in html.site_status.values():
+ if status.get("program_version").startswith("Check_MK"):
+ return True
+ return False
+
+
def browser_supports_canvas():
user_agent = html.get_user_agent()
if 'MSIE' in user_agent:
@@ -1327,14 +1343,14 @@ def get_graph_template_by_source(graph_templates, source):
# This page is called for the popup of the graph icon of hosts/services.
def page_host_service_graph_popup():
- site = html.var('site')
+ site_id = html.var('site')
host_name = html.var('host_name')
service_description = html.var('service')
- if cmk_graphs_possible():
- host_service_graph_popup_cmk(site, host_name, service_description)
+ if cmk_graphs_possible(site_id):
+ host_service_graph_popup_cmk(site_id, host_name, service_description)
else:
- host_service_graph_popup_pnp(site, host_name, service_description)
+ host_service_graph_popup_pnp(site_id, host_name, service_description)
diff --git a/web/plugins/icons/builtin.py b/web/plugins/icons/builtin.py
index 7ea856d..9962507 100644
--- a/web/plugins/icons/builtin.py
+++ b/web/plugins/icons/builtin.py
@@ -344,7 +344,7 @@ def pnp_graph_icon_link(row, what):
if 'X' not in html.display_options:
return ""
- if not metrics.cmk_graphs_possible():
+ if not metrics.cmk_graphs_possible(row["site"]):
return pnp_url(row, what)
else:
return new_graphing_url(row, what)
@@ -353,7 +353,7 @@ def pnp_graph_icon_link(row, what):
def pnp_icon(row, what):
url = pnp_graph_icon_link(row, what)
- if not metrics.cmk_graphs_possible():
+ if not metrics.cmk_graphs_possible(row["site"]):
# Directly ask PNP for all data, don't try to use the new graph fetching
mechanism
# to keep the number of single requests low
hover_content_func = 'fetch_pnp_hover_contents(\'%s\')' %
pnp_popup_url(row, what)
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index 221fc93..d87d596 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -917,7 +917,7 @@ multisite_painters["svc_group_memberlist"] = {
}
def paint_time_graph(row):
- if metrics.cmk_graphs_possible():
+ if metrics.cmk_graphs_possible(row["site"]):
return paint_time_graph_cmk(row)
else:
return paint_time_graph_pnp(row)