Module: check_mk
Branch: master
Commit: ba9b0073680893f742cef9cea7a450a027a54cc1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ba9b0073680893…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Mar 27 10:45:06 2015 +0100
Hover graph now also works for hosts
---
web/htdocs/metrics.py | 43 ++++++++++++++++++++++++++----------------
web/plugins/icons/builtin.py | 4 ++--
2 files changed, 29 insertions(+), 18 deletions(-)
diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index 0f12db9..7065034 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -944,22 +944,36 @@ def page_show_graph():
# FIXME HACK TODO We don't have the current perfata and check command
# here, but we only need it till metrics.render_svc_time_graph() does
# not need these information anymore.
- query = "GET services\n" \
- "Filter: host_name = %s\n" \
- "Filter: service_description = %s\n" \
- "Columns: perf_data check_command\n" % (host_name, service)
+ if service == "_HOST_":
+ query = "GET hosts\n" \
+ "Filter: host_name = %s\n" \
+ "Columns: perf_data check_command\n" % host_name
+
+ else:
+ query = "GET services\n" \
+ "Filter: host_name = %s\n" \
+ "Filter: service_description = %s\n" \
+ "Columns: perf_data check_command\n" % (host_name, service)
html.live.set_only_sites([site])
data = html.live.query_row(query)
html.live.set_only_sites(None)
- row = {
- 'site' : site,
- 'host_name' : host_name,
- 'service_description' : service,
- 'service_perf_data' : data[0],
- 'service_check_command' : data[1],
- }
+ if service == "_HOST_":
+ row = {
+ 'site' : site,
+ 'host_name' : host_name,
+ 'host_perf_data' : data[0],
+ 'host_check_command' : data[1],
+ }
+ else:
+ row = {
+ 'site' : site,
+ 'host_name' : host_name,
+ 'service_description' : service,
+ 'service_perf_data' : data[0],
+ 'service_check_command' : data[1],
+ }
# now try to render the graph with our graphing. If it is not possible,
# add JS code to let browser fetch the PNP graph
@@ -968,7 +982,7 @@ def page_show_graph():
end_time = time.time()
start_time = end_time - 8 * 3600
- htmlcode = render_svc_time_graph(row, start_time, end_time, size=(30, 10),
show_legend=False)
+ htmlcode = render_time_graph(row, start_time, end_time, size=(30, 10),
show_legend=False, graph_id_prefix="hover")
if htmlcode:
html.write(htmlcode)
return
@@ -979,10 +993,7 @@ def page_show_graph():
# Fallback to PNP graph rendering
host = pnp_cleanup(host_name)
- if not service:
- svc = "_HOST_"
- else:
- svc = pnp_cleanup(service)
+ svc = pnp_cleanup(service)
site = html.site_status[site]["site"]
if html.mobile:
url = site["url_prefix"] +
("pnp4nagios/index.php?kohana_uri=/mobile/popup/%s/%s" % \
diff --git a/web/plugins/icons/builtin.py b/web/plugins/icons/builtin.py
index 893718a..721bcee 100644
--- a/web/plugins/icons/builtin.py
+++ b/web/plugins/icons/builtin.py
@@ -195,13 +195,13 @@ def pnp_icon(row, what):
url = ""
import metrics
- if not hasattr(metrics, 'render_graph_html') or what == 'host':
+ if not hasattr(metrics, 'render_graph_html'):
# 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 = 'pnp_hover_contents(\'%s\')' %
pnp_popup_url(row, what)
else:
hover_content_func = 'hover_graph(\'%s\', \'%s\',
\'%s\')' % \
- (row['site'], row['host_name'],
row['service_description'])
+ (row['site'], row['host_name'],
row.get('service_description', '_HOST_'))
return '<a href="%s" onmouseover="displayHoverMenu(event,
%s)" ' \
'onmouseout="hoverHide()">%s</a>' % (url,
hover_content_func, html.render_icon('pnp', ''))