Module: check_mk
Branch: master
Commit: fedd793164218a56e945b123fe41a04f2240cb8b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fedd793164218a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Apr 6 16:16:15 2016 +0200
3372 FIX check_mailboxes: Improved error handling
---
.werks/3372 | 10 ++++++++++
ChangeLog | 1 +
doc/treasures/active_checks/check_mailboxes | 22 ++++++++++++++++------
3 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/.werks/3372 b/.werks/3372
new file mode 100644
index 0000000..a02ffa8
--- /dev/null
+++ b/.werks/3372
@@ -0,0 +1,10 @@
+Title: check_mailboxes: Improved error handling
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1459952151
+
+
diff --git a/ChangeLog b/ChangeLog
index 2ff2488..13bcb10 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -132,6 +132,7 @@
* 3367 FIX: nginx_status: Fixed local instance detection for IPv6 loopback address
* 3368 FIX: Fixed regression since 1.2.8b9 which broke all SNMP checks with Nagios
core
* 3370 FIX: check_mail: Fixed mail parsing bug when using POP3
+ * 3372 FIX: check_mailboxes: Improved error handling
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/doc/treasures/active_checks/check_mailboxes
b/doc/treasures/active_checks/check_mailboxes
index e17fcac..359bd68 100755
--- a/doc/treasures/active_checks/check_mailboxes
+++ b/doc/treasures/active_checks/check_mailboxes
@@ -34,6 +34,7 @@ import email
import email.utils
import re
import socket
+import traceback
from optparse import OptionParser
@@ -154,10 +155,9 @@ class Age(object):
def output(message):
- sys.stdout.write(message)
+ sys.stdout.write(message+"\n")
-
-def main():
+def parse_args():
parser = OptionParser()
parser.add_option("-d", "--debug", action="store_true",
default=False,
help="print debugging information")
@@ -197,8 +197,12 @@ def main():
for mandatory in ["server", "username"]:
if getattr(options, mandatory) is None:
parser.error("--%s not set" % mandatory)
- return 1
+ sys.exit(1)
+
+ return options
+
+def main(options):
if options.password is None:
from getpass import getpass
options.password = getpass()
@@ -291,5 +295,11 @@ def main():
if __name__ == "__main__":
- main()
-
+ options = parse_args()
+ try:
+ main(options)
+ except Exception, e:
+ output("An exception occured (Run in debug mode for details): %s" % e)
+ if options.debug:
+ output(traceback.format_exc())
+ sys.exit(3)