Module: check_mk
Branch: master
Commit: bfa3d841ee4ed6b0cbabb7b8fce9889533e3fa5d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bfa3d841ee4ed6…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Feb 26 08:12:33 2018 +0100
Improved WATO automation logging
Change-Id: I8f8ca4e2c2a3771a9d7ee70679a81008e0cece52
---
web/htdocs/watolib.py | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index 8199394..c10f4be 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -6933,6 +6933,8 @@ def check_mk_local_automation(command, args=None,
indata="", stdin_data=None, ti
if args is None:
args = []
+ auto_logger = logger.getChild("config.automations")
+
if timeout:
args = [ "--timeout", "%d" % timeout ] + args
@@ -6946,28 +6948,34 @@ def check_mk_local_automation(command, args=None,
indata="", stdin_data=None, ti
# it garbles the non-HTML response output
# if config.debug:
# html.write("<div class=message>Running
<tt>%s</tt></div>\n" % " ".join(cmd))
+ auto_logger.info("RUN: %s" % subprocess.list2cmdline(cmd))
p = subprocess.Popen(cmd,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
close_fds=True)
except Exception, e:
raise MKGeneralException("Cannot execute <tt>%s</tt>: %s" %
(" ".join(cmd), e))
if stdin_data != None:
+ auto_logger.info("STDIN: %r" % stdin_data)
p.stdin.write(stdin_data)
else:
+ auto_logger.info("STDIN: %r" % indata)
p.stdin.write(repr(indata))
p.stdin.close()
outdata = p.stdout.read()
exitcode = p.wait()
+ auto_logger.info("FINISHED: %d" % exitcode)
+ auto_logger.debug("OUTPUT: %r" % outdata)
if exitcode != 0:
- logger.error("Error running %r (exit code %d)" % ("
".join(cmd), exitcode))
+ auto_logger.error("Error running %r (exit code %d)" %
+ (subprocess.list2cmdline(cmd), exitcode))
+
if config.debug:
raise MKGeneralException("Error running <tt>%s</tt> (exit
code %d): <pre>%s</pre>" %
(" ".join(cmd), exitcode, hilite_errors(outdata)))
else:
raise MKGeneralException(hilite_errors(outdata))
-
# On successful "restart" command execute the activate changes hook
if command in [ 'restart', 'reload' ]:
call_hook_activate_changes()