57 lines
2.1 KiB
Python
57 lines
2.1 KiB
Python
import urllib.request
|
|
import ssl
|
|
import sys
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
|
|
ctx = ssl.create_default_context()
|
|
ctx.check_hostname = False
|
|
ctx.verify_mode = ssl.CERT_NONE
|
|
|
|
class NoRedirectHandler(urllib.request.HTTPRedirectHandler):
|
|
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
|
return None
|
|
|
|
opener = urllib.request.build_opener(NoRedirectHandler)
|
|
|
|
services = [
|
|
("Pi-hole 1 (Aerodrome)", "https://pihole1.snarfnet.net/"),
|
|
("Pi-hole 2 (Spaceport)", "https://pihole2.snarfnet.net/"),
|
|
("Technitium DNS 1", "https://dns1.snarfnet.net/"),
|
|
("Technitium DNS 2", "https://dns2.snarfnet.net/"),
|
|
("Longhorn Aerodrome", "https://longhorn.aerodrome.snarfnet.net/"),
|
|
("Semaphore UI", "https://semaphore.snarfnet.net/"),
|
|
("Uptime Kuma", "https://uptime.snarfnet.net/"),
|
|
("Synology SN-NAS", "https://sn-nas.snarfnet.net/"),
|
|
("Synology SnarfNAS", "https://snarfnas.snarfnet.net/"),
|
|
]
|
|
|
|
print("=================================================================")
|
|
print(" SNARFNET INFRASTRUCTURE HEALTH CHECK ")
|
|
print("=================================================================")
|
|
|
|
all_ok = True
|
|
for name, url in services:
|
|
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"})
|
|
try:
|
|
resp = opener.open(req, timeout=8)
|
|
print(f" [PASS] {name:<22} | Status: {resp.status} {resp.reason}")
|
|
except urllib.error.HTTPError as e:
|
|
loc = e.headers.get('Location', '')
|
|
if loc:
|
|
loc_summary = loc.split('?')[0]
|
|
print(f" [PASS] {name:<22} | Status: {e.code} -> Redirects to {loc_summary}")
|
|
else:
|
|
print(f" [PASS] {name:<22} | Status: {e.code} {e.reason}")
|
|
except Exception as e:
|
|
print(f" [FAIL] {name:<22} | Error: {e}")
|
|
all_ok = False
|
|
|
|
print("=================================================================")
|
|
if all_ok:
|
|
print("ALL SERVICES OPERATIONAL & VERIFIED HEALTHY")
|
|
else:
|
|
print("SOME CHECKS REPORTED ISSUES")
|
|
print("=================================================================")
|
|
|