Module: check_mk
Branch: master
Commit: ce6107e1bfad4c750af91d4f3f9a4c857f588e7c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ce6107e1bfad4c…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Tue Oct 15 14:51:57 2013 +0200
Blacklisting for services in the felixble notification system
---
ChangeLog | 3 +++
modules/notify.py | 15 +++++++++++++++
web/htdocs/wato.py | 12 +++++++++++-
3 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index cae8fd0..af4610f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -19,6 +19,9 @@
* FIX: Fix output format python for several numeric columns
* FIX: Fixed searching hosts by aliases/adresses
+ Notifications:
+ * Blacklisting for services in the felixble notification system
+
Checks & Agents:
* diskstat: removed (ever incorrect) latency computation for Linux
* statgrab_load: support predictive levels, add perf-o-meter
diff --git a/modules/notify.py b/modules/notify.py
index 253326a..5bc52c2 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -588,6 +588,21 @@ def should_notify(context, entry):
notify_log(" - Skipping: service level %d not between %d and %d" %
(sl, from_sl, to_sl))
return False
+ # Skip blacklistet serivces
+ if entry.get("service_blacklist"):
+ servicedesc = context.get("SERVICEDESC")
+ if not servicedesc:
+ notify_log(" - Proceed: blacklist certain services, but this is a host
notification")
+ else:
+ for s in entry["service_blacklist"]:
+ if re.match(s, servicedesc):
+ notify_log(" - Skipping: service '%s' matches blacklist
(%s)" % (
+ servicedesc, ",
".join(entry["service_blacklist"])))
+ return False
+
+
+
+
# Check service, if configured
if entry.get("only_services"):
servicedesc = context.get("SERVICEDESC")
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 016174e..a573c7d 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -8266,7 +8266,7 @@ def load_notification_table():
ListOf(
Foldable(
Dictionary(
- optional_keys = [ "only_hosts",
"only_services", "escalation" , "match_sl"],
+ optional_keys = [ "service_blacklist",
"only_hosts", "only_services", "escalation" ,
"match_sl"],
columns = 1,
headers = True,
elements = [
@@ -8379,6 +8379,16 @@ def load_notification_table():
validate = validate_only_services,
),
),
+ ( "service_blacklist",
+ ListOfStrings(
+ title = _("Blacklist the following
services"),
+ help = _("Configure regular expressions that
match the beginning of the service names here. Prefix an "
+ "entry with <tt>!</tt>
in order to <i>exclude</i> that service."),
+ orientation = "horizontal",
+ valuespec = RegExp(size = 20),
+ validate = validate_only_services,
+ ),
+ ),
]
),
title_function = lambda v: _("Notify by: ") +
notification_script_title(v["plugin"]),