Module: check_mk
Branch: master
Commit: c8e0c60cea440638040d7aa152d3e1d22edc3a7e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c8e0c60cea4406…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Jan 25 16:11:08 2016 +0100
Preparation for new style graph overview page
---
web/plugins/icons/builtin.py | 46 +++++++++++++++++++++++++++++++++++-------
web/plugins/views/builtin.py | 2 +-
web/plugins/views/layouts.py | 24 ++++++++++++++++++++--
3 files changed, 62 insertions(+), 10 deletions(-)
diff --git a/web/plugins/icons/builtin.py b/web/plugins/icons/builtin.py
index e7a9d87..6bf5905 100644
--- a/web/plugins/icons/builtin.py
+++ b/web/plugins/icons/builtin.py
@@ -294,6 +294,13 @@ multisite_icons_and_actions['realhost'] = {
# | |
# '----------------------------------------------------------------------'
+def has_new_graphing():
+ # TODO: Import in function is not good
+ import metrics
+ return hasattr(metrics, 'render_graph_from_template_html') \
+ and metrics.new_style_graphs_possible()
+
+
# Intelligent Links to PNP4Nagios 0.6.X
def pnp_url(row, what, how = 'graph'):
sitename = row["site"]
@@ -315,32 +322,57 @@ def pnp_url(row, what, how = 'graph'):
html.urlencode(site["url_prefix"])
return url
+
def pnp_popup_url(row, what):
return pnp_url(row, what, 'popup')
-def pnp_icon(row, what):
- if 'X' in html.display_options:
- url = pnp_url(row, what)
+
+def new_graphing_url(row, what):
+ site_id = row["site"]
+
+ urivars = [
+ ("view_name", "service_graphs"),
+ ("siteopt", site_id),
+ ("host", row["host_name"]),
+ ]
+
+ if what == "service":
+ urivars.append(("service", row["service_description"]))
+
+ return html.makeuri_contextless(urivars, filename="view.py")
+
+
+def pnp_graph_icon_link(row, what):
+ if 'X' not in html.display_options:
+ return ""
+
+ if not has_new_graphing():
+ return pnp_url(row, what)
else:
- url = ""
+ return new_graphing_url(row, what)
- # TODO: Import in function is not good
- import metrics
- if not hasattr(metrics, 'render_graph_from_template_html'):
+
+def pnp_icon(row, what):
+ url = pnp_graph_icon_link(row, what)
+
+ if not has_new_graphing():
# 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.get('service_description', '_HOST_').replace("\\",
"\\\\"))
+
return '<a href="%s" onmouseover="show_hover_menu(event,
%s)" ' \
'onmouseout="hide_hover_menu()">%s</a>' % (url,
hover_content_func, html.render_icon('pnp', ''))
+
def paint_pnp_graph(what, row, tags, host_custom_vars):
pnpgraph_present = row[what + "_pnpgraph_present"]
if pnpgraph_present == 1:
return pnp_icon(row, what)
+
multisite_icons_and_actions['perfgraph'] = {
'columns': [ 'pnpgraph_present' ],
'paint': paint_pnp_graph,
diff --git a/web/plugins/views/builtin.py b/web/plugins/views/builtin.py
index 8e357e9..9bea7f0 100644
--- a/web/plugins/views/builtin.py
+++ b/web/plugins/views/builtin.py
@@ -1657,7 +1657,7 @@ multisite_builtin_views.update({
'sorters': [('site', False),
('site_host', False),
('svcdescr', False)],
- 'linktitle': _('Graphs'),
+ 'linktitle': _('Host graphs'),
'title': _('Graphs for host'),
},
'recentsvc': {'browser_reload': 30,
diff --git a/web/plugins/views/layouts.py b/web/plugins/views/layouts.py
index 923cbdf..85d180b 100644
--- a/web/plugins/views/layouts.py
+++ b/web/plugins/views/layouts.py
@@ -122,7 +122,7 @@ multisite_layouts["dataset"] = {
# | The boxed layout is useful in views with a width > 1, boxes are |
# | stacked in columns and can have different sizes. |
# '----------------------------------------------------------------------'
-def render_grouped_boxes(rows, view, group_painters, painters, num_columns,
show_checkboxes):
+def render_grouped_boxes(rows, view, group_painters, painters, num_columns,
show_checkboxes, css_class=None):
repeat_heading_every = 20 # in case column_headers is "repeat"
@@ -230,7 +230,7 @@ def render_grouped_boxes(rows, view, group_painters, painters,
num_columns, show
init_rowselect(view)
# render table
- html.write("<table class=boxlayout><tr>")
+ html.write("<table class=\"boxlayout%s\"><tr>" %
(css_class and " "+css_class or ""))
for column in columns:
html.write("<td class=boxcolumn>")
for header, rows in column:
@@ -245,6 +245,26 @@ multisite_layouts["boxed"] = {
"checkboxes" : True,
}
+#.
+# .--Graph Boxes---------------------------------------------------------.
+# | ____ _ ____ |
+# | / ___|_ __ __ _ _ __ | |__ | __ ) _____ _____ ___ |
+# | | | _| '__/ _` | '_ \| '_ \ | _ \ / _ \ \/ / _ \/ __| |
+# | | |_| | | | (_| | |_) | | | | | |_) | (_) > < __/\__ \ |
+# | \____|_| \__,_| .__/|_| |_| |____/ \___/_/\_\___||___/ |
+# | |_| |
+# +----------------------------------------------------------------------+
+# | Same as balanced boxes layout but adds a cs class graph to the box |
+# '----------------------------------------------------------------------'
+
+
+multisite_layouts["boxed_graph"] = {
+ "title" : _("Balanced graph boxes"),
+ "render" : lambda *args: render_grouped_boxes(*args +
("graph",)),
+ "group" : True,
+ "checkboxes" : True,
+}
+
#.
# .--Tiled---------------------------------------------------------------.