From d7efef6a4c2306e07bba8c34ae28d6f3c79ea351 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Thu, 21 Dec 2023 10:40:59 -0800 Subject: Add feature to adjust failure threshold before errors are reported. --- bin/emailcanary | 7 ++++--- setup.py | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/emailcanary b/bin/emailcanary index 46b47e9..c8d305c 100755 --- a/bin/emailcanary +++ b/bin/emailcanary @@ -16,6 +16,7 @@ def parse_args(): parser.add_argument('-d', '--database', default='/etc/emailcanary.db', help='Specify the database to use.') parser.add_argument('-s', '--smtp', default='localhost:465', help='SMTP Server to send chirps to.') parser.add_argument('-f', '--from', dest='fromaddress', help='Specify the email address to send the ping from.') + parser.add_argument('-t', '--threshold', dest='threshold', default='1', type=int, help='The minimum number of failures before reporting.') group = parser.add_mutually_exclusive_group(required=True) group.add_argument('--chirp', metavar='listAddress', help='Send an email to the given canary list address.') @@ -63,11 +64,11 @@ def remove(db, listAddress, recepients): db.remove_account(listAddress, address) return SUCCESS -def check(db, birdie, listAddress): +def check(db, birdie, listAddress, threshold): missing = birdie.check(listAddress) missing = [x for x in missing if x[3].total_seconds() < 86400] missing = [x for x in missing if x[3].total_seconds() > 3600] - if len(missing) == 0: + if len(missing) < threshold: return SUCCESS print("list recepient uuid time") for chirp in missing: @@ -100,7 +101,7 @@ def main(): birdie.chirp(args.chirp) return SUCCESS elif args.check: - return check(db, birdie, args.check) + return check(db, birdie, args.check, args.threshold) else: raise Exception('Unknown action') diff --git a/setup.py b/setup.py index da0c698..5af4732 100644 --- a/setup.py +++ b/setup.py @@ -2,12 +2,13 @@ from setuptools import setup, find_packages setup(name='emailcanary', - version='0.1', + version='0.2', author='Jesse Morgan', author_email='jesse@jesterpm.net', url='https://jesterpm.net', download_url='http://www.my_program.org/files/', description='Email Canary sends emails to a distribution list and checks for proper distribution.', + long_description='', packages = find_packages(), include_package_data = True, -- cgit v1.2.3