sh2/d2ypp2/tools/_diag_host03_neko.py
2026-06-14 18:35:41 -05:00

51 lines
2.4 KiB
Python

#!/usr/bin/env python3
import paramiko
HOST, PW = "10.88.0.3", "Xiao4669805"
BASE = "/home/eric/d2ypp2-src"
CMDS = [
("docker_ps", "docker ps -a --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}' 2>/dev/null | grep -i neko; true"),
("curl_9200", "curl -sS -m 8 -o /dev/null -w '9200 http=%{http_code} time=%{time_total}\n' http://127.0.0.1:9200/ 2>&1; true"),
("curl_9201", "curl -sS -m 8 -o /dev/null -w '9201 http=%{http_code} time=%{time_total}\n' http://127.0.0.1:9201/ 2>&1; true"),
("curl_wg", "curl -sS -m 8 -o /dev/null -w '10.88.0.3:9200 http=%{http_code}\n' http://10.88.0.3:9200/ 2>&1; true"),
("ss_ports", "ss -tlnp 2>/dev/null | grep -E ':9200|:9201' || echo no_listener"),
("inspect1", "docker inspect live-neko-1 --format '{{.State.Status}} health={{if .State.Health}}{{.State.Health.Status}}{{end}} err={{.State.Error}}' 2>/dev/null || echo missing"),
("inspect2", "docker inspect live-neko-2 --format '{{.State.Status}} health={{if .State.Health}}{{.State.Health.Status}}{{end}} err={{.State.Error}}' 2>/dev/null || echo missing"),
("logs1", "docker logs --tail 50 live-neko-1 2>&1"),
("logs2", "docker logs --tail 50 live-neko-2 2>&1"),
(
"neko_status",
f"cd {BASE} && . scripts/linux/lib/common.sh && load_env && bash scripts/linux/service_ctl.sh neko status 2>&1 | head -80",
),
(
"stack_env",
f"grep -E 'NEKO|ENABLE_NEKO|SHELLCRASH|WEBRTC' {BASE}/config/system-stack.env 2>/dev/null | head -40 || echo no_env",
),
(
"compose",
f"ls -la {BASE}/services/neko/*.yml {BASE}/services/neko/*.yaml 2>/dev/null; "
f"grep -E '9200|9201|NEKO|proxy' {BASE}/services/neko/docker-compose.yml 2>/dev/null | head -30",
),
("iptables", "sudo -S -p '' iptables -L INPUT -n 2>/dev/null | head -20 || true"),
]
def main() -> None:
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(HOST, username="eric", password=PW, timeout=15)
for name, cmd in CMDS:
print(f"\n=== {name} ===")
stdin, stdout, stderr = c.exec_command(cmd, timeout=90, get_pty=True)
if name == "iptables":
stdin.write(PW + "\n")
stdin.flush()
out = (stdout.read() + stderr.read()).decode("utf-8", "replace")
print(out[:4000].encode("ascii", "backslashreplace").decode())
c.close()
if __name__ == "__main__":
main()