Module: check_mk
Branch: master
Commit: 1143bef2030c98e1b4bc35bde3577ddf0938e4be
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1143bef2030c98…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Nov 16 12:32:23 2012 +0100
Allow event expiration also on acknowledged events (configurable)
---
ChangeLog | 1 +
mkeventd/bin/mkeventd | 26 +++++++++++++++++++-------
mkeventd/web/plugins/wato/mkeventd.py | 27 +++++++++++++++++++++++----
3 files changed, 43 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 595d878..e7d4a27 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,6 +22,7 @@
* New button for generating test events directly via WATO
* Allow Event Console to replicate from another (master) console for
fast failover.
+ * Allow event expiration also on acknowledged events (configurable)
Multisite:
* Enable automation login with _username= and _secret=, while
diff --git a/mkeventd/bin/mkeventd b/mkeventd/bin/mkeventd
index 58d3599..b8b4d94 100755
--- a/mkeventd/bin/mkeventd
+++ b/mkeventd/bin/mkeventd
@@ -727,12 +727,14 @@ class EventServer:
# Handle events with a limited lifetime
- elif event["phase"] == "open" and "live_until" in event:
+ elif "live_until" in event:
if now >= event["live_until"]:
- events_to_delete.append(nr)
- log("Livetime of event %d (rule %s) exceeded. Deleting event." % (
- event["id"], event["rule_id"]))
- log_event_history(event, "EXPIRED")
+ allowed_phases = event.get("live_until_phases", ["open"])
+ if event["phase"] in allowed_phases:
+ events_to_delete.append(nr)
+ log("Livetime of event %d (rule %s) exceeded. Deleting event." % (
+ event["id"], event["rule_id"]))
+ log_event_history(event, "EXPIRED")
# Do delayed deletion now (was delayed in order to keep list indices OK)
@@ -871,6 +873,13 @@ class EventServer:
else:
count_rules += 1
rule = rule.copy() # keep original intact because of slave replication
+
+ # Convert some data fields into newer format
+ if "livetime" in rule:
+ livetime = rule["livetime"]
+ if type(livetime) != tuple:
+ rule["livetime"] = ( livetime, ["open"] )
+
self._rules.append(rule)
self._rule_by_id[rule["id"]] = rule
try:
@@ -1980,9 +1989,12 @@ class EventStatus():
def do_rule_actions(rule, event):
# Prepare for events with a limited livetime. This time starts
- # when the event enters the open state.
+ # when the event enters the open state or acked state
if "livetime" in rule:
- event["live_until"] = time.time() + rule["livetime"]
+ livetime, phases = rule["livetime"]
+ event["live_until"] = time.time() + livetime
+ event["live_until_phases"] = phases
+
for aname in rule.get("actions", []):
action = g_config["action"].get(aname)
if not action:
diff --git a/mkeventd/web/plugins/wato/mkeventd.py b/mkeventd/web/plugins/wato/mkeventd.py
index ceaf169..b083d1a 100644
--- a/mkeventd/web/plugins/wato/mkeventd.py
+++ b/mkeventd/web/plugins/wato/mkeventd.py
@@ -422,10 +422,22 @@ vs_mkeventd_rule = Dictionary(
"rule."))
),
( "livetime",
- Age(
- title = _("Limit event livetime"),
- help = _("If you set a livetime of an event, then it will automatically be "
- "deleted after that time if, even if no action has taken by the user."),
+ Tuple(
+ title = _("Limit event livetime"),
+ help = _("If you set a livetime of an event, then it will automatically be "
+ "deleted after that time if, even if no action has taken by the user. You can "
+ "decide whether to expire open, acknowledged or both types of events. The lifetime "
+ "always starts when the event is entering the open state."),
+ elements = [
+ Age(),
+ ListChoice(
+ choices = [
+ ( "open", _("Expire events that are in state <i>open</i>") ),
+ ( "ack", _("Expire events thar are in state <i>acknowledged</i>") ),
+ ],
+ default_value = [ "open" ],
+ )
+ ],
),
),
( "match",
@@ -659,6 +671,13 @@ def load_mkeventd_rules():
for rule in vars["rules"]:
rule["hits"] = rule_stats.get(rule["id"], 0)
+ # Convert some data fields into a new format
+ for rule in vars["rules"]:
+ if "livetime" in rule:
+ livetime = rule["livetime"]
+ if type(livetime) != tuple:
+ rule["livetime"] = ( livetime, ["open"] )
+
return vars["rules"]
except Exception, e:
Module: check_mk
Branch: master
Commit: 229d9171d92f9c9ab852f62664155959d988565d
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=229d9171d92f9c…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Nov 15 22:49:25 2012 +0100
mkeventd: fixed spelling of takeover
---
mkeventd/web/plugins/wato/mkeventd.py | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/mkeventd/web/plugins/wato/mkeventd.py b/mkeventd/web/plugins/wato/mkeventd.py
index ccbc447..ceaf169 100644
--- a/mkeventd/web/plugins/wato/mkeventd.py
+++ b/mkeventd/web/plugins/wato/mkeventd.py
@@ -768,7 +768,7 @@ def mode_mkeventd_rules(phase):
if rep_mode in [ "sync", "takeover" ]:
html.show_warning(_("WARNING: This Event Console is currently running as a replication "
"slave. The rules edited here will not be used. Instead a copy of the rules of the "
- "master are being used in the case of a take over. The same holds for the event "
+ "master are being used in the case of a takeover. The same holds for the event "
"actions in the global settings."))
if len(rules) == 0:
@@ -1104,7 +1104,7 @@ def mode_mkeventd_status(phase):
html.write("<li>%s</li>" % _("Event Daemon is running."))
html.write("<li>%s: <b>%s</b></li>" % (_("Current replication mode"),
{ "sync" : _("synchronize"),
- "takeover" : _("Take Over!"),
+ "takeover" : _("Takeover!"),
}.get(repl_mode, _("master / standalone"))))
if repl_mode in [ "sync", "takeover" ]:
html.write(("<li>" + _("Status of last synchronization: <b>%s</b>") + "</li>") % (
@@ -1120,7 +1120,7 @@ def mode_mkeventd_status(phase):
if config.may("mkeventd.switchmode"):
html.begin_form("switch")
if repl_mode == "sync":
- html.button("_switch_takeover", _("Switch to Take Over mode!"))
+ html.button("_switch_takeover", _("Switch to Takeover mode!"))
elif repl_mode == "takeover":
html.button("_switch_sync", _("Switch back to sync mode!"))
html.hidden_fields()
@@ -1305,9 +1305,9 @@ if mkeventd_enabled:
Integer(
title = _("Automatic takeover"),
help = _("If you enable this option then the slave will automatically "
- "take over and enable event processing if the master is for "
+ "takeover and enable event processing if the master is for "
"the configured number of seconds unreachable."),
- label = _("Take over after a master downtime of"),
+ label = _("Takeover after a master downtime of"),
unit = _("sec"),
minvalue = 1,
default_value = 30,