Module: check_mk
Branch: master
Commit: e073632d283e3323c92b95d16f126521594f632c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e073632d283e33…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Feb 28 10:29:10 2014 +0100
RBN: option for matching the plugin output
---
modules/notify.py | 14 ++++++++++++++
web/htdocs/wato.py | 15 +++++++++++++--
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/modules/notify.py b/modules/notify.py
index 49bfd4d..b8c2c75 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -1016,6 +1016,7 @@ def rbn_match_rule(rule, context):
rbn_match_exclude_hosts(rule, context) or \
rbn_match_services(rule, context) or \
rbn_match_exclude_services(rule, context) or \
+ rbn_match_plugin_output(rule, context) or \
rbn_match_checktype(rule, context) or \
rbn_match_timeperiod(rule) or \
rbn_match_escalation(rule, context) or \
@@ -1063,6 +1064,19 @@ def rbn_match_exclude_services(rule, context):
return "The service's description '%s' matches the list of
excluded services" \
% context["SERVICEDESC"]
+def rbn_match_plugin_output(rule, context):
+ if "match_plugin_output" in rule:
+ r = regex(rule["match_plugin_output"])
+
+ if context["WHAT"] == "SERVICE":
+ output = context["SERVICEOUTPUT"]
+ else:
+ output = context["HOSTOUTPUT"]
+ if not r.search(output):
+ return "The expression '%s' cannot be found in the plugin output
'%s'" % \
+ (rule["match_plugin_output"], output)
+
+
def rbn_match_checktype(rule, context):
if "match_checktype" in rule:
if context["WHAT"] != "SERVICE":
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 393fb03..ef2860c 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -7486,6 +7486,13 @@ def vs_notification_rule(userid = None):
orientation = "horizontal",
)
),
+ ( "match_plugin_output",
+ RegExp(
+ title = _("Match the output of the check plugin"),
+ help = _("This text is a regular expression that is being searched
in the output "
+ "of the check plugins that produced the alert. It is not a
prefix but an infix match."),
+ ),
+ ),
( "match_checktype",
CheckTypeSelection(
title = _("Match the following check types"),
@@ -7619,6 +7626,7 @@ def vs_notification_rule(userid = None):
],
optional_keys = [ "match_hosttags", "match_hosts",
"match_exclude_hosts", "match_services",
"match_exclude_services",
+ "match_plugin_output",
"match_timeperiod", "match_escalation",
"match_sl", "match_host_event", "match_service_event",
"match_checktype", "contact_contacts",
"contact_groups", "contact_emails" ],
headers = [
@@ -7627,7 +7635,7 @@ def vs_notification_rule(userid = None):
+ contact_headers
+ [
( _("Conditions"), [ "match_hosttags",
"match_hosts", "match_exclude_hosts",
- "match_services",
"match_exclude_services",
+ "match_services",
"match_exclude_services", "match_plugin_output",
"match_checktype",
"match_timeperiod",
"match_escalation",
"match_sl", "match_host_event", "match_service_event" ] ),
],
@@ -7891,7 +7899,10 @@ def mode_notifications(phase):
table.cell(css="buttons")
analyse_url = html.makeuri([("analyse", str(nr))])
- html.icon_button(analyse_url, _("Anaylse ruleset with this
notification"), "analyze")
+ context = entry.items()
+ context.sort()
+ tooltip = "".join("%s: %s\n" % e for e in context)
+ html.icon_button(analyse_url, _("Anaylse ruleset with this
notification:\n" + tooltip), "analyze")
replay_url = html.makeactionuri([("_replay", str(nr))])
html.icon_button(replay_url, _("Replay this notification, send it
again!"), "replay")
if html.var("analyse") and nr ==
int(html.var("analyse")):