#!/usr/bin/env python3 """Quick follow-up: docker names + listen ports only.""" from __future__ import annotations import sys import time import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") def connect(): for i in range(10): try: c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect( "107.173.30.245", 22, "root", "Xiao4669805", timeout=40, banner_timeout=120, allow_agent=False, look_for_keys=False, ) print("connected", i, flush=True) return c except Exception as ex: print("retry", i, ex, flush=True) time.sleep(5) raise SystemExit("ssh fail") def run(c, cmd, t=45): print(f"\n$ {cmd}", flush=True) _i, o, e = c.exec_command(cmd, timeout=t) # read with channel timeout chan = o.channel chan.settimeout(t) data = b"" while True: try: chunk = chan.recv(8192) if not chunk: break data += chunk if len(data) > 20000: break except Exception: break err = b"" try: err = e.read(4096) except Exception: pass print((data + err).decode("utf-8", "replace")[:18000], flush=True) c = connect() try: run(c, "timeout 20 docker ps -a --format '{{.Names}}|{{.Status}}' 2>/dev/null | head -40", 30) run(c, "timeout 15 ss -lnt | awk 'NR==1 || /LISTEN/' | head -60", 25) run(c, "timeout 10 systemctl is-active douyinweb-api douyinweb-web douyinweb-yt douyinweb-pb caddy nginx seaweed-s3 frpp 'wg-quick@wg-dy' sing-box 2>/dev/null; " "cd /opt/douyinWEB && git rev-parse --short HEAD 2>/dev/null", 20) finally: c.close() print("DONE", flush=True)