import requests
import socket
import sys

targets = [
    {"name": "Qdrant HTTP", "host": "qdrant-b3knu-u50607.vm.elestio.app", "port": 6333, "type": "http"},
    {"name": "Redis", "host": "redis-genesis-u50607.vm.elestio.app", "port": 26379, "type": "tcp"},
    {"name": "Postgres", "host": "postgresql-genesis-u50607.vm.elestio.app", "port": 25432, "type": "tcp"}
]

print("--- Connectivity Check ---")
for t in targets:
    print(f"Checking {t['name']} ({t['host']}:{t['port']})...", end=" ")
    try:
        if t['type'] == 'http':
            url = f"https://{t['host']}:{t['port']}/dashboard"
            res = requests.get(url, timeout=5, verify=False)
            print(f"OK (HTTP {res.status_code})")
        else:
            sock = socket.create_connection((t['host'], t['port']), timeout=5)
            sock.close()
            print("OK (TCP)")
    except Exception as e:
        print(f"FAIL: {e}")
