Module: check_mk
Branch: master
Commit: d41622019e299d873dba56c46fb2b3da729e0c93
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d41622019e299d…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jan 13 10:40:33 2015 +0100
#1811 Added new filter for regex based filtering of contacts to log based views
This filter can be used to filter monitoring log based views by a regex matching
the contact name. Additionally the filter can be negated.
---
.werks/1811 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/views.css | 4 ++++
web/plugins/visuals/filters.py | 28 +++++++++++++++++++++-------
4 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/.werks/1811 b/.werks/1811
new file mode 100644
index 0000000..82b6834
--- /dev/null
+++ b/.werks/1811
@@ -0,0 +1,10 @@
+Title: Added new filter for regex based filtering of contacts to log based views
+Level: 1
+Component: multisite
+Compatible: compat
+Version: 1.2.7i1
+Date: 1421141961
+Class: feature
+
+This filter can be used to filter monitoring log based views by a regex matching
+the contact name. Additionally the filter can be negated.
diff --git a/ChangeLog b/ChangeLog
index e09bcfc..b0640a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -65,6 +65,7 @@
* 1758 Improved exception hander: Shows details without additional debug request,
added mailto link for error report...
* 1788 New personal setting for start page, right after login...
* 1776 Dashboard: Allowing unicode characters in static text dashlet
+ * 1811 Added new filter for regex based filtering of contacts to log based views...
* 1781 FIX: Fix broken grouping by host/service group in availability
* 1783 FIX: Finish the view "History of Scheduled Downtimes"...
* 1206 FIX: Hostname not longer shown as column in host views
diff --git a/web/htdocs/views.css b/web/htdocs/views.css
index 75e1f1d..f4df338 100644
--- a/web/htdocs/views.css
+++ b/web/htdocs/views.css
@@ -68,6 +68,10 @@ div.floatfilter {
color: black;
}
+div.floatfilter input[type=text].neg {
+ width: 229px;
+}
+
div.floatfilter.double {
height: 110px;
display: table-cell;
diff --git a/web/plugins/visuals/filters.py b/web/plugins/visuals/filters.py
index f4fc53f..3a6d547 100644
--- a/web/plugins/visuals/filters.py
+++ b/web/plugins/visuals/filters.py
@@ -28,21 +28,33 @@
# Filters for substring search, displaying a text input field
class FilterText(Filter):
- def __init__(self, name, title, info, column, htmlvar, op):
- Filter.__init__(self, name, title, info, [htmlvar], [column])
+ def __init__(self, name, title, info, column, htmlvar, op, negateable=False):
+ htmlvars = [htmlvar]
+ if negateable:
+ htmlvars.append("neg_" + htmlvar)
+ Filter.__init__(self, name, title, info, htmlvars, [column])
self.op = op
self.column = column
+ self.negateable = negateable
def display(self):
htmlvar = self.htmlvars[0]
current_value = html.var(htmlvar, "")
- html.text_input(htmlvar, current_value)
+ html.text_input(htmlvar, current_value, self.negateable and 'neg' or
'')
+ if self.negateable:
+ html.write(" <nobr>")
+ html.checkbox(self.htmlvars[1], label=_("negate"))
+ html.write("</nobr>")
def filter(self, infoname):
htmlvar = self.htmlvars[0]
current_value = html.var(htmlvar)
+ if self.negateable and html.get_checkbox(self.htmlvars[1]):
+ negate = "!"
+ else:
+ negate = ""
if current_value:
- return "Filter: %s %s %s\n" % (self.column, self.op,
lqencode(current_value))
+ return "Filter: %s %s%s %s\n" % (self.column, negate, self.op,
lqencode(current_value))
else:
return ""
@@ -735,11 +747,13 @@ class FilterLogClass(Filter):
return "".join(headers) + ("Or: %d\n" % len(headers))
declare_filter(255, FilterLogClass())
+# filter title info column
htmlvar
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", "="),
+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
(exact match)"), "log", "log_contact_name",
"log_contact_name", "="),
_("Exact match, used for linking"))
+declare_filter(261, FilterText("log_contact_name_regex", _("Log: contact
name"), "log", "log_contact_name",
"log_contact_name_regex", "~~", negateable=True))
class FilterLogState(Filter):
def __init__(self):