forked from public/mirror-checker
Created OpenBSD mirror status checker
This commit is contained in:
parent
6379fb4af5
commit
708579e0db
15
main.py
15
main.py
|
@ -18,6 +18,11 @@ def get_debian_dt(trace_file_url):
|
||||||
time_str = response_text.split('\n')[0]
|
time_str = response_text.split('\n')[0]
|
||||||
return datetime.strptime(time_str, "%a %b %d %H:%M:%S UTC %Y")
|
return datetime.strptime(time_str, "%a %b %d %H:%M:%S UTC %Y")
|
||||||
|
|
||||||
|
def get_openbsd_sec(timestamp_file_url):
|
||||||
|
"""Get OpenBSD seconds since the Epoch from timestamp file"""
|
||||||
|
sec_str = requests.get(timestamp_file_url).text
|
||||||
|
return int(sec_str)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# Arch
|
# Arch
|
||||||
try:
|
try:
|
||||||
|
@ -44,3 +49,13 @@ if __name__ == "__main__":
|
||||||
print(OUTPUT.format("Debian"))
|
print(OUTPUT.format("Debian"))
|
||||||
except requests.exceptions.RequestException as err:
|
except requests.exceptions.RequestException as err:
|
||||||
print(ERROR.format("Debian", err))
|
print(ERROR.format("Debian", err))
|
||||||
|
|
||||||
|
# OpenBSD
|
||||||
|
try:
|
||||||
|
official_sec = get_openbsd_sec("https://ftp.openbsd.org/pub/OpenBSD/timestamp")
|
||||||
|
csc_sec = get_openbsd_sec(f"{CSC_MIRROR}OpenBSD/timestamp")
|
||||||
|
# Out-of-sync by 1 day maximum
|
||||||
|
OUTPUT = SUCCESS if official_sec < csc_sec + 86400 else FAILURE
|
||||||
|
print(OUTPUT.format("OpenBSD"))
|
||||||
|
except requests.exceptions.RequestException as err:
|
||||||
|
print(ERROR.format("OpenBSD", err))
|
||||||
|
|
Loading…
Reference in New Issue