Commit 0ceb4ff5 authored by Jonathan Michalon's avatar Jonathan Michalon

Add report feature

parent 50fcd4eb
......@@ -113,3 +113,6 @@ def send_email_for_check(check):
_send_email(subject, msg_text, extra_headers)
def send_email_report(text):
from . import config
_send_email(config.emails.report.subject, text)
......@@ -30,11 +30,20 @@ def usr1_handler(signum, frame):
print ("Signal SIGUSR1 caught, printing state of checks.")
print (report)
def alarm_handler(signum, frame):
(report, err) = create_report()
if err:
mails.send_email_report(report)
if __name__ == '__main__':
# register signal handling
signal.signal(signal.SIGUSR1, usr1_handler)
signal.signal(signal.SIGALRM, alarm_handler)
# register report signal interval
if config.emails.report.every > 0:
signal.setitimer(signal.ITIMER_REAL, 60, config.emails.report.every)
# Parse command line
parser = argparse.ArgumentParser()
......
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