Module: check_mk
Branch: master
Commit: 0c87091b2a9e4fc09fa9c4ab813d786e16cc91b9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0c87091b2a9e4f…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Thu Aug 18 11:34:05 2016 +0200
3776 check_mail_loop: now you can specify the subject text instead of default
'Check_MK-Mail-Loop'
---
.werks/3776 | 9 +++++++++
ChangeLog | 1 +
checks/check_mail_loop | 4 +++-
doc/treasures/active_checks/check_mail_loop | 10 +++++++---
web/plugins/wato/active_checks.py | 8 +++++++-
5 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/.werks/3776 b/.werks/3776
new file mode 100644
index 0000000..89d75ae
--- /dev/null
+++ b/.werks/3776
@@ -0,0 +1,9 @@
+Title: check_mail_loop: now you can specify the subject text instead of default
'Check_MK-Mail-Loop'
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.4.0i1
+Date: 1471512811
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 4c3a97d..5f367f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -128,6 +128,7 @@
* 3784 agent_netapp / 7mode: now also reports snapsvaults for the default filer...
* 3832 diskstat: added new device bcache
* 3775 fjdarye500_pfm: new check which monitors health status and lifetime of PCIe
flash modules of Eternus DX500 storage systems
+ * 3776 check_mail_loop: now you can specify the subject text instead of default
'Check_MK-Mail-Loop'
* 3073 FIX: windows agent: relative paths to mrpe scripts are now treated as relative
to the agent installation directory...
* 3061 FIX: mk_jolokia: Fixed debugging of the agent plugin
* 3074 FIX: windows agent: fixed incorrect values for 32-bit performance counters
diff --git a/checks/check_mail_loop b/checks/check_mail_loop
index 6121d49..b905fbc 100644
--- a/checks/check_mail_loop
+++ b/checks/check_mail_loop
@@ -77,6 +77,9 @@ def check_mail_loop_arguments(params):
args += [ '--warning=%d' % params['duration'][0] ]
args += [ '--critical=%d' % params['duration'][1] ]
+ if 'subject' in params:
+ args += ' --subject=%s' % quote_shell_string(params['subject'])
+
return args
@@ -86,4 +89,3 @@ active_check_info['mail_loop'] = {
"service_description" : lambda params: "Mail Loop %s" %
params['item'],
"has_perfdata" : True,
}
-
diff --git a/doc/treasures/active_checks/check_mail_loop
b/doc/treasures/active_checks/check_mail_loop
index ff4288f..b795765 100755
--- a/doc/treasures/active_checks/check_mail_loop
+++ b/doc/treasures/active_checks/check_mail_loop
@@ -84,6 +84,8 @@ OPTIONS:
check plugin. This is disabled by default, which
might make your mailbox grow when you not clean it up
manually.
+ --subject SUBJECT You can specify the subject text. If choosen the subject
+ 'Check_MK-Mail-Loop' will be replace by the stated
text.
-d, --debug Enable debug mode
-h, --help Show this help message and exit
@@ -129,7 +131,7 @@ conn_timeout = 10
delete_messages = False
status_dir = None
status_suffix = None
-
+subject = 'Check_MK-Mail-Loop'
for o,a in opts:
if o in [ '-h', '--help' ]:
usage()
@@ -175,6 +177,8 @@ for o,a in opts:
status_dir = a
elif o == '--status-suffix':
status_suffix = a
+ elif o == '--subject':
+ subject = a
param_names = dict(opts).keys()
for p in required_params:
@@ -287,7 +291,7 @@ def fetch_mails():
raise Exception('Failed to fetch mail %s (%s). Available
messages: %r' % (num, parse_exception(e), messages))
# Now filter out the messages for this check
- pattern = re.compile('(?:Re: |WG: )?Check_MK-Mail-Loop ([^\s]+)
([^\s]+)')
+ pattern = re.compile('(?:Re: |WG: )?%s ([^\s]+) ([^\s]+)' % subject)
for index, msg in mails.items():
matches = pattern.match(msg.get('Subject', ''))
if matches:
@@ -324,7 +328,7 @@ def send_mail():
mail = email.mime.text.MIMEText("")
mail['From'] = mail_from
mail['To'] = mail_from
- mail['Subject'] = 'Check_MK-Mail-Loop %d %d' % (now, key)
+ mail['Subject'] = '%s %d %d' % (subject, now, key)
try:
S = smtplib.SMTP(smtp_server, smtp_port)
diff --git a/web/plugins/wato/active_checks.py b/web/plugins/wato/active_checks.py
index 20140a4..99f47ba 100644
--- a/web/plugins/wato/active_checks.py
+++ b/web/plugins/wato/active_checks.py
@@ -1803,13 +1803,19 @@ register_rule(group,
'the SMTP protocol and then tries to receive these mails back by
querying the '
'inbox of a IMAP or POP3 mailbox. With this check you can verify
that your whole '
'mail delivery progress is working.'),
- optional_keys = ['smtp_server', 'smtp_tls', 'smtp_port',
'smtp_auth', 'imap_tls', 'connect_timeout',
'delete_messages', 'duration'],
+ optional_keys = ['subject', 'smtp_server', 'smtp_tls',
'smtp_port', 'smtp_auth', 'imap_tls', 'connect_timeout',
'delete_messages', 'duration'],
elements = [
('item', TextUnicode(
title = _('Name'),
help = _('The service description will be <b>Mail
Loop</b> plus this name'),
allow_empty = False
)),
+ ('subject', TextAscii(
+ title = _('Subject'),
+ allow_empty = False,
+ help = _('Here you can specify the subject text '
+ 'instead of default text
\'Check_MK-Mail-Loop\'.'),
+ )),
('smtp_server', TextAscii(
title = _('SMTP Server'),
allow_empty = False,