Module: check_mk
Branch: master
Commit: 56ffe9fadc695f79a92abcadd7a449360fb2b88d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=56ffe9fadc695f…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue Jun 23 16:13:56 2015 +0200
added documentation about new colors for metric_info in metrics/check_mk.py and edited
function parse_color_into_hexrgb in htdocs/metrics.py
---
web/htdocs/metrics.py | 22 ++++++++++++++--------
web/plugins/metrics/check_mk.py | 19 +++++++++++++++----
2 files changed, 29 insertions(+), 12 deletions(-)
diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index e6ba3e7..fce0a6a 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -201,14 +201,20 @@ def parse_color_into_hexrgb(color_string):
elif "/" in color_string:
cmk_color_index, color_shading = color_string.split("/")
hsv = list(cmk_color_palette[cmk_color_index])
- if color_shading == 'a':
- hsv[2] *= 0.6
- elif color_shading == 'b':
- hsv[2] *= 0.8
- elif color_shading == 'd':
- hsv[1] *= 0.8
- elif color_shading == 'e':
- hsv[1] *= 0.6
+
+ # Colors of the yellow ("2") and green ("3") area need to be
darkened (in third place of the hsv tuple),
+ # colors of the red and blue area need to be brightened (in second place of the
hsv tuple).
+ # For both shadings we need different factors.
+ cmk_color_nuance_index = 1
+ cmk_color_nuance_factor = 0.6
+
+ if cmk_color_index[0] in ["2", "3"]:
+ cmk_color_nuance_index = 2
+ cmk_color_nuance_factor = 0.8
+
+ if color_shading == 'b':
+ hsv[cmk_color_nuance_index] *= cmk_color_nuance_factor
+
color_hexrgb = hsv_to_hexrgb(hsv)
return color_hexrgb
else:
diff --git a/web/plugins/metrics/check_mk.py b/web/plugins/metrics/check_mk.py
index 444e321..c9a0f55 100644
--- a/web/plugins/metrics/check_mk.py
+++ b/web/plugins/metrics/check_mk.py
@@ -178,7 +178,7 @@ unit_info["db"] = {
# Title are always lower case - except the first character!
-# colors:
+# Colors:
#
# red
# magenta orange
@@ -190,11 +190,22 @@ unit_info["db"] = {
# 42 25
# 41 26
# 36 35 34 33 32 31
-# cyan chartreuse
+# cyan yellow-green
# green
#
-# "color" : "23/a" basic color
-# "color" : "23/b" nuance of color
+# Special colors:
+# 51 gray
+# 52 brown 1
+# 53 brown 2
+#
+# For a new metric_info you have to choose a color. No more hex-codes are needed!
+# Instead you can choose a number of the above color ring and a letter 'a' or
'b
+# where 'a' represents the basic color and 'b' is a nuance/shading of the
basic color.
+# Both number and letter must be declared!
+#
+# Example:
+# "color" : "23/a" (basic color yellow)
+# "color" : "23/b" (nuance of color yellow)
metric_info["rta"] = {
"title" : _("Round trip average"),