Commit 037db59a authored by Jonathan Michalon's avatar Jonathan Michalon

Provide last exec'd command in a check failure's email as debug info

parent 97eefd7b
......@@ -38,6 +38,7 @@ class Check(object):
self.error_every = self.every
self.run_count = 0
self.errmsg = ''
self.last_exec = ''
self.ok = True
self.target_name = options.get('target_name', 'Unknown')
self.timeout = options.get('timeout', 2)
......@@ -86,7 +87,10 @@ class Check(object):
def exec_with_timeout(self, command, timeout=None, pattern=''):
timeout = self.timeout if timeout is None else timeout
self.errmsg = ''
self.errmsg = ''
self.last_exec = ' '.join(map(
lambda s: "'" + s.replace("'", "'\"'\"'") + "'",
command))
try:
p = Popen(command, stdout=PIPE, stderr=PIPE)
except OSError as e:
......
......@@ -123,7 +123,8 @@ def send_email_for_check(check):
msg_text += ("recovered after %s (%d %s)." %
(delta, n, "retry" if n == 1 else "retries"))
else:
msg_text += ("failure:\n%s" % check.errmsg.strip())
msg_text += ("failure:\n%s\n" % check.errmsg.strip())
msg_text += ("\nFYI, last exec was:\n%s\n" % check.last_exec.strip())
extra_headers = {}
extra_headers['Message-ID'] = make_msgid(type(check).__name__)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment