Module: check_mk
Branch: master
Commit: 1e6f0062e09af1fd5ab58c6c80ad1e08074a5620
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1e6f0062e09af1…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Mar 6 18:31:21 2014 +0100
RBN: implement throttling of periodic notifications
---
modules/notify.py | 37 +++++++++++++++++++++++++------------
web/htdocs/wato.py | 30 ++++++++++++++++++++++++++++--
2 files changed, 53 insertions(+), 14 deletions(-)
diff --git a/modules/notify.py b/modules/notify.py
index 058b278..caef69f 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -583,18 +583,19 @@ def rbn_match_rule(rule, context):
return "This rule is disabled"
return \
- rbn_match_folder(rule, context) or \
- rbn_match_hosttags(rule, context) or \
- rbn_match_hosts(rule, context) or \
- rbn_match_exclude_hosts(rule, context) or \
- rbn_match_services(rule, context) or \
- rbn_match_exclude_services(rule, context) or \
- rbn_match_plugin_output(rule, context) or \
- rbn_match_checktype(rule, context) or \
- rbn_match_timeperiod(rule) or \
- rbn_match_escalation(rule, context) or \
- rbn_match_servicelevel(rule, context) or \
- rbn_match_host_event(rule, context) or \
+ rbn_match_folder(rule, context) or \
+ rbn_match_hosttags(rule, context) or \
+ rbn_match_hosts(rule, context) or \
+ rbn_match_exclude_hosts(rule, context) or \
+ rbn_match_services(rule, context) or \
+ rbn_match_exclude_services(rule, context) or \
+ rbn_match_plugin_output(rule, context) or \
+ rbn_match_checktype(rule, context) or \
+ rbn_match_timeperiod(rule) or \
+ rbn_match_escalation(rule, context) or \
+ rbn_match_escalation_throtte(rule, context) or \
+ rbn_match_servicelevel(rule, context) or \
+ rbn_match_host_event(rule, context) or \
rbn_match_service_event(rule, context)
@@ -708,6 +709,18 @@ def rbn_match_escalation(rule, context):
return "The notification number %d does not lie in range %d ... %d"
% (
notification_number, from_number, to_number)
+def rbn_match_escalation_throtte(rule, context):
+ if "match_escalation_throttle" in rule:
+ from_number, rate = rule["match_escalation_throttle"]
+ if context["WHAT"] == "HOST":
+ notification_number = int(context.get("HOSTNOTIFICATIONNUMBER",
1))
+ else:
+ notification_number = int(context.get("SERVICENOTIFICATIONNUMBER",
1))
+ if notification_number <= from_number:
+ return
+ if (notification_number - from_number) % rate != 0:
+ return "This notification is being skipped due to throttling. The next
number will be %d" % \
+ (notification_number + rate - ((notification_number - from_number) %
rate))
def rbn_match_servicelevel(rule, context):
if "match_sl" in rule:
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 8c04161..1839917 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -7574,6 +7574,30 @@ def vs_notification_rule(userid = None):
],
),
),
+ ( "match_escalation_throttle",
+ Tuple(
+ title = _("Throttle periodic notifications"),
+ help = _("This match option allows you to throttle periodic
notifications after "
+ "a certain number of notifications have been created by
the monitoring "
+ "core. If you for example select 10 as the beginning and
5 as the rate "
+ "then you will receive the notification 1 through 10 and
then 15, 20, "
+ "25.. and so on."),
+ orientation = "float",
+ elements = [
+ Integer(
+ label = _("beginning from notifcation number"),
+ default_value = 10,
+ minvalue = 1,
+ ),
+ Integer(
+ label = _("send only every"),
+ default_value = 5,
+ unit = _("th notification"),
+ minvalue = 1,
+ )
+ ],
+ )
+ ),
( "match_sl",
Tuple(
title = _("Match service level"),
@@ -7702,7 +7726,8 @@ def vs_notification_rule(userid = None):
],
optional_keys = [ "match_folder", "match_hosttags",
"match_hosts", "match_exclude_hosts",
"match_services", "match_exclude_services",
"match_plugin_output",
- "match_timeperiod", "match_escalation",
"match_sl", "match_host_event", "match_service_event",
+ "match_timeperiod", "match_escalation",
"match_escalation_throttle",
+ "match_sl", "match_host_event",
"match_service_event",
"match_checktype", "bulk",
"contact_users", "contact_groups", "contact_emails" ],
headers = [
( _("General Properties"), [ "description",
"disabled", "allow_disable" ] ),
@@ -7712,7 +7737,8 @@ def vs_notification_rule(userid = None):
( _("Conditions"), [ "match_folder",
"match_hosttags", "match_hosts", "match_exclude_hosts",
"match_services",
"match_exclude_services", "match_plugin_output",
"match_checktype",
"match_timeperiod",
- "match_escalation",
"match_sl", "match_host_event", "match_service_event" ] ),
+ "match_escalation",
"match_escalation_throttle",
+ "match_sl",
"match_host_event", "match_service_event" ] ),
],
render = "form",
form_narrow = True,