douyinWEB/scripts/_diag_frp_panel3.py
eric d409e416da Ship physical dual-edge stack, Studio CDP live metrics, and ops tooling.
Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-04 22:42:40 -05:00

94 lines
3.4 KiB
Python

# -*- coding: utf-8 -*-
import json
import sys
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
HOST = "107.172.77.34"
USER = "root"
PASS = "Xiao4669805"
REMOTE = r'''
set +e
TOKEN=$(curl -sS -X POST 'http://127.0.0.1:9000/api/v1/auth/login' \
-H 'Content-Type: application/json' \
-d '{"username":"hackrobot","password":"Xiao4669805@"}' | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('body',{}).get('token') or '')")
echo "token_len=${#TOKEN}"
AUTH="Authorization: Bearer $TOKEN"
echo '=== baseinfo ==='
curl -sS -H "$AUTH" 'http://127.0.0.1:9000/api/v1/platform/baseinfo' | python3 -m json.tool 2>/dev/null | head -80
echo '=== server/list ==='
curl -sS -X POST -H "$AUTH" -H 'Content-Type: application/json' -d '{}' \
'http://127.0.0.1:9000/api/v1/server/list' | python3 -m json.tool 2>/dev/null | head -120
echo '=== client list (common paths) ==='
for p in /api/v1/client/list /api/v1/clients/list /api/v1/platform/client/list; do
echo "-- $p --"
curl -sS -X POST -H "$AUTH" -H 'Content-Type: application/json' -d '{}' \
"http://127.0.0.1:9000$p" --max-time 20 | head -c 1500; echo
done
echo '=== clientsstatus timing ==='
time curl -sS -X POST -H "$AUTH" -H 'Content-Type: application/json' -d '{}' \
'http://127.0.0.1:9000/api/v1/platform/clientsstatus' --max-time 30 | python3 -c "
import sys,json
raw=sys.stdin.read()
print('bytes', len(raw))
try:
d=json.loads(raw)
except Exception as e:
print('json err', e, raw[:300]); raise SystemExit
body=d.get('body') or d
print('keys', list(d.keys())[:10], 'body_type', type(body).__name__)
if isinstance(body, dict):
for k,v in list(body.items())[:20]:
if isinstance(v, list):
print(k, 'list', len(v))
for i,item in enumerate(v[:8]):
if isinstance(item, dict):
print(' ', {kk:item.get(kk) for kk in list(item)[:12]})
else:
print(' ', item)
else:
print(k, str(v)[:200])
"
echo '=== docker stats / top ==='
docker stats --no-stream --format 'table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.NetIO}}' 2>/dev/null
echo
echo '=== db size / wal ==='
ls -lah /opt/frp-panel/
sqlite3 /opt/frp-panel/data.db "PRAGMA integrity_check;" 2>/dev/null || python3 - <<'PY'
import sqlite3
c=sqlite3.connect('/opt/frp-panel/data.db')
print('integrity', c.execute('PRAGMA integrity_check').fetchone())
print('tables', [r[0] for r in c.execute("SELECT name FROM sqlite_master WHERE type='table'").fetchall()])
for t in c.execute("SELECT name FROM sqlite_master WHERE type='table'").fetchall():
n=t[0]
try:
cnt=c.execute(f'SELECT COUNT(*) FROM "{n}"').fetchone()[0]
print(f' {n}: {cnt}')
except Exception as e:
print(f' {n}: err {e}')
PY
echo '=== recent ERROR/WARN logs ==='
docker logs --since 24h frp-panel 2>&1 | grep -iE 'error|warn|panic|fail|fatal|timeout' | tail -40
echo '=== restart count / image ==='
docker inspect frp-panel --format 'Image={{.Config.Image}} RestartCount={{.RestartCount}} Started={{.State.StartedAt}} Status={{.State.Status}} OOMKilled={{.State.OOMKilled}}'
docker inspect frp-panel --format '{{range .Config.Env}}{{println .}}{{end}}' | head -40
'''
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(HOST, 22, USER, PASS, timeout=45, allow_agent=False, look_for_keys=False)
_, o, e = c.exec_command(REMOTE, timeout=180)
print(o.read().decode("utf-8", "replace"))
err = e.read().decode("utf-8", "replace")
if err.strip():
print("STDERR:", err[-2000:])
c.close()