#!/usr/bin/env python3 """Read-only inventory of dylive VPS services for operator review.""" from __future__ import annotations import sys import time import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") HOST = "107.173.30.245" PASS = "Xiao4669805" def connect(): last = None for i in range(15): try: c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect( HOST, 22, "root", PASS, timeout=45, banner_timeout=120, allow_agent=False, look_for_keys=False, ) print(f"connected attempt={i}", flush=True) return c except Exception as ex: last = ex print(f"retry {i} {type(ex).__name__}: {ex}", flush=True) time.sleep(6) raise SystemExit(f"ssh failed: {last}") def run(c, title: str, cmd: str, timeout: int = 90) -> str: print(f"\n## {title}", flush=True) print(f"$ {cmd}", flush=True) _i, o, e = c.exec_command(cmd, timeout=timeout) out = (o.read() + e.read()).decode("utf-8", "replace") text = out[-15000:] if len(out) > 15000 else out print(text if text.strip() else "(empty)", flush=True) return out def main() -> int: c = connect() try: run(c, "host / load", "hostname; uptime; free -h; df -h / /var /opt 2>/dev/null | grep -v tmpfs") run( c, "running systemd services", "systemctl list-units --type=service --state=running --no-pager --no-legend", ) run( c, "enabled non-default-ish units", "systemctl list-unit-files --type=service --state=enabled --no-pager --no-legend", ) run( c, "douyinweb / project units", "systemctl list-units --all --no-pager 'douyinweb*' 'caddy*' 'nginx*' 'docker*' " "'wg*' 'frp*' 'sing*' 'shellcrash*' 'clash*' 's3*' 'minio*' 'seaweed*' 2>/dev/null; " "ls -la /etc/systemd/system/douyinweb* /etc/systemd/system/*neko* 2>/dev/null; " "systemctl cat douyinweb-api 2>/dev/null | head -40", ) run( c, "docker containers", "docker ps -a --format 'table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}' 2>/dev/null", timeout=60, ) run( c, "listening ports", "ss -lntup 2>/dev/null | head -120", ) run( c, "top memory processes", "ps aux --sort=-%mem | head -30", ) run( c, "top cpu processes", "ps aux --sort=-%cpu | head -20", ) run( c, "caddy / nginx sites", "command -v caddy nginx; " "ls /etc/caddy 2>/dev/null; ls /etc/caddy/Caddyfile* 2>/dev/null; " "(test -f /etc/caddy/Caddyfile && grep -E '^[a-zA-Z0-9.*_-]+' /etc/caddy/Caddyfile | head -40); " "ls /etc/nginx/sites-enabled /www/server/panel/vhost/nginx 2>/dev/null | head -40; " "systemctl is-active caddy nginx 2>/dev/null", ) run( c, "wireguard / frp / proxy hubs", "wg show 2>/dev/null | head -80; " "systemctl is-active 'wg-quick@*' frps frpc 2>/dev/null; " "ls /etc/wireguard 2>/dev/null; " "ps aux | grep -E '[f]rp|[s]ing-box|[c]lash|[s]hellcrash|[m]ihomo' | head -20", ) run( c, "project health quick", "cd /opt/douyinWEB 2>/dev/null && git rev-parse --short HEAD && git status -sb; " "curl -sS -m 8 http://127.0.0.1:8014/api/health | head -c 600; echo; " "curl -sS -m 8 -o /dev/null -w 'public_health=%{http_code}\\n' https://dylive.nomadro.com/api/health || true", timeout=40, ) run( c, "cron / timers", "systemctl list-timers --all --no-pager | head -40; " "crontab -l 2>/dev/null; ls /etc/cron.d 2>/dev/null", ) print("\nDONE inventory", flush=True) return 0 finally: c.close() if __name__ == "__main__": raise SystemExit(main())