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 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'bin') 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') -- cgit v1.2.3