Module: check_mk
Branch: master
Commit: f65a75c9a7f52b1f8761bb17ab68a1bb002c4c92
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f65a75c9a7f52b…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Dec 12 13:58:36 2017 +0100
5579 Rule event limit can now be configured individually per rule
The rule event limit can now be customized per rule. There is a new
option "Custom rule event limit" available in the EC rule editor
that can be used for this purpose.
Change-Id: Id740b84abe04fb2bf9b17b629953943c159f8818
---
.werks/5579 | 12 +++++++++
bin/mkeventd | 17 ++++++++++--
web/plugins/wato/mkeventd.py | 64 +++++++++++++++++++++++++++-----------------
3 files changed, 67 insertions(+), 26 deletions(-)
diff --git a/.werks/5579 b/.werks/5579
new file mode 100644
index 0000000..deba512
--- /dev/null
+++ b/.werks/5579
@@ -0,0 +1,12 @@
+Title: Rule event limit can now be configured individually per rule
+Level: 1
+Component: ec
+Compatible: compat
+Edition: cre
+Version: 1.5.0i2
+Date: 1513083425
+Class: feature
+
+The rule event limit can now be customized per rule. There is a new
+option "Custom rule event limit" available in the EC rule editor
+that can be used for this purpose.
diff --git a/bin/mkeventd b/bin/mkeventd
index 866ed04..353099a 100755
--- a/bin/mkeventd
+++ b/bin/mkeventd
@@ -2914,8 +2914,7 @@ class EventServer(ECServerThread):
assert ty in [ "overall", "by_rule", "by_host" ]
num_already_open = g_event_status.get_num_existing_events_by(ty, event)
- limit = g_config["event_limit"][ty]["limit"]
- action = g_config["event_limit"][ty]["action"]
+ limit, action = self._get_event_limit(ty, event)
self.logger.verbose(" Type: %s, already open events: %d, Limit: %d" %
(ty, num_already_open, limit))
# Limit not reached: add new event
@@ -2960,6 +2959,20 @@ class EventServer(ECServerThread):
return False
+ # protected by lock_eventstatus
+ def _get_event_limit(self, ty, event):
+ # Prefer the rule inidividual limit for by_rule limit (in case there is some)
+ if ty == "by_rule":
+ rule_limit =
self._rule_by_id[event["rule_id"]].get("event_limit")
+ if rule_limit:
+ return rule_limit["limit"], rule_limit["action"]
+
+ limit = g_config["event_limit"][ty]["limit"]
+ action = g_config["event_limit"][ty]["action"]
+
+ return limit, action
+
+
def _create_overflow_event(self, ty, event):
now = time.time()
new_event = {
diff --git a/web/plugins/wato/mkeventd.py b/web/plugins/wato/mkeventd.py
index cae5679..a84cd0a 100644
--- a/web/plugins/wato/mkeventd.py
+++ b/web/plugins/wato/mkeventd.py
@@ -419,6 +419,20 @@ def vs_mkeventd_rule(rule_pack):
"will be no \"open event\" to be handled by the
administrators."),
)
),
+ ("event_limit", Alternative(
+ title = _("Custom rule event limit"),
+ help = _("Use this option to override the "
+ "<a
href=\"wato.py?mode=mkeventd_edit_configvar&site=&varname=event_limit\">"
+ "global rule event limit</a>"),
+ style = "dropdown",
+ elements = [
+ FixedValue(None,
+ title = _("Use global rule limit"),
+ totext = "",
+ ),
+ vs_ec_rule_limit(),
+ ],
+ )),
( "count",
Dictionary(
title = _("Count messages in defined interval"),
@@ -848,7 +862,7 @@ def vs_mkeventd_rule(rule_pack):
( _("Matching Criteria"), [ "match",
"match_host", "match_ipaddress", "match_application",
"match_priority", "match_facility",
"match_sl", "match_ok",
"cancel_priority", "cancel_application", "match_timeperiod",
"invert_matching" ]),
( _("Outcome & Action"), [ "state", "sl",
"contact_groups", "actions", "actions_in_downtime",
- "cancel_actions",
"cancel_action_phases", "drop", "autodelete" ]),
+ "cancel_actions",
"cancel_action_phases", "drop", "autodelete",
"event_limit" ]),
( _("Counting & Timing"), [ "count",
"expect", "delay", "livetime", ]),
( _("Rewriting"), [ "set_text", "set_host",
"set_application", "set_comment", "set_contact" ]),
],
@@ -2543,6 +2557,30 @@ if mkeventd_enabled:
default_value = "stop_overflow_notify",
)
+ def vs_ec_rule_limit():
+ return Dictionary(
+ title = _("Rule limit"),
+ help = _("You can limit the number of current events created by a single
"
+ "rule here. This is meant to "
+ "prevent you from too generous rules creating a lot of
events.<br>"
+ "Once the limit is reached, the Event Console will stop the
rule "
+ "creating new current events until the number of current
"
+ "events has been reduced to be below this limit. In the "
+ "moment the limit is reached, the Event Console will notify
"
+ "the configured contacts of the rule or create a notification
"
+ "with empty contact information."),
+ elements = [
+ ("limit", Integer(
+ title = _("Limit"),
+ minvalue = 1,
+ default_value = 1000,
+ unit = _("current events"),
+ )),
+ ("action", vs_ec_event_limit_actions("notify contacts in
rule or fallback contacts")),
+ ],
+ optional_keys = [],
+ )
+
register_configvar(groups["ec"],
"event_limit",
Dictionary(
@@ -2573,28 +2611,7 @@ if mkeventd_enabled:
],
optional_keys = [],
)),
- ("by_rule", Dictionary(
- title = _("Rule limit"),
- help = _("You can limit the number of current events created by
a single "
- "rule here. This is meant to "
- "prevent you from too generous rules creating a lot of
events.<br>"
- "Once the limit is reached, the Event Console will stop
the rule "
- "creating new current events until the number of
current "
- "events has been reduced to be below this limit. In the
"
- "moment the limit is reached, the Event Console will
notify "
- "the configured contacts of the rule or create a
notification "
- "with empty contact information."),
- elements = [
- ("limit", Integer(
- title = _("Limit"),
- minvalue = 1,
- default_value = 1000,
- unit = _("current events"),
- )),
- ("action", vs_ec_event_limit_actions("notify
contacts in rule or fallback contacts")),
- ],
- optional_keys = [],
- )),
+ ("by_rule", vs_ec_rule_limit()),
("overall", Dictionary(
title = _("Overall current events"),
help = _("To protect you against a continously growing list of
current "
@@ -2852,7 +2869,6 @@ if mkeventd_enabled:
domain = ConfigDomainEventConsole,
)
-
# Settings that should also be avaiable on distributed Sites that
# do not run an own eventd but want to query one or send notifications
# to one.