Module: check_mk
Branch: master
Commit: f58e2e9252cc972620c82837dbce3c6a4b50231e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f58e2e9252cc97…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Oct 26 11:12:40 2010 +0200
Downtimes view: Group by hosts and services - just like comments
---
ChangeLog | 1 +
web/plugins/views/builtin.py | 7 ++++---
web/plugins/views/painters.py | 6 ++++++
web/plugins/views/sorters.py | 3 +++
4 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index cdf086f..eb95080 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -24,6 +24,7 @@
Multisite:
* Snapin Performance: show external command per second and usage and
size of external command buffer
+ * Downtimes view: Group by hosts and services - just like comments
1.1.8b3:
Core, Setup, etc.:
diff --git a/web/plugins/views/builtin.py b/web/plugins/views/builtin.py
index 185d176..b6caca1 100644
--- a/web/plugins/views/builtin.py
+++ b/web/plugins/views/builtin.py
@@ -221,10 +221,10 @@ multisite_builtin_views = {
'sorters': [],
'linktitle': 'Comments',
'title': 'Comments of service'},
- 'downtimes': {'column_headers': 'perpage',
+ 'downtimes': {'column_headers': 'pergroup',
'datasource': 'downtimes',
'description': 'All host- und service-downtimes',
- 'group_painters': [],
+ 'group_painters': [('downtime_what', None)],
'hard_filters': [],
'hard_filtervars':
[('is_service_scheduled_downtime_depth',
'-1'),
@@ -247,7 +247,8 @@ multisite_builtin_views = {
'show_filters': ['service_scheduled_downtime_depth',
'hostregex',
'serviceregex'],
- 'sorters': [('downtime_start_time', False)],
+ 'sorters': [('downtime_what', False),
+ ('downtime_start_time', False)],
'title': 'Downtimes'},
'downtimes_of_host': {'column_headers': 'perpage',
'datasource': 'downtimes',
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index 6d1cfaf..1b61662 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -1180,6 +1180,12 @@ multisite_painters["downtime_fixed"] = {
"columns" : ["downtime_fixed"],
"paint" : lambda row: (None, row["downtime_fixed"] ==
"0" and "flexible" or "fixed")
}
+multisite_painters["downtime_what"] = {
+ "title" : "Downtime type (host/service)",
+ "short" : "Type",
+ "columns" : ["service_description"],
+ "paint" : lambda row: (None, row["service_description"] and
"Service" or "Host")
+}
multisite_painters["downtime_type"] = {
"title" : "Downtime active or pending",
"short" : "act/pend",
diff --git a/web/plugins/views/sorters.py b/web/plugins/views/sorters.py
index cd6cee8..d04f479 100644
--- a/web/plugins/views/sorters.py
+++ b/web/plugins/views/sorters.py
@@ -136,6 +136,8 @@ def declare_simple_sorter(name, title, column, func):
"cmp" : lambda r1, r2: func(column, r1, r2)
}
+def cmp_empty_first(column, r1, r2):
+ return { (True,True):0, (False,False):0, (True,False):-1, (False,True):1}[(not
r1[column], not r2[column])]
# name title column
sortfunction
declare_simple_sorter("svcdescr", "Service description",
"service_description", cmp_simple_string)
@@ -150,6 +152,7 @@ declare_simple_sorter("comment_author", "Comment
author", "comment_author",
declare_simple_sorter("comment_type", "Comment type",
"comment_type", cmp_simple_number)
# Downtimes
+declare_simple_sorter("downtime_what", "Downtime type
(host/service)", "service_description", cmp_empty_first)
declare_simple_sorter("downtime_start_time", "Downtime start",
"downtime_start_time", cmp_simple_number)
declare_simple_sorter("downtime_end_time", "Downtime end",
"downtime_end_time", cmp_simple_number)
declare_simple_sorter("downtime_entry_time", "Downtime entry time",
"downtime_entry_time", cmp_simple_number)