maybe ready for prod

This commit is contained in:
Christoph J. Scherr 2023-05-22 15:07:43 +02:00
parent 5b203904db
commit ea511a6d67
Signed by: PlexSheep
GPG Key ID: 25B4ACF7D88186CC
2 changed files with 12 additions and 4 deletions

View File

@ -0,0 +1 @@
python-daemon==3.0.1

View File

@ -1,18 +1,20 @@
import http.client
import daemon
from time import sleep
import datetime
from socket import socket
TIMEOUT: float = 1
TESTDOMAINS: list[str] = ["cscherr.de", "debian.org", "cloudflare.com"]
def check_net() -> bool:
overall: bool = True
statuses: list[bool] = []
for domain in TESTDOMAINS:
status, msg = reachable(domain)
overall &= status
statuses.append(status)
print(f"{domain:60s} {msg}")
overall = False
for s in statuses:
overall |= s
return overall
def reachable(domain: str) -> tuple[bool, str]:
@ -36,4 +38,9 @@ def monitor():
print(e)
if __name__ == "__main__":
print("executing as normal script")
monitor()
with daemon.DaemonContext():
print("entering daemon mode")
monitor()