Module: check_mk
Branch: master
Commit: a120592670a1ef7b9b34072e2d42e440aa720683
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a120592670a1ef…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Feb 21 11:29:34 2017 +0100
Refactoring: rename "abstract graph" into "graph artwork"
Change-Id: I04fcf2fb71ddc14b2113c924e903689548d0f9be
---
.bugs/2814 | 4 ++--
web/htdocs/metrics.py | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/.bugs/2814 b/.bugs/2814
index 7aa9aa4..b3ea6c0 100644
--- a/.bugs/2814
+++ b/.bugs/2814
@@ -8,8 +8,8 @@ Targetversion: 1.2.8
2016-03-18 14:32:52 [3] [19625] Ajax call ajax_graph.py failed: list index out of range
Traceback (most recent call last):
File "/omd/sites/stable/share/check_mk/web/plugins/metrics/graphs.py", line 1659, in ajax_graph
- abstract_graph = compute_abstract_graph(graph_definition, graph_data_range, graph_render_options)
- File "/omd/sites/stable/share/check_mk/web/plugins/metrics/graphs.py", line 407, in compute_abstract_graph
+ graph_artwork = compute_graph_artwork(graph_definition, graph_data_range, graph_render_options)
+ File "/omd/sites/stable/share/check_mk/web/plugins/metrics/graphs.py", line 407, in compute_graph_artwork
elif chop_last_empty_step(graph_data_range, step, rrd_data):
File "/omd/sites/stable/share/check_mk/web/plugins/metrics/graphs.py", line 592, in chop_last_empty_step
if data[-1] != None:
diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index be5bc61..222e539 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -1487,9 +1487,9 @@ def host_service_graph_dashlet_cmk(graph_specification, custom_graph_render_opti
# When the legend is enabled, we need to reduce the height by the height of the legend to
# make the graph fit into the dashlet area.
if graph_render_options["show_legend"]:
- # TODO FIXME: This abstract graph is calulated twice. Once here and once in render_graphs_from_specification_html()
- abstract_graph = compute_abstract_graph(graph_definition, graph_data_range, graph_render_options)
- graph_render_options["size"] = (size[0], size[1] - graph_legend_height_ex(graph_render_options, abstract_graph))
+ # TODO FIXME: This graph artwork is calulated twice. Once here and once in render_graphs_from_specification_html()
+ graph_artwork = compute_graph_artwork(graph_definition, graph_data_range, graph_render_options)
+ graph_render_options["size"] = (size[0], size[1] - graph_legend_height_ex(graph_render_options, graph_artwork))
html_code = render_graphs_from_definitions([graph_definition], graph_data_range, graph_render_options)
html.write(html_code)
Module: check_mk
Branch: master
Commit: 77dd12a3f6817b5b5a314dce45ad79a8af2fdfdc
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=77dd12a3f6817b…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Feb 21 11:36:05 2017 +0100
Refactoring: rename "graph definition" into "graph recipe"
Change-Id: I8cb2abd30255adaa15c9b42cb20de1ceceb71a29
---
.bugs/2814 | 2 +-
.bugs/2839 | 10 +++++-----
.werks/1073 | 2 +-
.werks/2355 | 2 +-
.werks/3465 | 2 +-
tests/web/test_webapi.py | 2 +-
web/htdocs/metrics.py | 16 ++++++++--------
web/plugins/metrics/check_mk.py | 2 +-
8 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/.bugs/2814 b/.bugs/2814
index b3ea6c0..af68f57 100644
--- a/.bugs/2814
+++ b/.bugs/2814
@@ -8,7 +8,7 @@ Targetversion: 1.2.8
2016-03-18 14:32:52 [3] [19625] Ajax call ajax_graph.py failed: list index out of range
Traceback (most recent call last):
File "/omd/sites/stable/share/check_mk/web/plugins/metrics/graphs.py", line 1659, in ajax_graph
- graph_artwork = compute_graph_artwork(graph_definition, graph_data_range, graph_render_options)
+ graph_artwork = compute_graph_artwork(graph_recipe, graph_data_range, graph_render_options)
File "/omd/sites/stable/share/check_mk/web/plugins/metrics/graphs.py", line 407, in compute_graph_artwork
elif chop_last_empty_step(graph_data_range, step, rrd_data):
File "/omd/sites/stable/share/check_mk/web/plugins/metrics/graphs.py", line 592, in chop_last_empty_step
diff --git a/.bugs/2839 b/.bugs/2839
index 962be8c..89cd083 100644
--- a/.bugs/2839
+++ b/.bugs/2839
@@ -61,15 +61,15 @@ details:
show_timeranges)
File "/omd/sites/heute/share/check_mk/web/plugins/metrics/graphs.py", line 1760, in render_graphs_from_specification_html
- graph_definitions = create_graph_definitions_from_specification(graph_specification)
+ graph_recipes = create_graph_recipes_from_specification(graph_specification)
- File "/omd/sites/heute/share/check_mk/web/plugins/metrics/graphs.py", line 145, in create_graph_definitions_from_specification
+ File "/omd/sites/heute/share/check_mk/web/plugins/metrics/graphs.py", line 145, in create_graph_recipes_from_specification
return func(spec_info)
- File "/omd/sites/heute/share/check_mk/web/plugins/metrics/graphs.py", line 189, in create_graph_definitions_from_template
- graph_definition = create_graph_definition_from_template(graph_template, translated_metrics, site, host_name, service_description)
+ File "/omd/sites/heute/share/check_mk/web/plugins/metrics/graphs.py", line 189, in create_graph_recipes_from_template
+ graph_recipe = create_graph_recipe_from_template(graph_template, translated_metrics, site, host_name, service_description)
- File "/omd/sites/heute/share/check_mk/web/plugins/metrics/graphs.py", line 211, in create_graph_definition_from_template
+ File "/omd/sites/heute/share/check_mk/web/plugins/metrics/graphs.py", line 211, in create_graph_recipe_from_template
metric = parse_template_metric(site, host_name, service_description, metric_definition, translated_metrics)
File "/omd/sites/heute/share/check_mk/web/plugins/metrics/graphs.py", line 283, in parse_template_metric
diff --git a/.werks/1073 b/.werks/1073
index e57781e..7819926 100644
--- a/.werks/1073
+++ b/.werks/1073
@@ -1,4 +1,4 @@
-Title: sni_octopuse_cpu: added PNP graph definition and Perf-O-Meter
+Title: sni_octopuse_cpu: added PNP graph template and Perf-O-Meter
Level: 1
Component: checks
Version: 1.2.5i5
diff --git a/.werks/2355 b/.werks/2355
index c79cfea..3a02867 100644
--- a/.werks/2355
+++ b/.werks/2355
@@ -1,4 +1,4 @@
-Title: docsis_channels_upstream: Fix graph definitions
+Title: docsis_channels_upstream: Fix graph templates
Level: 1
Component: checks
Compatible: compat
diff --git a/.werks/3465 b/.werks/3465
index 6381c7b..e7b881b 100644
--- a/.werks/3465
+++ b/.werks/3465
@@ -7,6 +7,6 @@ State: unknown
Version: 1.4.0i1
Date: 1461597698
-The graph definition had an explicit vertical range of <tt>(0, 0)</tt>. That
+The graph recipe had an explicit vertical range of <tt>(0, 0)</tt>. That
effectively had set the displayed range to 0..1 Bytes/day - which led to an
always empty or near useless graph. This has been fixed.
diff --git a/tests/web/test_webapi.py b/tests/web/test_webapi.py
index 06f5d6f..3ce73f0 100644
--- a/tests/web/test_webapi.py
+++ b/tests/web/test_webapi.py
@@ -188,7 +188,7 @@ def test_get_graph(web, site):
# No graph yet...
with pytest.raises(APIError) as e:
data = web.get_regular_graph("test-host-get-graph", "Check_MK", 0, expect_error=True)
- assert "Cannot calculate graph definitions" in "%s" % e
+ assert "Cannot calculate graph recipes" in "%s" % e
# Now add the host
web.add_host("test-host-get-graph", attributes={
diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index 222e539..2238cc1 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -445,7 +445,7 @@ def translate_metrics(perf_data, check_command):
new_entry = {
"value" : value * translation_entry["scale"],
"orig_name" : varname,
- "scale" : translation_entry["scale"], # needed for graph definitions
+ "scale" : translation_entry["scale"], # needed for graph recipes
"scalar" : {},
}
@@ -1332,7 +1332,7 @@ def browser_supports_canvas():
return True
-# CLEANUP: Make this function being used only by create_graph_definition_from_template.
+# CLEANUP: Make this function being used only by create_graph_recipe_from_template.
# Then rename it and move it over there.
def get_graph_data_from_livestatus(site, host_name, service):
if service == "_HOST_":
@@ -1475,11 +1475,11 @@ def host_service_graph_dashlet_cmk(graph_specification, custom_graph_render_opti
graph_render_options)
try:
- graph_definitions = create_graph_definitions_from_specification(graph_specification)
- if graph_definitions:
- graph_definition = graph_definitions[0]
+ graph_recipes = create_graph_recipes_from_specification(graph_specification)
+ if graph_recipes:
+ graph_recipe = graph_recipes[0]
else:
- raise MKGeneralException(_("Failed to calculate a graph definition."))
+ raise MKGeneralException(_("Failed to calculate a graph recipe."))
except MKLivestatusNotFoundError:
html.write("<div class=error>%s</div>" % html.attrencode(_("Cannot render graphs: cannot fetch data via Livestatus")))
return
@@ -1488,10 +1488,10 @@ def host_service_graph_dashlet_cmk(graph_specification, custom_graph_render_opti
# make the graph fit into the dashlet area.
if graph_render_options["show_legend"]:
# TODO FIXME: This graph artwork is calulated twice. Once here and once in render_graphs_from_specification_html()
- graph_artwork = compute_graph_artwork(graph_definition, graph_data_range, graph_render_options)
+ graph_artwork = compute_graph_artwork(graph_recipe, graph_data_range, graph_render_options)
graph_render_options["size"] = (size[0], size[1] - graph_legend_height_ex(graph_render_options, graph_artwork))
- html_code = render_graphs_from_definitions([graph_definition], graph_data_range, graph_render_options)
+ html_code = render_graphs_from_definitions([graph_recipe], graph_data_range, graph_render_options)
html.write(html_code)
diff --git a/web/plugins/metrics/check_mk.py b/web/plugins/metrics/check_mk.py
index 6bb7ac9..aac3c73 100644
--- a/web/plugins/metrics/check_mk.py
+++ b/web/plugins/metrics/check_mk.py
@@ -5819,7 +5819,7 @@ perfometer_info.append({
# It determines the order of graphs of a service, which in turn is used by
# the report definitions to determine which graph to include.
-# Order of metrics in graph definitions important if you use only 'area':
+# Order of metrics in graph recipes important if you use only 'area':
# The first one must be the bigger one, then descending.
# Example: ('tablespace_size', 'area'),
# ('tablespace_used', 'area')
Module: check_mk
Branch: master
Commit: 8d7a1373152e8f15edfd5c7995b1efc171aa349e
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8d7a1373152e8f…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Feb 24 10:32:58 2017 +0100
Combined graphs: update internal notes
Change-Id: Ie5e5bf9fb3f90c39ea0fb2461c0312bbb6f44fde
---
ZUTUN.graphing | 8 --------
1 file changed, 8 deletions(-)
diff --git a/ZUTUN.graphing b/ZUTUN.graphing
index 2895fe2..132c293 100644
--- a/ZUTUN.graphing
+++ b/ZUTUN.graphing
@@ -6,14 +6,6 @@
[4] Titel der Graphen selbst
-[5] au: Titel der einzelnen Metriken. Hierbei berücksichtigen,
- au: ob alle Kurven vom gleichen Host oder Service kommen.
- au: Frage klären, ob eventuell sogar der Name der Metrik
- au: auch weggealssen wird - z.B. wenn der Graph nur eine
- au: einzige Metrik zeigt und diese schon im Graph-Titel
- au: zu sehen ist.
-
-
[6] Graph zu Dashboard hinzufügen.
Module: check_mk
Branch: master
Commit: a3c0135a77630a34e58ff976165ce79d8016a458
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a3c0135a77630a…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Feb 23 14:52:34 2017 +0100
Combined graph: useful color palette for lines representation
Change-Id: Iabb4e093fcb3d961eb23179683be0ec4b10f1d21
---
ZUTUN.graphing | 32 ++++++++++++++++++--------------
web/htdocs/metrics.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 64 insertions(+), 14 deletions(-)
diff --git a/ZUTUN.graphing b/ZUTUN.graphing
index edf4973..98851ef 100644
--- a/ZUTUN.graphing
+++ b/ZUTUN.graphing
@@ -5,14 +5,14 @@
zu machen.
-[2] Farbabstufungen für "lines":
- Hier einfach auf die Originalfarben ganz verzichten und
- Palettenfarben verwenden. Dazu den Code angucken, wo wir
- die Palatte definieren ("21/a", "22/a", ....). Daraus einen
- Kreis bauen. Dann die Anzahl der Punkte im Kreis durch die
- Anzahl der Kurven teilen und die Abstände dadurch so groß
- wie möglich machen. Wenn wir mehr Kurven als Farben haben,
- müssen wir mehrfach im Kreis "rumfahren".
+[2] mk: Farbabstufungen für "lines":
+ mk: Hier einfach auf die Originalfarben ganz verzichten und
+ mk: Palettenfarben verwenden. Dazu den Code angucken, wo wir
+ mk: die Palatte definieren ("21/a", "22/a", ....). Daraus einen
+ mk: Kreis bauen. Dann die Anzahl der Punkte im Kreis durch die
+ mk: Anzahl der Kurven teilen und die Abstände dadurch so groß
+ mk: wie möglich machen. Wenn wir mehr Kurven als Farben haben,
+ mk: müssen wir mehrfach im Kreis "rumfahren".
[3] au: Implementierung von "Average": einfach die kleine Funktion
@@ -23,12 +23,12 @@
[4] Titel der Graphen selbst
-[5] au:Titel der einzelnen Metriken. Hierbei berücksichtigen,
- au:ob alle Kurven vom gleichen Host oder Service kommen.
- au:Frage klären, ob eventuell sogar der Name der Metrik
- au:auch weggealssen wird - z.B. wenn der Graph nur eine
- au:einzige Metrik zeigt und diese schon im Graph-Titel
- au:zu sehen ist.
+[5] au: Titel der einzelnen Metriken. Hierbei berücksichtigen,
+ au: ob alle Kurven vom gleichen Host oder Service kommen.
+ au: Frage klären, ob eventuell sogar der Name der Metrik
+ au: auch weggealssen wird - z.B. wenn der Graph nur eine
+ au: einzige Metrik zeigt und diese schon im Graph-Titel
+ au: zu sehen ist.
[6] Graph zu Dashboard hinzufügen.
@@ -71,3 +71,7 @@
[18] Default festlegen, wenn man auf die Seite kommt. Sollen wir einfach "Summe"
nehmen?
+
+
+[19] Umswitchen der Darstellungsarten über die Knöpfe soll den gewählten Zeitbereich beibehalten.
+ Geht das überhaupt?
diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index 7986b53..37b04dd 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -220,6 +220,48 @@ def get_palette_color_by_index(i, shading='a'):
return "%s/%s" % (color_key, shading)
+# Return a list of colors that are as different as possible (visually)
+# by distributing them on the HSV color wheel.
+def get_n_different_colors(n):
+ total_weight = sum([x[1] for x in hsv_color_distribution])
+
+ colors = []
+ while len(colors) < n:
+ weight_index = len(colors) * total_weight / n
+ hue = get_hue_by_weight_index(weight_index)
+ colors.append(hsv_to_hexrgb((hue, 1, 1)))
+ return colors
+
+
+def get_hue_by_weight_index(weight_index):
+ section_begin = 0.0
+ for section_end, section_weight in hsv_color_distribution:
+ if weight_index < section_weight:
+ section_size = section_end - section_begin
+ hue = section_begin + ((weight_index / section_weight) * section_size)
+ return hue
+ weight_index -= section_weight
+ section_begin = section_end
+
+
+
+# Try to distribute colors in a whay that the psychological
+# colors distance is distributed evenly.
+hsv_color_distribution = [
+ (0.1, 10.0), # orange ... red
+ (0.2, 10.0), # orange ... yellow(-greenish)
+ (0.3, 5.0), # green-yellow
+ (0.4, 2.0), # green
+ (0.5, 5.0), # green .... cyan
+ (0.6, 20.0), # cyan ... seablue
+ (0.7, 10.0), # seablue ... dark blue
+ (0.8, 20.0), # dark blue ... violet
+ (0.9, 10.0), # violet .. magenta
+ (1.0, 20.0), # magenta .. red
+]
+
+
+
def get_next_random_palette_color():
keys = cmk_color_palette.keys()
if html.is_cached("random_color_index"):
@@ -277,18 +319,21 @@ def render_color(color_rgb):
int(color_rgb[1] * 255),
int(color_rgb[2] * 255),)
+
# Make a color darker. v ranges from 0 (not darker) to 1 (black)
def darken_color(rgb, v):
def darken(x, v):
return x * (1.0 - v)
return tuple([ darken(x, v) for x in rgb ])
+
# Make a color lighter. v ranges from 0 (not lighter) to 1 (white)
def lighten_color(rgb, v):
def lighten(x, v):
return x + ((1.0 - x) * v)
return tuple([ lighten(x, v) for x in rgb ])
+
def mix_colors(a, b):
return tuple([
(ca + cb) / 2.0
@@ -296,6 +341,7 @@ def mix_colors(a, b):
in zip(a, b)
])
+
def render_color_icon(color):
return "<div class=color style=\"background-color: %s\"></div>" % color
Module: check_mk
Branch: master
Commit: 17913be108f6baa97682cdcee063f8e388611942
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=17913be108f6ba…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Feb 27 14:55:32 2017 +0100
Combined graphs: updated internal notes
Change-Id: Iefac836ba451812eb7403fdff8e12e9fb2c6866b
---
ZUTUN.graphing | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/ZUTUN.graphing b/ZUTUN.graphing
index 7ced761..54c38c1 100644
--- a/ZUTUN.graphing
+++ b/ZUTUN.graphing
@@ -7,15 +7,17 @@
[8] Graph zu "GraphCollections" hinzufügen.
-[9] Fall, dass ein Graph negative Metrik hat ("-line", "-area", "-stacked")
+[9] au: Fall, dass ein Graph negative Metrik hat ("-line", "-area", "-stacked")
-[10] Graphen mit mehreren Areas, saubere Stacks bilden.
- Wenn die erste Metrik line oder area ist, nimmt man area,
- sonst stacked. Beispiel zum Testen: Filesystem-Graph. Bei Sum kommt
- aktuell nur die Hälfte raus wie bei Stacked - sollte aber ja das
- gleiche Ergebnis zeigen.
+[10] au: Graphen mit mehreren Areas, saubere Stacks bilden.
+ au: Wenn die erste Metrik line oder area ist, nimmt man area,
+ au: sonst stacked. Beispiel zum Testen: Filesystem-Graph. Bei Sum kommt
+ au: aktuell nur die Hälfte raus wie bei Stacked - sollte aber ja das
+ au: gleiche Ergebnis zeigen.
au: Aktueller Status: Umgesetzt fuer "area"
+ au: Linie bei stacked: hier verwenden wir die Summe. Allerdings muss
+ au: man das auch in der Beschriftung der Linie dann korrekt machen.
[12] Limit auf Menge der dargestellten Objekte.
@@ -23,10 +25,6 @@
[14] Import views und visuals irgendwie aufrüamen
-[16] Prüfung auf eine einheitliche Unit? Brauchen wir das? Im Originalcode ist
- von den normalen Templates.
-
-
[18] au: Default festlegen, wenn man auf die Seite kommt. Wenn die Variable
"presentation" nicht da ist, soll er einfache "Summe" nehmen. Bei
den Links von den Views dann "presentation" weglassen.