Module: check_mk
Branch: master
Commit: c4ae1a7163a3c0fd91ad8e75d74b48fc66b090fe
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c4ae1a7163a3c0…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jan 15 16:46:51 2016 +0100
Improved error handling of web cron jobs (exceptions are logged to web.log now)
---
web/htdocs/cron.py | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/web/htdocs/cron.py b/web/htdocs/cron.py
index e98dd1e..7812478 100644
--- a/web/htdocs/cron.py
+++ b/web/htdocs/cron.py
@@ -49,6 +49,9 @@ def load_plugins(force):
# Page called by some external trigger (usually cron job in OMD site)
# Note: this URL is being called *without* any login. We have no
# user. Everyone can call this! We must not read any URL variables.
+#
+# There is no output written to the user in regular cases. Exceptions
+# are written to the web log.
def page_run_cron():
now = time.time()
# Prevent cron jobs from being run too often, also we need
@@ -61,4 +64,10 @@ def page_run_cron():
aquire_lock(lock_file)
for cron_job in multisite_cronjobs:
- cron_job()
+ try:
+ cron_job()
+ except Exception, e:
+ html.write("An exception occured. Take a look at the web.log.\n")
+ import traceback
+ logger(LOG_ERR, "Exception in cron_job [%s]:\n%s" %
+ (cron_job.__name__, traceback.format_exc()))