Module: check_mk
Branch: master
Commit: 216b2a375ba4e85a3f9efaed099079dd38948f03
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=216b2a375ba4e8…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon May 11 14:36:11 2015 +0200
Matrix layout: option for omitting rows with uniform values
---
web/htdocs/status.css | 24 +++++++++++++++++++++---
web/htdocs/views.css | 4 ++--
web/htdocs/views.py | 2 +-
web/plugins/config/builtin.py | 3 +++
web/plugins/views/layouts.py | 22 +++++++++++++++++-----
5 files changed, 44 insertions(+), 11 deletions(-)
diff --git a/web/htdocs/status.css b/web/htdocs/status.css
index c4ba9c0..798db16 100644
--- a/web/htdocs/status.css
+++ b/web/htdocs/status.css
@@ -57,27 +57,45 @@ table.data td.perfometer.stale div.title {
/* OK/UP */
+/* TODO: Replace class "odd0" with "odd state0" */
.state0, .hstate0, .state0 a, .hstate0 a {
background-color: #0b3; color: #fff;
}
+.odd0 .state0, .odd0 .hstate0, .odd0 .state0 a, .odd0 .hstate0 a {
+ background-color: #1c4;
+}
+.even0 .state0, .even0 .hstate0, .even0 .state0 a, .even0 .hstate0 a {
+ background-color: #0b3;
+}
+
.hstate {
white-space: nowrap;
}
/* WARN */
-.state1, .state1 a, tr.groupheader td.state1 {
- background-color: #ff0; color: #000;
+.state1, .even1 .state1, .state1 a, tr.groupheader td.state1 {
+ background-color: #f8f800; color: #000;
+}
+.odd0 .state1, .odd1 .state1 {
+ background-color: #ff5;
}
/* CRIT/DOWN */
-.state2, .hstate1, .state2 a, .hstate2 a {
+.state2, .even0 .state2, .even2 .state2, .hstate1, .state2 a, .hstate2 a {
background-color: #f00; color: #fff;
}
+.odd0 .state2, .odd2 .state2 {
+ background-color: #f44;
+}
+
/* UNKNOWN / UNREACH */
.state3, .hstate2, .state3 a, .hstate2 a {
background-color: #f80; color: #fff;
}
+.odd0 .state3, .odd3 .state3 {
+ background-color: #f91;
+}
/* PENDING */
.statep, .hstatep, .statep a, .hstatep a {
diff --git a/web/htdocs/views.css b/web/htdocs/views.css
index e9d9c08..a8dc994 100644
--- a/web/htdocs/views.css
+++ b/web/htdocs/views.css
@@ -416,10 +416,10 @@ table.data.matrix tr.matrixhead td.left {
color: white;
}
-table.data.matrix tr.even0 td.minority {
+.even0 .minority {
background-color: #cff;
}
-table.data.matrix tr.odd0 td.minority {
+.odd0 .minority {
background-color: #dff;
}
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 7706710..f7ae63d 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -2302,7 +2302,7 @@ def group_value(row, group_painters):
else:
for c in p[0]["columns"]:
group.append(row[c])
- return group
+ return tuple(group)
def get_painter_option(name):
opt = multisite_painter_options[name]
diff --git a/web/plugins/config/builtin.py b/web/plugins/config/builtin.py
index 8ae8501..cd840ab 100644
--- a/web/plugins/config/builtin.py
+++ b/web/plugins/config/builtin.py
@@ -110,6 +110,9 @@ sounds = [
view_option_refreshes = [ 30, 60, 90, 0 ]
view_option_columns = [ 1, 2, 3, 4, 5, 6, 8, 10, 12 ]
+# Experimental:
+matrix_omit_uniform_lines = False
+
# MISC
doculink_urlformat = "http://mathias-kettner.de/checkmk_%s.html";
diff --git a/web/plugins/views/layouts.py b/web/plugins/views/layouts.py
index 0b648e0..ff80763 100644
--- a/web/plugins/views/layouts.py
+++ b/web/plugins/views/layouts.py
@@ -521,7 +521,8 @@ multisite_layouts["table"] = {
def render_matrix(rows, view, group_painters, painters, num_columns,
_ignore_show_checkboxes):
header_majorities = matrix_find_majorities(rows, group_painters, True)
- row_majorities = matrix_find_majorities(rows, painters, False)
+ value_counts, row_majorities = matrix_find_majorities(rows, painters, False)
+ html.debug(value_counts)
for groups, unique_row_ids, matrix_cells in \
create_matrices(rows, group_painters, painters, num_columns):
@@ -545,6 +546,16 @@ def render_matrix(rows, view, group_painters, painters, num_columns,
_ignore_sho
# Now for each unique service^H^H^H^H^H^H ID column paint one row
for row_id in unique_row_ids:
+ # Omit rows where all cells have the same values
+ if config.matrix_omit_uniform_lines:
+ at_least_one_different = False
+ for counts in value_counts[row_id].values():
+ if len(counts) > 1:
+ at_least_one_different = True
+ break
+ if not at_least_one_different:
+ continue
+
odd = odd == "odd" and "even" or "odd"
html.write('<tr class="data %s0">' % odd)
tdclass, content = prepare_paint(painters[0],
matrix_cells[row_id].values()[0])
@@ -586,12 +597,13 @@ def matrix_find_majorities(rows, painters, for_header):
else:
row_id = tuple(group_value(row, [ painters[0] ]))
for painter_nr, painter in enumerate(painters[1:]):
- value = group_value(row, [painter])[0]
+ value = group_value(row, [painter])
row_entry = counts.setdefault(row_id, {})
painter_entry = row_entry.setdefault(painter_nr, {})
painter_entry.setdefault(value, 0)
painter_entry[value] += 1
+
# Now find majorities for each row
majorities = {} # row_id -> painter_nr -> majority value
for row_id, row_entry in counts.items():
@@ -611,7 +623,7 @@ def matrix_find_majorities(rows, painters, for_header):
if for_header:
return majorities[None]
else:
- return majorities
+ return counts, majorities
# Create list of matrices to render
def create_matrices(rows, group_painters, painters, num_columns):
@@ -633,7 +645,7 @@ def create_matrices(rows, group_painters, painters, num_columns):
for row in rows:
register_events(row) # needed for playing sounds
- group_id = tuple(group_value(row, group_painters))
+ group_id = group_value(row, group_painters)
if group_id != last_group_id:
col_num += 1
if col_num > num_columns:
@@ -649,7 +661,7 @@ def create_matrices(rows, group_painters, painters, num_columns):
# Now the rule is that the *first* column painter (usually the service
# description) will define the left legend of the matrix. It defines
# the set of possible rows.
- row_id = tuple(group_value(row, [ painters[0] ]))
+ row_id = group_value(row, [ painters[0] ])
if row_id not in matrix_cells:
unique_row_ids.append(row_id)
matrix_cells[row_id] = {}