douyinWEB/scripts/_diag_neko3_tm4.py
2026-09-13 22:10:49 -05:00

55 lines
1.9 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import annotations
import sys
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
# Avoid heredocs: one docker-exec python -c at a time
CMDS = [
"docker exec douyinweb-neko-3 supervisorctl status google-chrome",
"docker exec douyinweb-neko-3 wc -l /etc/neko/browser-launch.sh; docker exec douyinweb-neko-3 sed -n '1,15p' /etc/neko/browser-launch.sh",
"docker exec douyinweb-neko-3 sed -n '250,340p' /etc/neko/browser-launch.sh",
"""docker exec douyinweb-neko-3 python3 -c "import os; ids=[p for p in os.listdir('/proc') if p.isdigit()];
print('pids',len(ids));
[
print(pid, open('/proc/%s/cmdline'%pid,'rb').read().replace(b'\\x00',b' ').decode('utf-8','replace')[:300])
for pid in ids
if b'chrome' in open('/proc/%s/cmdline'%pid,'rb').read().lower() or b'browser-launch' in open('/proc/%s/cmdline'%pid,'rb').read()
]
" """.replace("\n", " "),
'docker exec douyinweb-neko-3 sh -c \'tail -n 80 /var/log/neko/google-chrome.log 2>/dev/null || tail -n 80 /var/log/supervisor/google-chrome*.log 2>/dev/null; ls -la /var/log/neko/ 2>/dev/null | head\'',
'docker exec douyinweb-neko-3 python3 -c "import json,urllib.request; print(json.loads(urllib.request.urlopen(\'http://127.0.0.1:9222/json/version\',timeout=3).read()))"',
]
def main() -> None:
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(
"107.173.30.245",
4014,
"eric",
"4669805",
timeout=45,
allow_agent=False,
look_for_keys=False,
banner_timeout=120,
)
for cmd in CMDS:
print("\n#####", cmd[:120])
_i, o, e = c.exec_command(
f"echo '4669805' | sudo -S -p '' bash -lc {cmd!r}",
timeout=60,
)
out = (o.read() + e.read()).decode("utf-8", "replace")
print(out[:4000])
c.close()
if __name__ == "__main__":
main()