Module: check_mk
Branch: master
Commit: 44a658f93c1a55825f34c50e5b7ba0559dc2c34d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=44a658f93c1a55…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sun Jan 31 23:42:41 2016 +0100
Metrics table now contains links for adding these to custom graphs
---
web/htdocs/metrics.py | 16 +++++++++++++++-
web/htdocs/pagetypes.py | 5 +++++
web/htdocs/views.css | 6 ------
web/plugins/views/painters.py | 2 +-
4 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index 6fe5679..7ed4f70 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -1407,13 +1407,27 @@ def host_service_graph_dashlet_pnp(site, host_name,
service_description, source)
# | Renders a simple table with all metrics of a host or service |
# '----------------------------------------------------------------------'
-def render_metrics_table(translated_metrics):
+def render_metrics_table(translated_metrics, host_name, service_description):
output = "<table class=metricstable>"
for metric_name, metric in sorted(translated_metrics.items(), cmp=lambda a,b:
cmp(a[1]["title"], b[1]["title"])):
output += "<tr>"
output += "<td class=color><div class=color
style=\"background-color: %s\"></div></td>" %
metric["color"]
output += "<td>%s:</td>" % metric["title"]
output += "<td class=value>%s</td>" %
metric["unit"]["render"](metric["value"])
+ if cmk_graphs_possible():
+ output += "<td>"
+ output += html.render_popup_trigger(
+ html.render_icon("custom_graph", help=_("Add this metric
to a custom graph"), cssclass="iconbutton"),
+ ident = "add_metric_to_graph_" + host_name + ";" +
service_description,
+ what = "add_metric_to_custom_graph",
+ url_vars = [
+ ("host", host_name),
+ ("service", service_description),
+ ("metric", metric_name),
+ ("back_url", "HIRN MIST TODO"),
+ ]
+ )
+ output += "</td>"
output += "</tr>"
output += "</table>"
return output
diff --git a/web/htdocs/pagetypes.py b/web/htdocs/pagetypes.py
index 1b56ef9..37e2d51 100644
--- a/web/htdocs/pagetypes.py
+++ b/web/htdocs/pagetypes.py
@@ -354,6 +354,11 @@ class PageRenderer:
class Overridable:
@classmethod
+ def sanitize(self, d):
+ d.setdefault("public", False)
+
+
+ @classmethod
def parameters(self, clazz):
if clazz.has_overriding_permission("publish"):
return [( _("General Properties"), [
diff --git a/web/htdocs/views.css b/web/htdocs/views.css
index 9d233df..a3aeee6 100644
--- a/web/htdocs/views.css
+++ b/web/htdocs/views.css
@@ -805,9 +805,3 @@ td.if_state.if_not_available {
color: black;
background-color: #cccccc;
}
-
-/* metrics table in painter svc_metrics */
-table.metricstable td.value {
- padding-left: 10px;
- text-align: right;
-}
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index 702aa05..72e1c01 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -530,7 +530,7 @@ multisite_painters["svc_perf_data"] = {
def paint_service_metrics(row):
translated_metrics =
metrics.translate_metrics(*metrics.parse_perf_data(row["service_perf_data"],
row["service_check_command"]))
- return "", metrics.render_metrics_table(translated_metrics)
+ return "", metrics.render_metrics_table(translated_metrics,
row["host_name"], row["service_description"])
multisite_painters["svc_metrics"] = {
"title" : _("Service Metrics"),