Commit 59fb191b authored by Jonathan Michalon's avatar Jonathan Michalon

Give information about failure duration in recovery notification

parent 78fcca71
...@@ -5,6 +5,7 @@ from email.utils import make_msgid ...@@ -5,6 +5,7 @@ from email.utils import make_msgid
from collections import defaultdict from collections import defaultdict
from sys import stderr from sys import stderr
from time import strftime from time import strftime
from datetime import datetime, timedelta
import email.charset import email.charset
from threading import Thread from threading import Thread
import queue import queue
...@@ -99,10 +100,16 @@ def send_email_for_check(check): ...@@ -99,10 +100,16 @@ def send_email_for_check(check):
check=check.__class__.__name__, check=check.__class__.__name__,
dest=check.target_name)) dest=check.target_name))
msg_text = '' msg_text = "Check %s:\n" % str(check)
if not check.ok: if check.ok:
msg_text += ("Check %s failed:\n%s" % delta = datetime.now() - check.failure_date
(str(check), check.errmsg.strip())) # remove microsec
delta = delta - timedelta(microseconds=delta.microseconds)
n = delta // timedelta(seconds=check.error_every * config.base_tick)
msg_text += ("recovered after %s (%d %s)." %
(delta, n, "retry" if n == 1 else "retries"))
else:
msg_text += ("failure:\n%s" % check.errmsg.strip())
extra_headers = {} extra_headers = {}
extra_headers['Message-ID'] = make_msgid(type(check).__name__) 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