Module: check_mk
Branch: master
Commit: eeff3ca077ed8a1efe51cc601aa0afa76c1c0897
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=eeff3ca077ed8a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Dec 12 15:21:14 2017 +0100
5580 Host event limit can now be configured individuall per Host & service ruleset
The host event limit can now be customized per host & service parameter ruleset.
There is a new ruleset named "Host event limit" available to configure the host
event limit individually for overriding the global limit.
Change-Id: I0d1d144db13ad21de4a71877b97ddb3bfb14a896
---
.werks/5580 | 12 +++++++++
bin/mkeventd | 10 +++++++-
web/plugins/wato/mkeventd.py | 58 +++++++++++++++++++++++++++-----------------
3 files changed, 57 insertions(+), 23 deletions(-)
diff --git a/.werks/5580 b/.werks/5580
new file mode 100644
index 0000000..308ec43
--- /dev/null
+++ b/.werks/5580
@@ -0,0 +1,12 @@
+Title: Host event limit can now be configured individuall per Host & service ruleset
+Level: 1
+Component: ec
+Compatible: compat
+Edition: cre
+Version: 1.5.0i2
+Date: 1513088405
+Class: feature
+
+The host event limit can now be customized per host & service parameter ruleset.
+There is a new ruleset named "Host event limit" available to configure the
host
+event limit individually for overriding the global limit.
diff --git a/bin/mkeventd b/bin/mkeventd
index 353099a..e8d0b58 100755
--- a/bin/mkeventd
+++ b/bin/mkeventd
@@ -2961,12 +2961,20 @@ class EventServer(ECServerThread):
# 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)
+ # Prefer the rule individual 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"]
+ # Prefer the host individual limit for by_host limit (in case there is some)
+ if ty == "by_host":
+ host_config = g_event_server.host_config.get(event["core_host"],
{})
+ host_limit = host_config.get("custom_variables",
{}).get("EC_EVENT_LIMIT")
+ if host_limit:
+ limit, action = host_limit.split(":", 1)
+ return int(limit), action
+
limit = g_config["event_limit"][ty]["limit"]
action = g_config["event_limit"][ty]["action"]
diff --git a/web/plugins/wato/mkeventd.py b/web/plugins/wato/mkeventd.py
index a84cd0a..bd1e8a4 100644
--- a/web/plugins/wato/mkeventd.py
+++ b/web/plugins/wato/mkeventd.py
@@ -2581,6 +2581,40 @@ if mkeventd_enabled:
optional_keys = [],
)
+ def vs_ec_host_limit(title):
+ return Dictionary(
+ title = title,
+ help = _("You can limit the number of current events created by a single
"
+ "host here. This is meant to "
+ "prevent you from message storms created by one
device.<br>"
+ "Once the limit is reached, the Event Console will block
"
+ "all future incoming messages sent by this host 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 host."),
+ elements = [
+ ("limit", Integer(
+ title = _("Limit"),
+ minvalue = 1,
+ default_value = 1000,
+ unit = _("current events"),
+ )),
+ ("action", vs_ec_event_limit_actions("notify contacts of
the host")),
+ ],
+ optional_keys = [],
+ )
+
+ register_rule(
+ "eventconsole",
+ "extra_host_conf:_ec_event_limit",
+ Transform(vs_ec_host_limit(title=_("Host event limit")),
+ forth = lambda x: dict([("limit", int(x.split(":")[0])),
("action", x.split(":")[1])]),
+ back = lambda x: "%d:%s" % (x["limit"],
x["action"]),
+ ),
+ match = "first",
+ )
+
register_configvar(groups["ec"],
"event_limit",
Dictionary(
@@ -2589,28 +2623,7 @@ if mkeventd_enabled:
"problems which may occur in case of too many current events at
the "
"same time."),
elements = [
- ("by_host", Dictionary(
- title = _("Host limit"),
- help = _("You can limit the number of current events created by
a single "
- "host here. This is meant to "
- "prevent you from message storms created by one
device.<br>"
- "Once the limit is reached, the Event Console will
block "
- "all future incoming messages sent by this host 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 host."),
- elements = [
- ("limit", Integer(
- title = _("Limit"),
- minvalue = 1,
- default_value = 1000,
- unit = _("current events"),
- )),
- ("action", vs_ec_event_limit_actions("notify
contacts of the host")),
- ],
- optional_keys = [],
- )),
+ ("by_host", vs_ec_host_limit(title=_("Host
limit"))),
("by_rule", vs_ec_rule_limit()),
("overall", Dictionary(
title = _("Overall current events"),
@@ -3129,6 +3142,7 @@ register_rule(
itemtype = 'service',
match = 'first',
)
+
#.
# .--Notifications-------------------------------------------------------.
# | _ _ _ _ __ _ _ _ |