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

97 lines
3.3 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""READ-ONLY: explain what touched Neko vs frpp SSH. Log timeline only."""
from __future__ import annotations
import sys
import time
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
def ssh(port, user, pw):
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
for i in range(6):
try:
c.connect(
"107.173.30.245",
port,
user,
pw,
timeout=45,
banner_timeout=120,
allow_agent=False,
look_for_keys=False,
)
return c
except Exception as ex:
print("retry", port, i, ex, flush=True)
time.sleep(3)
raise SystemExit(f"ssh {port} fail")
def run(c, cmd, t=90):
_i, o, e = c.exec_command(cmd, timeout=t)
o.channel.recv_exit_status()
print((o.read() + e.read()).decode("utf-8", "replace"), flush=True)
print("===== VPS: frpp vs dy-frp-http-aux (what I touched) =====", flush=True)
v = ssh(22, "root", "Xiao4669805")
run(
v,
r"""
set +e
echo '--- units ---'
systemctl is-active frpp dy-frp-http-aux caddy
systemctl is-enabled frpp dy-frp-http-aux 2>/dev/null
echo '--- frpp = YOUR SSH panel (should be untouched) ---'
systemctl cat frpp 2>/dev/null | head -40
echo '--- dy-frp-http-aux = EXTRA ssh -L tunnels (THIS is what was remapped) ---'
systemctl cat dy-frp-http-aux 2>/dev/null | head -50
echo '--- bak files (proof of edits) ---'
ls -lt /etc/systemd/system/dy-frp-http-aux.service* 2>/dev/null | head -10
ls -lt /etc/caddy/sites/dy.nomadro.com.caddy* 2>/dev/null | head -15
echo '--- journal dy-frp-http-aux today ---'
journalctl -u dy-frp-http-aux --since '2026-09-05 16:00:00' --no-pager 2>/dev/null | tail -60
echo '--- journal frpp today (should be calm) ---'
journalctl -u frpp --since '2026-09-05 16:00:00' --no-pager 2>/dev/null | tail -20
echo '--- caddy reload today ---'
journalctl -u caddy --since '2026-09-05 16:00:00' --no-pager 2>/dev/null | grep -iE 'reload|stop|start|error' | tail -30
""",
)
v.close()
print("===== PHYSICAL: Neko/chrome timeline =====", flush=True)
p = ssh(4014, "eric", "4669805")
run(
p,
r"""
echo '4669805' | sudo -S -p '' bash -lc '
set +e
echo "--- container StartedAt (not recreate if old) ---"
docker ps -a --filter name=douyinweb-neko --filter name=douyinweb-ops-neko \
--format "{{.Names}}\t{{.Status}}\t{{.CreatedAt}}"
echo "--- docker events: create/destroy/die last 8h (exclude healthcheck noise) ---"
docker events --since 8h --until 0s --filter type=container 2>/dev/null \
| grep -iE "douyinweb-(neko|ops-neko)" \
| grep -iE " create | destroy | die | start | stop | kill | restart " \
| grep -vi health \
| tail -80
echo "--- api journal mentions compose/recreate/neko start last 8h ---"
journalctl -u douyinweb-api --since "8 hours ago" --no-pager 2>/dev/null \
| grep -iE "force-recreate|compose up|recreate_all|docker rm|supervisorctl|neko" \
| grep -viE "remote-catalog|GET /api" \
| tail -40
echo "--- auth.log sudo from eric (who ran what) last 8h ---"
journalctl -u ssh --since "8 hours ago" --no-pager 2>/dev/null | tail -5
grep -E "sudo|COMMAND" /var/log/auth.log 2>/dev/null | tail -40
'
""",
)
p.close()
print("DONE", flush=True)