Module: check_mk
Branch: master
Commit: 74b53f7351bdfcf0de053ca474664ad88a5d90cb
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=74b53f7351bdfc…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Sep 19 16:49:41 2017 +0200
3920 Graphs: Vertical axis scaling and mirroring can now be customized
You can now customize the vertical axis scaling mode and mirror the
metrics in a graph if you like. This can be done just for yourself
or for all your users.
This can be useful, for example, if you like to change the scaling
of all CPU usage graphs from fixed 100% to dynamical scaling based
on the measured values.
This feature is usable for all template based and combined graphs.
It does not affect custom graphs at all.
To configure such a customization open your GUI and click the {{Edit}}
button of your {{Views}} snapin. Then click on the {{Graph tunings}}
button on the top of the page. From this page you can then create a
new graph tuning where you first need to set a title and the graph
type you want to customize
.
Then you need to add a new tuning setting where you can first configure
to which graphs you want it to be applied and then configure the options
you want to change.
If you like you can enable to share this tuning with others, which will
make your changes effective for other users graphs.
After saving the new tunings it's settings will be applied immediately
to fresh rendered graphs.
---
.werks/3920 | 35 +++++++++++++++++++++++++++++++++++
web/htdocs/metrics.py | 7 +++++++
web/htdocs/pagetypes.py | 14 ++++++++++++++
web/htdocs/visuals.py | 2 ++
4 files changed, 58 insertions(+)
diff --git a/.werks/3920 b/.werks/3920
new file mode 100644
index 0000000..e4cbcf1
--- /dev/null
+++ b/.werks/3920
@@ -0,0 +1,35 @@
+Title: Graphs: Vertical axis scaling and mirroring can now be customized
+Level: 2
+Component: multisite
+Compatible: compat
+Edition: cee
+Version: 1.5.0i1
+Date: 1505832008
+Class: feature
+
+You can now customize the vertical axis scaling mode and mirror the
+metrics in a graph if you like. This can be done just for yourself
+or for all your users.
+
+This can be useful, for example, if you like to change the scaling
+of all CPU usage graphs from fixed 100% to dynamical scaling based
+on the measured values.
+
+This feature is usable for all template based and combined graphs.
+It does not affect custom graphs at all.
+
+To configure such a customization open your GUI and click the {{Edit}}
+button of your {{Views}} snapin. Then click on the {{Graph tunings}}
+button on the top of the page. From this page you can then create a
+new graph tuning where you first need to set a title and the graph
+type you want to customize
+.
+Then you need to add a new tuning setting where you can first configure
+to which graphs you want it to be applied and then configure the options
+you want to change.
+
+If you like you can enable to share this tuning with others, which will
+make your changes effective for other users graphs.
+
+After saving the new tunings it's settings will be applied immediately
+to fresh rendered graphs.
diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index d4cc625..208b44f 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -1123,6 +1123,13 @@ def generic_graph_template(metric_name):
]
}
+
+def get_graph_template_choices():
+ # TODO: v.get("title", k): Use same algorithm as used in
+ # GraphIdentificationTemplateBased._parse_template_metric()
+ return sorted([ (k, v.get("title", k)) for k, v in graph_info.items() ],
key=lambda (k, v): v)
+
+
def get_graph_template(template_id):
if template_id.startswith("METRIC_"):
return generic_graph_template(template_id[7:])
diff --git a/web/htdocs/pagetypes.py b/web/htdocs/pagetypes.py
index e8ad462..989fbb5 100644
--- a/web/htdocs/pagetypes.py
+++ b/web/htdocs/pagetypes.py
@@ -84,6 +84,9 @@ class Base(object):
# "add_to" : Text like "Add to foo bar..."
# TODO: Look at GraphCollection for the complete list of phrases to
# be defined for each page type and explain that here.
+ # TODO: Refactor this to different indepentent class methods. For example
+ # the "add_to" phrase is not relevant for non container elements. In the
+ # moment we use dedicated methods, wrong usage will be found by pylint.
@classmethod
def phrase(cls, phrase):
return _("MISSING '%s'") % phrase
@@ -492,6 +495,17 @@ class Overridable(Base):
### elif visual["public"] and owner == "":
### builtin.append((owner, visual_name, visual))
+
+ @classmethod
+ def permitted_instances_sorted(cls):
+ instances = []
+ for instance in cls.instances_sorted():
+ if (instance.is_mine() and instance.may_see()) or \
+ (not instance.is_mine() and instance.is_public() and instance.may_see()):
+ instances.append(instance)
+ return instances
+
+
def may_delete(self):
if self.is_builtin():
return False
diff --git a/web/htdocs/visuals.py b/web/htdocs/visuals.py
index 1d4bab8..eabd0ad 100644
--- a/web/htdocs/visuals.py
+++ b/web/htdocs/visuals.py
@@ -302,6 +302,8 @@ def page_list(what, title, visuals, custom_columns = None,
html.context_button(_("Graph Collections"),
"graph_collections.py", "graph_collection")
if pagetypes.has_page_type("custom_graph"):
html.context_button(_("Custom Graphs"), "custom_graphs.py",
"custom_graph")
+ if pagetypes.has_page_type("graph_tuning"):
+ html.context_button(_("Grap tunings"), "graph_tunings.py",
"graph_tuning")
html.context_button(_("Bookmark Lists"), "bookmark_lists.py",
"bookmark_list")
html.end_context_buttons()