Module: check_mk
Branch: master
Commit: b9079eff5b8615ab6a3aba658851af10097a5a7d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b9079eff5b8615…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Feb 22 14:49:33 2017 +0100
First protypic version of partially functional combined graphs
Change-Id: If05fc12477611e6da9ab67b605e9cbf1f7d449be
---
web/htdocs/config.py | 5 +++++
web/htdocs/metrics.py | 14 +++++++++++---
web/htdocs/views.py | 23 +++++++++++++++++------
web/plugins/metrics/check_mk.py | 6 +++---
4 files changed, 36 insertions(+), 12 deletions(-)
diff --git a/web/htdocs/config.py b/web/htdocs/config.py
index 3c3d631..67b8543 100644
--- a/web/htdocs/config.py
+++ b/web/htdocs/config.py
@@ -161,6 +161,11 @@ def reporting_available():
return False
+def combined_graphs_available():
+ # HIRN: Really detect
+ return True
+
+
def hide_language(lang):
return lang in hide_languages
diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index 7626e20..0d918a2 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -75,10 +75,17 @@ def load_plugins(force):
load_web_plugins("metrics", globals())
loaded_with_language = current_language
- fixup_unit_into()
+ fixup_graph_info()
+ fixup_unit_info()
-def fixup_unit_into():
+def fixup_graph_info():
+ # create back link from each graph to its id.
+ for graph_id, graph in graph_info.items():
+ graph["id"] = graph_id
+
+
+def fixup_unit_info():
# create back link from each unit to its id.
for unit_id, unit in unit_info.items():
unit["id"] = unit_id
@@ -920,7 +927,7 @@ def build_perfometer(perfometer, translated_metrics):
# +----------------------------------------------------------------------+
# | Implementation of time graphs - basic code, not the rendering |
# | Rendering of the graphs is done by PNP4Nagios, we just create PHP |
-# | templates for PNP here.
+# | templates for PNP here. |
# '----------------------------------------------------------------------'
def get_graph_templates(translated_metrics):
@@ -1027,6 +1034,7 @@ def add_fake_metrics(translated_metrics, metric_names):
def generic_graph_template(metric_name):
return {
+ "id" : "METRIC_" + metric_name,
"metrics" : [
( metric_name, "area" ),
],
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 2be24b2..3569fc6 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -1792,13 +1792,15 @@ def render_view(view, rows, datasource, group_painters, painters,
can_display_checkboxes = layout.get('checkboxes', False)
if show_buttons:
- show_context_links(view, show_filters,
+ show_context_links(view, datasource, show_filters,
# Take into account: permissions, display_options
row_count > 0 and command_form,
# Take into account: layout capabilities
can_display_checkboxes and not
view.get("force_checkboxes"), show_checkboxes,
# Show link to availability
- datasource["table"] in [ "hosts",
"services" ] or "aggr" in datasource["infos"])
+ datasource["table"] in [ "hosts",
"services" ] or "aggr" in datasource["infos"],
+ # Show link to combined graphs
+ "service" in datasource["infos"])
# User errors in filters
html.show_user_errors()
@@ -2058,9 +2060,9 @@ def ajax_set_viewoption():
po.save_to_config()
-def show_context_links(thisview, show_filters,
+def show_context_links(thisview, datasource, show_filters,
enable_commands, enable_checkboxes, show_checkboxes,
- show_availability):
+ show_availability, show_combined_graphs):
# html.begin_context_buttons() called automatically by html.context_button()
# That way if no button is painted we avoid the empty container
if display_options.enabled(display_options.B):
@@ -2141,8 +2143,17 @@ def show_context_links(thisview, show_filters,
(thisview["owner"], thisview["name"], backurl)
html.context_button(_("Edit View"), url, "edit",
id="edit", bestof=config.context_buttons_to_show)
- if display_options.enabled(display_options.E) and show_availability:
- html.context_button(_("Availability"), html.makeuri([("mode",
"availability")]), "availability")
+ if display_options.enabled(display_options.E):
+ if show_availability:
+ html.context_button(_("Availability"),
html.makeuri([("mode", "availability")]), "availability")
+ if show_combined_graphs and config.combined_graphs_available():
+ html.context_button(_("Combined graphs"),
+ html.makeuri([
+ ("single_infos",
",".join(thisview["single_infos"])),
+ ("datasource",
thisview["datasource"]),
+ ],
+ filename="combined_graphs.py"),
"pnp")
+
if display_options.enabled(display_options.B):
execute_hooks('buttons-end')
diff --git a/web/plugins/metrics/check_mk.py b/web/plugins/metrics/check_mk.py
index 95932c1..df895cb 100644
--- a/web/plugins/metrics/check_mk.py
+++ b/web/plugins/metrics/check_mk.py
@@ -6038,7 +6038,7 @@ graph_info["used_cpu_time"] = {
}
-graph_info["time_usage_by_phase"] = {
+graph_info["cmk_cpu_time_by_phase"] = {
"title" : _("Time usage by phase"),
"metrics" : [
( "user_time,children_user_time,+", "stack", _("CPU
time in user space") ),
@@ -6979,7 +6979,7 @@ graph_info["handled_requests"] = {
"omit_zero_metrics" : True,
}
-graph_info["time_spent_for_various_page_types"] = {
+graph_info["cmk_http_pagetimes"] = {
"title" : _("Time spent for various page types"),
"metrics" : [
("secs_cmk_views", "stack"),
@@ -6999,7 +6999,7 @@ graph_info["time_spent_for_various_page_types"] = {
"omit_zero_metrics" : True,
}
-graph_info["bytes_sent"] = {
+graph_info["cmk_http_traffic"] = {
"title" : _("Bytes sent"),
"metrics" : [
("bytes_cmk_views", "stack"),