#!/usr/bin/env python3 import paramiko import sys HOST = "107.173.30.245" USER = "root" PASS = "Xiao4669805" def run(client, cmd): print(">", cmd) _, stdout, stderr = client.exec_command(cmd, timeout=60) out = stdout.read().decode("utf-8", errors="replace").strip() err = stderr.read().decode("utf-8", errors="replace").strip() if out: print(out) if err: print("ERR:", err) return stdout.channel.recv_exit_status() def main(): if hasattr(sys.stdout, "reconfigure"): sys.stdout.reconfigure(encoding="utf-8", errors="replace") client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(HOST, username=USER, password=PASS, timeout=20) print("=== STATUS ===") run(client, "pm2 status 2>/dev/null || echo PM2_NOT_INSTALLED") run(client, "curl -sf -o /dev/null -w 'app:%{http_code}' http://127.0.0.1:3000/ || echo app:DOWN") run(client, "curl -sf -o /dev/null -w 'nginx:%{http_code}' http://127.0.0.1/ || echo nginx:DOWN") run(client, "test -d /var/www/ebook && cd /var/www/ebook && git log -1 --oneline || echo NO_REPO") run(client, "pgrep -af next || pgrep -af standalone || echo NO_NODE_APP") client.close() if __name__ == "__main__": main()