# -*- coding: utf-8 -*- import sys import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") HOST = "108.174.50.68" cmds = [ "systemctl is-active douyinweb-api; systemctl status douyinweb-api --no-pager -l | head -25", "journalctl -u douyinweb-api -n 60 --no-pager", "curl -sS -o /dev/null -w 'api_local=%{http_code}\n' http://127.0.0.1:8014/api/health || true", "curl -sS -o /dev/null -w 'shorts_status=%{http_code}\n' http://127.0.0.1:8014/api/shorts/status || true", "ss -ltnp | grep -E '8014|douyin' || true", ] c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(HOST, 22, "root", "Xiao4669805", timeout=45, allow_agent=False, look_for_keys=False) for cmd in cmds: print("\n===", cmd[:80], "===") _i, o, e = c.exec_command(cmd, timeout=60) out = o.read().decode("utf-8", "replace") err = e.read().decode("utf-8", "replace") print(out) if err.strip(): print("STDERR:", err[:500]) c.close()