Module: check_mk
Branch: master
Commit: d185327cbe65eb8e570188f1e7328838a45331c9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d185327cbe65eb…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Dec 16 15:25:08 2014 +0100
#1783 FIX Finish the view "History of Scheduled Downtimes"
Add missing filters, group by Host/Service
---
.werks/1783 | 10 ++++++++++
ChangeLog | 1 +
web/plugins/views/builtin.py | 10 +++++-----
web/plugins/views/filters.py | 4 +++-
web/plugins/views/painters.py | 19 +++++++++++++++++++
web/plugins/views/sorters.py | 13 +++++++++++++
web/plugins/visuals/filters.py | 1 +
7 files changed, 52 insertions(+), 6 deletions(-)
diff --git a/.werks/1783 b/.werks/1783
new file mode 100644
index 0000000..46f4e70
--- /dev/null
+++ b/.werks/1783
@@ -0,0 +1,10 @@
+Title: Finish the view "History of Scheduled Downtimes"
+Level: 2
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1418739860
+
+Add missing filters, group by Host/Service
diff --git a/ChangeLog b/ChangeLog
index bef521b..1b845e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -19,6 +19,7 @@
Multisite:
* 1758 Improved exception hander: Shows details without additional debug request,
added mailto link for error report...
* 1781 FIX: Fix broken grouping by host/service group in availability
+ * 1783 FIX: Finish the view "History of Scheduled Downtimes"...
WATO:
* 1760 Added search form to manual checks page
diff --git a/web/plugins/views/builtin.py b/web/plugins/views/builtin.py
index 68f230d..ff33c03 100644
--- a/web/plugins/views/builtin.py
+++ b/web/plugins/views/builtin.py
@@ -400,11 +400,11 @@ multisite_builtin_views.update({
'column_headers': 'pergroup',
'datasource': 'log_events',
'description': _('All historic scheduled downtimes of hosts and
services'),
- 'group_painters': [],
+ 'group_painters': [('log_what', None)],
'hard_filters': [ 'log_type' ],
'hard_filtervars': [('logtime_from_range', '86400'),
('logtime_from', '60'),
- ('log_type', 'SERVICE DOWNTIME ALERT'),
+ ('log_type', 'DOWNTIME ALERT'),
],
'hidden': False,
'hide_filters': [],
@@ -419,11 +419,11 @@ multisite_builtin_views.update({
('service_description', 'svc_dt_hist'),
('log_state_type', None),
('log_plugin_output', None),
- ],
+ ],
'play_sounds': False,
'public': True,
- 'show_filters': ['logtime', ],
- 'sorters': [('log_time', True), ('log_lineno',
True)],
+ 'show_filters': ['logtime', 'hostregex',
'serviceregex', 'log_state_type' ],
+ 'sorters': [('log_what', True), ('log_time', True),
('log_lineno', True), ],
'title': _('History of scheduled downtimes'),
'topic': _('Other'),
},
diff --git a/web/plugins/views/filters.py b/web/plugins/views/filters.py
index b392955..70b378c 100644
--- a/web/plugins/views/filters.py
+++ b/web/plugins/views/filters.py
@@ -25,6 +25,8 @@
# Boston, MA 02110-1301 USA.
# This file was shipped with Check_MK previous to 1.2.5i6. To prevent
-# problems during updaate, this dummy file is shipped. It overwrites
+# problems during update, this dummy file is shipped. It overwrites
# the outdated existing file and invalidates it. This can be removed
# in later versions.
+
+# The filters are now defined in plugins/visuals/filters.py
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index 1dfe48c..5ac1c23 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -1752,6 +1752,25 @@ multisite_painters["log_plugin_output"] = {
"paint" : paint_log_plugin_output,
}
+
+def paint_log_type(row):
+ lt = row["log_type"]
+ if "HOST" in lt:
+ return "", _("Host")
+ elif "SERVICE" in lt or "SVC" in lt:
+ return "", _("Service")
+ else:
+ return "", _("Program")
+
+
+multisite_painters["log_what"] = {
+ "title" : _("Log: host or service"),
+ "short" : _("Host/Service"),
+ "columns" : [ "log_type" ],
+ "paint" : paint_log_type,
+}
+
+
multisite_painters["log_attempt"] = {
"title" : _("Log: number of check attempt"),
"short" : _("Att."),
diff --git a/web/plugins/views/sorters.py b/web/plugins/views/sorters.py
index 09870d7..7e9fbf1 100644
--- a/web/plugins/views/sorters.py
+++ b/web/plugins/views/sorters.py
@@ -333,6 +333,19 @@ declare_1to1_sorter("log_contact_name",
cmp_simple_string)
declare_1to1_sorter("log_time", cmp_simple_number)
declare_1to1_sorter("log_lineno", cmp_simple_number)
+def cmp_log_what(col, a, b):
+ return cmp(log_what(a[col]), log_what(b[col]))
+
+def log_what(t):
+ if "HOST" in t:
+ return 1
+ elif "SERVICE" in t or "SVC" in t:
+ return 2
+ else:
+ return 0
+
+declare_1to1_sorter("log_what", cmp_log_what)
+
import time
def get_day_start_timestamp(t):
st = time.localtime(int(t))
diff --git a/web/plugins/visuals/filters.py b/web/plugins/visuals/filters.py
index bc4499a..f4fc53f 100644
--- a/web/plugins/visuals/filters.py
+++ b/web/plugins/visuals/filters.py
@@ -737,6 +737,7 @@ class FilterLogClass(Filter):
declare_filter(255, FilterLogClass())
declare_filter(202, FilterText("log_plugin_output", _("Log: plugin
output"), "log", "log_plugin_output",
"log_plugin_output", "~~"))
declare_filter(203, FilterText("log_type", _("Log: message type"),
"log", "log_type", "log_type", "~~"))
+declare_filter(204, FilterText("log_state_type", _("Log: state
type"), "log", "log_state_type", "log_state_type",
"~~"))
declare_filter(260, FilterText("log_contact_name", _("Log: contact
name"), "log", "log_contact_name",
"log_contact_name", "="),
_("Exact match, used for linking"))