Module: check_mk
Branch: master
Commit: fab45e2b3d7d747f33c542c91fb38ff8df70c43e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fab45e2b3d7d74…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Thu Jul 5 11:33:47 2018 +0200
6119 FIX asciimail, mail: display the custom host and service notes URL correctly in
notifications
Change-Id: Id93aac1983f38d7c4a06ecda022dfc690ae2f71e
---
.werks/6119 | 10 ++++++++++
notifications/asciimail | 5 +++++
notifications/mail | 7 +++++++
3 files changed, 22 insertions(+)
diff --git a/.werks/6119 b/.werks/6119
new file mode 100644
index 0000000..00e5256
--- /dev/null
+++ b/.werks/6119
@@ -0,0 +1,10 @@
+Title: asciimail, mail: display the custom host and service notes URL correctly in
notifications
+Level: 1
+Component: notifications
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1530782196
+
diff --git a/notifications/asciimail b/notifications/asciimail
index c0a2d90..fbd11bf 100755
--- a/notifications/asciimail
+++ b/notifications/asciimail
@@ -66,6 +66,11 @@ def substitute_context(template, context):
for varname, value in context.items():
template = template.replace('$'+varname+'$', value)
+ if re.search(r"\$[A-Z_][A-Z_0-9]*\$", template):
+ # Second pass to replace nested variables inside e.g. SERVICENOTESURL
+ for varname, value in context.items():
+ template = template.replace('$'+varname+'$', value)
+
# Remove the rest of the variables and make them empty
template = re.sub(r"\$[A-Z_][A-Z_0-9]*\$", "", template)
return template
diff --git a/notifications/mail b/notifications/mail
index 8c4a8c4..7d5f749 100755
--- a/notifications/mail
+++ b/notifications/mail
@@ -394,14 +394,21 @@ tmpl_service_subject = 'Check_MK: $HOSTNAME$/$SERVICEDESC$
$EVENT_TXT$'
opt_debug = '-d' in sys.argv
bulk_mode = '--bulk' in sys.argv
+
class GraphException(Exception):
pass
+
def substitute_context(template, context):
# First replace all known variables
for varname, value in context.items():
template = template.replace('$'+varname+'$', value)
+ if re.search(r"\$[A-Z_][A-Z_0-9]*\$", template):
+ # Second pass to replace nested variables inside e.g. SERVICENOTESURL
+ for varname, value in context.items():
+ template = template.replace('$'+varname+'$', value)
+
# Debugging of variables. Create content only on demand
if "$CONTEXT_ASCII$" in template or "$CONTEXT_HTML$" in
template:
template = replace_variable_context(template, context)