Module: check_mk
Branch: master
Commit: dd2bf8d640ce878d03177c1e0117bb0bad7e7bc9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dd2bf8d640ce87…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri Sep 15 07:44:08 2017 +0200
updated werk 5127
Change-Id: Ib425c61d5fd299d44a871ed8f2dab22682da0531
---
notifications/asciimail | 18 ++++++++++++------
notifications/mail | 18 ++++++++++++------
2 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/notifications/asciimail b/notifications/asciimail
index 94f17d8..cd2f6e1 100755
--- a/notifications/asciimail
+++ b/notifications/asciimail
@@ -215,19 +215,25 @@ def read_bulk_contexts():
return parameters, contexts
-def get_bulk_notification_subject(parameters, contexts, hosts):
+def get_bulk_notification_subject(contexts, hosts):
hosts = list(hosts)
- if parameters.get("PARAMETER_BULK_SUBJECT"):
- subject = parameters["PARAMETER_BULK_SUBJECT"]
+ bulk_subject = None
+ for context in contexts:
+ if context.get("PARAMETER_BULK_SUBJECT"):
+ bulk_subject = context["PARAMETER_BULK_SUBJECT"]
+ break
+
+ if bulk_subject:
+ subject = bulk_subject
elif len(hosts) == 1:
subject = "Check_MK: $COUNT_NOTIFICATIONS$ notifications for %s" %
hosts[0]
else:
subject = "Check_MK: $COUNT_NOTIFICATIONS$ notifications for $COUNT_HOSTS$
hosts"
if "$COUNT_NOTIFICATIONS$" in subject:
- subject.replace("$COUNT_NOTIFICATIONS$", len(contexts))
+ subject = subject.replace("$COUNT_NOTIFICATIONS$", str(len(contexts)))
if "$COUNT_HOSTS$" in subject:
- subject.replace("$COUNT_HOSTS$", len(hosts))
+ subject = subject.replace("$COUNT_HOSTS$", str(len(hosts)))
return subject
@@ -242,7 +248,7 @@ def main():
mailto = context['CONTACTEMAIL'] # Assume the same in each context
subject = context['SUBJECT']
hosts.add(context["HOSTNAME"])
- subject = get_bulk_notification_subject(parameters, contexts, hosts)
+ subject = get_bulk_notification_subject(contexts, hosts)
else:
# gather all options from env
diff --git a/notifications/mail b/notifications/mail
index 8cbdadd..464704d 100755
--- a/notifications/mail
+++ b/notifications/mail
@@ -949,19 +949,25 @@ def read_bulk_contexts():
return parameters, contexts
-def get_bulk_notification_subject(parameters, contexts, hosts):
+def get_bulk_notification_subject(contexts, hosts):
hosts = list(hosts)
- if parameters.get("PARAMETER_BULK_SUBJECT"):
- subject = parameters["PARAMETER_BULK_SUBJECT"]
+ bulk_subject = None
+ for context in contexts:
+ if context.get("PARAMETER_BULK_SUBJECT"):
+ bulk_subject = context["PARAMETER_BULK_SUBJECT"]
+ break
+
+ if bulk_subject:
+ subject = bulk_subject
elif len(hosts) == 1:
subject = "Check_MK: $COUNT_NOTIFICATIONS$ notifications for %s" %
hosts[0]
else:
subject = "Check_MK: $COUNT_NOTIFICATIONS$ notifications for $COUNT_HOSTS$
hosts"
if "$COUNT_NOTIFICATIONS$" in subject:
- subject.replace("$COUNT_NOTIFICATIONS$", len(contexts))
+ subject = subject.replace("$COUNT_NOTIFICATIONS$", str(len(contexts)))
if "$COUNT_HOSTS$" in subject:
- subject.replace("$COUNT_HOSTS$", len(hosts))
+ subject = subject.replace("$COUNT_HOSTS$", str(len(hosts)))
return subject
@@ -981,7 +987,7 @@ def main():
mailto = context['CONTACTEMAIL'] # Assume the same in each context
subject = context['SUBJECT']
hosts.add(context["HOSTNAME"])
- subject = get_bulk_notification_subject(parameters, contexts, hosts)
+ subject = get_bulk_notification_subject(contexts, hosts)
else:
# gather all options from env