print success after fail

This commit is contained in:
Christoph J. Scherr 2023-05-29 15:45:45 +02:00
parent b90a32aad5
commit 7c195841cd
Signed by: PlexSheep
GPG Key ID: 25B4ACF7D88186CC
1 changed files with 6 additions and 0 deletions

View File

@ -31,12 +31,18 @@ def reachable(domain: str) -> tuple[bool, str]:
return False, e.__str__()
def monitor():
last_was_fail: bool = False
while True:
try:
b, msg = check_net()
if not b:
print(f":FAILURE AT {datetime.now()}:")
print(msg)
last_was_fail = True
elif b and last_was_fail:
print(f":SUCCESS AT {datetime.now()}:")
print(msg)
last_was_fail = False
sleep(SLEEPTIME)
except Exception as e:
print(e)