Module: check_mk
Branch: master
Commit: a23fffdb9d2c37bf04f195cf74e72d831b096e62
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a23fffdb9d2c37…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Feb 12 18:13:06 2013 +0100
EC: New rule feature: automatically delete after action
---
ChangeLog | 2 ++
mkeventd/bin/mkeventd | 26 ++++++++++++++++++++++++++
mkeventd/web/plugins/views/mkeventd.py | 3 +++
mkeventd/web/plugins/wato/mkeventd.py | 10 ++++++++--
4 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d069874..df3d559 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,6 @@
1.2.3i1:
+ Event Console:
+ * New rule feature: automatically delete after action
1.2.2b2:
BI:
diff --git a/mkeventd/bin/mkeventd b/mkeventd/bin/mkeventd
index 6e3acfe..567eaba 100755
--- a/mkeventd/bin/mkeventd
+++ b/mkeventd/bin/mkeventd
@@ -961,6 +961,10 @@ class EventServer:
log_event_history(event, "DELAYOVER")
if rule:
do_rule_actions(rule, event)
+ if rule.get("autodelete"):
+ events_to_delete.append(nr)
+ log_event_history(event, "AUTODELETE")
+
else:
log("Cannot do rule action: rule %s not present
anymore." % event["rule_id"])
@@ -1095,6 +1099,10 @@ class EventServer:
g_event_status.new_event(event)
log_event_history(event, "COUNTFAILED")
do_rule_actions(rule, event)
+ if rule.get("autodelete"):
+ log_event_history(event, "AUTODELETE")
+ g_event_status.remove_event(event)
+
# Precompile regular expressions and similar stuff
@@ -1270,8 +1278,15 @@ class EventServer:
existing_event["phase"] = "delayed"
else:
do_rule_actions(rule, existing_event)
+
log_event_history(existing_event, "COUNTREACHED")
+ if "delay" not in rule and
rule.get("autodelete"):
+ log_event_history(existing_event,
"AUTODELETE")
+ with lock_eventstatus:
+ g_event_status.remove_event(existing_event)
+
+
elif "expect" in rule:
g_event_status.count_expected_event(event)
@@ -1287,6 +1302,10 @@ class EventServer:
g_event_status.new_event(event)
if event["phase"] == "open":
do_rule_actions(rule, event)
+ if rule.get("autodelete"):
+ log_event_history(event, "AUTODELETE")
+ with lock_eventstatus:
+ g_event_status.remove_event(event)
return
# Checks if an event matches a rule. Returns either False (no match)
@@ -2115,6 +2134,13 @@ class EventStatus():
self._events.append(event)
log_event_history(event, "NEW")
+ def remove_event(self, event):
+ try:
+ self._events.remove(event);
+ except Exception, e:
+ log("Cannot remove event %d: not present" % event["id"])
+
+
# Cancel all events the belong to a certain rule id and are
# of the same "breed" as a new event.
def cancel_events(self, new_event, match_groups, rule_id):
diff --git a/mkeventd/web/plugins/views/mkeventd.py
b/mkeventd/web/plugins/views/mkeventd.py
index 0343b62..7dfcad5 100644
--- a/mkeventd/web/plugins/views/mkeventd.py
+++ b/mkeventd/web/plugins/views/mkeventd.py
@@ -1015,6 +1015,7 @@ if mkeventd_enabled:
],
'sorters': [
('history_time', False),
+ ('history_line', True),
],
})
@@ -1088,6 +1089,7 @@ if mkeventd_enabled:
],
'sorters': [
('history_time', False),
+ ('history_line', True),
],
})
@@ -1141,5 +1143,6 @@ if mkeventd_enabled:
],
'sorters': [
('history_time', False),
+ ('history_line', True),
],
})
diff --git a/mkeventd/web/plugins/wato/mkeventd.py
b/mkeventd/web/plugins/wato/mkeventd.py
index 923a34e..96308fe 100644
--- a/mkeventd/web/plugins/wato/mkeventd.py
+++ b/mkeventd/web/plugins/wato/mkeventd.py
@@ -234,7 +234,7 @@ vs_mkeventd_rule = Dictionary(
Checkbox(
title = _("Drop Message"),
help = _("With this option all messages matching this rule will be
silently dropped."),
- label = _("Silently drop messages, do no actions"),
+ label = _("Silently drop message, do no actions"),
)
),
( "state",
@@ -257,6 +257,12 @@ vs_mkeventd_rule = Dictionary(
choices = mkeventd.action_choices,
)
),
+ ( "autodelete",
+ Checkbox(
+ title = _("Automatic Deletion"),
+ label = _("Delete event immediately after the actions"),
+ )
+ ),
( "count",
Dictionary(
title = _("Count messages in defined interval"),
@@ -613,7 +619,7 @@ vs_mkeventd_rule = Dictionary(
( _("General Properties"), [ "id", "description",
"disabled" ] ),
( _("Matching Criteria"), [ "match", "match_host",
"match_application", "match_priority", "match_facility",
"match_sl", "match_ok",
"cancel_priority" ]),
- ( _("Outcome & Action"), [ "state", "sl",
"actions", "drop" ]),
+ ( _("Outcome & Action"), [ "state", "sl",
"actions", "drop", "autodelete" ]),
( _("Counting & Timing"), [ "count",
"expect", "delay", "livetime", ]),
( _("Rewriting"), [ "set_text", "set_host",
"set_application", "set_comment", "set_contact" ]),
],