# -*- coding: utf-8 -*- import sys import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False) cmds = [ "journalctl -u douyinweb-api --since '30 min ago' --no-pager 2>&1 | grep -E 'Publish|project/post|status_code|status_msg|Invalid|posting too|Published|Trying|error occured' | tail -80", "journalctl -u douyinweb-api --since '15 min ago' --no-pager 2>&1 | grep -vE 'GET /api/' | tail -60", ] for cmd in cmds: print("\n====", cmd[:90]) _s, out, err = c.exec_command(cmd, timeout=25) print(out.read().decode("utf-8", "replace")[-8000:]) e = err.read().decode("utf-8", "replace") if e: print("ERR:", e[:400]) c.close()