Module: check_mk
Branch: master
Commit: be3c9c48f7012a794bbec1d7b7c707122446bf8b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=be3c9c48f7012a…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Apr 23 09:51:44 2015 +0200
#2223 Allow cancelling actions to be omitted of the cancelled event is not (yet) open
If you have an Event Console rule that uses delaying or counting at the
same time as cancelling, and if this rule furthermore defines actions when
cancelling, then you can have these actions only be executed if the event
has made it in to the <tt>open</tt> phase. The default is still the old
behaviour: that cancelling actions are also executed when the event is still
being delayed or in phase <tt>counting</tt>
---
.werks/2223 | 14 ++++++++++++++
ChangeLog | 1 +
mkeventd/bin/mkeventd | 11 ++++++++---
mkeventd/web/plugins/wato/mkeventd.py | 12 +++++++++++-
4 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/.werks/2223 b/.werks/2223
new file mode 100644
index 0000000..ad178cb
--- /dev/null
+++ b/.werks/2223
@@ -0,0 +1,14 @@
+Title: Allow cancelling actions to be omitted of the cancelled event is not (yet) open
+Level: 1
+Component: ec
+Compatible: compat
+Version: 1.2.7i1
+Date: 1429775384
+Class: feature
+
+If you have an Event Console rule that uses delaying or counting at the
+same time as cancelling, and if this rule furthermore defines actions when
+cancelling, then you can have these actions only be executed if the event
+has made it in to the <tt>open</tt> phase. The default is still the old
+behaviour: that cancelling actions are also executed when the event is still
+being delayed or in phase <tt>counting</tt>
diff --git a/ChangeLog b/ChangeLog
index e1c2c29..e69a20c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -501,6 +501,7 @@
* 1878 SEC: Fixed possible shell injection when filtering the EC archive...
* 2099 Allow replication of Event Console rule and settings...
* 2107 mkeventd: can now handle syslog format of Sophos firewalls
+ * 2223 Allow cancelling actions to be omitted of the cancelled event is not (yet)
open...
* 1839 FIX: Fix exception when notifying EC alert into monitoring for traps (because
PID is missing)
* 1813 FIX: Fixed bug in event console rule editor when no contact groups configured
* 1974 FIX: Event console views were randomly ignoring host filters...
diff --git a/mkeventd/bin/mkeventd b/mkeventd/bin/mkeventd
index 8846616..3363138 100755
--- a/mkeventd/bin/mkeventd
+++ b/mkeventd/bin/mkeventd
@@ -2925,6 +2925,7 @@ class EventStatus():
# Fill a few fields of the cancelled event with data from
# the cancelling event so that action scripts have useful
# values and the logfile entry if more relevant.
+ previous_phase = event["phase"]
event["phase"] = "closed"
event["state"] = 0 # OK
event["text"] = new_event["text"]
@@ -2933,9 +2934,13 @@ class EventStatus():
event["priority"] = new_event["priority"]
log_event_history(event, "CANCELLED")
actions = rule.get("cancel_actions", [])
- # TODO: Execute the cancelling actions only, if the event
- # was open. Do not do this e.g. on delayed or counting.
- do_event_actions(actions, event, is_cancelling = True)
+ if actions:
+ if previous_phase != "open" \
+ and rule.get("cancel_action_phases",
"always") == "open":
+ log("Do not execute cancelling actions, event
%s's phase is not 'open' but '%s'" %
+ (event["id"], previous_phase))
+ else:
+ do_event_actions(actions, event, is_cancelling = True)
to_delete.append(nr)
for nr in to_delete[::-1]:
diff --git a/mkeventd/web/plugins/wato/mkeventd.py
b/mkeventd/web/plugins/wato/mkeventd.py
index b3a2b86..da99f10 100644
--- a/mkeventd/web/plugins/wato/mkeventd.py
+++ b/mkeventd/web/plugins/wato/mkeventd.py
@@ -301,6 +301,16 @@ vs_mkeventd_rule = Dictionary(
choices = mkeventd.action_choices,
)
),
+ ( "cancel_action_phases",
+ DropdownChoice(
+ title = _("Do Cancelling-Actions when..."),
+ choices = [
+ ( "always", _("Always when an event is being
cancelled")),
+ ( "open", _("Only when the cancelled event is in phase
OPEN")),
+ ],
+ help = _("With this setting you can prevent actions to be executed when
"
+ "events are being cancelled that are in the phases DELAYED or
COUNTING."),
+ )),
( "autodelete",
Checkbox(
title = _("Automatic Deletion"),
@@ -689,7 +699,7 @@ vs_mkeventd_rule = Dictionary(
( _("Rule Properties"), [ "id", "description",
"comment", "docu_url", "disabled" ] ),
( _("Matching Criteria"), [ "match", "match_host",
"match_ipaddress", "match_application", "match_priority",
"match_facility",
"match_sl", "match_ok",
"cancel_priority", "match_timeperiod" ]),
- ( _("Outcome & Action"), [ "state", "sl",
"contact_groups", "actions", "cancel_actions",
"drop", "autodelete" ]),
+ ( _("Outcome & Action"), [ "state", "sl",
"contact_groups", "actions", "cancel_actions",
"cancel_action_phases", "drop", "autodelete" ]),
( _("Counting & Timing"), [ "count",
"expect", "delay", "livetime", ]),
( _("Rewriting"), [ "set_text", "set_host",
"set_application", "set_comment", "set_contact" ]),
],