Module: check_mk
Branch: master
Commit: 210890aa7b79882a6fb7efbef767bf01de030e85
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=210890aa7b7988…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sun Jan 31 22:20:22 2016 +0100
#2929 Show all metrics of a service in a nicely formatted table in the service details
---
.werks/2929 | 9 +++++++++
ChangeLog | 1 +
web/htdocs/metrics.py | 24 ++++++++++++++++++++++++
web/htdocs/views.css | 6 ++++++
web/plugins/views/builtin.py | 3 ++-
web/plugins/views/painters.py | 15 ++++++++++++++-
6 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/.werks/2929 b/.werks/2929
new file mode 100644
index 0000000..71b24cf
--- /dev/null
+++ b/.werks/2929
@@ -0,0 +1,9 @@
+Title: Show all metrics of a service in a nicely formatted table in the service details
+Level: 1
+Component: multisite
+Compatible: compat
+Version: 1.2.7i4
+Date: 1454275199
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index b4693ea..66b8167 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -241,6 +241,7 @@
* 2768 SHowing number of unacknowledged incompatible changes in sidebar header
* 2769 Verifying that the Check_MK GUI is not used with Apache threaded MPM (e.g.
worker)
* 2880 Automatically detect changes in local web/plugins, no Apache restart needed
anymore...
+ * 2929 Show all metrics of a service in a nicely formatted table in the service
details
* 2680 FIX: LDAP: Fixed exception when syncing groups using configurations from
previous versions...
* 2435 FIX: New graphing system: fixed broken graphs for iSCSI checks...
* 2696 FIX: Fixed broken perfometer for update checks
diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index d15d2d5..6fe5679 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -1393,3 +1393,27 @@ def host_service_graph_dashlet_pnp(site, host_name,
service_description, source)
html.write(url_prefix +
"pnp4nagios/index.php/image?host=%s&srv=%s&source=%d&view=%s&theme=multisite"
% \
(html.urlencode(pnp_host), html.urlencode(pnp_svc), source,
html.var("timerange")))
+
+
+#.
+# .--Metrics Table-------------------------------------------------------.
+# | __ __ _ _ _____ _ _ |
+# | | \/ | ___| |_ _ __(_) ___ ___ |_ _|_ _| |__ | | ___ |
+# | | |\/| |/ _ \ __| '__| |/ __/ __| | |/ _` | '_ \| |/ _ \ |
+# | | | | | __/ |_| | | | (__\__ \ | | (_| | |_) | | __/ |
+# | |_| |_|\___|\__|_| |_|\___|___/ |_|\__,_|_.__/|_|\___| |
+# | |
+# +----------------------------------------------------------------------+
+# | Renders a simple table with all metrics of a host or service |
+# '----------------------------------------------------------------------'
+
+def render_metrics_table(translated_metrics):
+ 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"])
+ output += "</tr>"
+ output += "</table>"
+ return output
diff --git a/web/htdocs/views.css b/web/htdocs/views.css
index a3aeee6..9d233df 100644
--- a/web/htdocs/views.css
+++ b/web/htdocs/views.css
@@ -805,3 +805,9 @@ 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/builtin.py b/web/plugins/views/builtin.py
index 9bea7f0..672ecd2 100644
--- a/web/plugins/views/builtin.py
+++ b/web/plugins/views/builtin.py
@@ -1251,7 +1251,7 @@ multisite_builtin_views.update({
('svc_long_plugin_output', None),
('perfometer', None),
('svc_pnpgraph', None),
- ('svc_perf_data', None),
+ ('svc_metrics', None),
('svc_in_downtime', None),
('svc_in_notifper', None),
@@ -1276,6 +1276,7 @@ multisite_builtin_views.update({
('svc_group_memberlist', None),
('svc_servicelevel', None),
('svc_check_command', None),
+ ('svc_perf_data', None),
('svc_custom_vars', None),
('check_manpage', None),
('svc_custom_notes', None),
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index 8923e28..702aa05 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -513,19 +513,32 @@ multisite_painters["svc_plugin_output"] = {
"paint" : lambda row: paint_stalified(row,
format_plugin_output(row["service_plugin_output"], row)),
"sorter" : 'svcoutput',
}
+
multisite_painters["svc_long_plugin_output"] = {
"title" : _("Long output of check plugin (multiline)"),
"short" : _("Status detail"),
"columns" : ["service_long_plugin_output"],
"paint" : lambda row: paint_stalified(row,
format_plugin_output(row["service_long_plugin_output"],
row).replace('\\n', '<br>').replace('\n',
'<br>')),
}
+
multisite_painters["svc_perf_data"] = {
- "title" : _("Service performance data"),
+ "title" : _("Service performance data (source code)"),
"short" : _("Perfdata"),
"columns" : ["service_perf_data"],
"paint" : lambda row: paint_stalified(row,
row["service_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)
+
+multisite_painters["svc_metrics"] = {
+ "title" : _("Service Metrics"),
+ "short" : _("Metrics"),
+ "columns" : [ "service_check_command",
"service_perf_data"],
+ "paint" : paint_service_metrics,
+}
+
def get_perfdata_nth_value(row, n, remove_unit = False):
perfdata = row.get("service_perf_data")
if not perfdata: