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

85 lines
2.8 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Diagnose covers + ops-neko routing on VPS / physical (read-only)."""
import sys
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
def ssh(host, port, user, pw):
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(host, port, user, pw, timeout=40, banner_timeout=80, allow_agent=False, look_for_keys=False)
return c
def run(c, cmd, t=60):
_i, o, e = c.exec_command(cmd, timeout=t)
return (o.read() + e.read()).decode("utf-8", "replace")
print("===== VPS probes =====")
v = ssh("107.173.30.245", 22, "root", "Xiao4669805")
print(
run(
v,
r"""
set +e
echo '-- public --'
for u in \
'https://dylive.nomadro.com/api/health' \
'https://dy.nomadro.com/api/health' \
'https://dy.nomadro.com/ops-neko/1' \
'https://dy.nomadro.com/ops-neko/1/' \
'https://dy.nomadro.com/neko/1/' \
'https://dylive.nomadro.com/douyin-covers/' \
'https://dy.nomadro.com/douyin-covers/'
do
code=$(curl -sS -m 12 -o /dev/null -w '%{http_code}' -L "$u" 2>/dev/null || echo err)
echo "$code $u"
done
echo '-- caddy dy site snippets --'
grep -nE 'douyin-covers|ops-neko|/neko/|8333|18200|10\.8\.0\.2' /etc/caddy/sites/*.caddy 2>/dev/null | head -80
echo '-- local weed --'
ss -lntup 2>/dev/null | grep -E ':8333|:18200|:9200' || netstat -lntup 2>/dev/null | grep -E ':8333|:18200|:9200'
curl -sS -m 5 -o /dev/null -w 'vps_weed_8333=%{http_code}\n' http://127.0.0.1:8333/ 2>/dev/null
curl -sS -m 5 -o /dev/null -w 'frp_aux_18333=%{http_code}\n' http://127.0.0.1:18333/ 2>/dev/null
""",
90,
)
)
v.close()
print("===== PHYSICAL probes =====")
p = ssh("107.173.30.245", 4014, "eric", "4669805")
print(
run(
p,
r"""echo '4669805' | sudo -S -p '' bash -lc '
set +e
ss -lntup 2>/dev/null | grep -E ":8333|:18200|:9200" | head -20
docker ps -a --format "{{.Names}} {{.Status}} {{.Ports}}" 2>/dev/null | grep -E "ops-neko|douyinweb-neko" | head -20
curl -sS -m 5 --noproxy "*" -o /dev/null -w "local_weed=%{http_code}\n" http://127.0.0.1:8333/
curl -sS -m 5 --noproxy "*" -o /dev/null -w "opsneko1=%{http_code}\n" http://127.0.0.1:18200/
curl -sS -m 5 --noproxy "*" -o /dev/null -w "neko1=%{http_code}\n" http://127.0.0.1:9200/
# sample cover from db
python3 - <<"PY"
import sqlite3, json
c=sqlite3.connect("/opt/douyinWEB/backend/data/monitor.db")
rows=c.execute("select id, cover_url, cover_path from sessions where cover_url!=\"\" or cover_path!=\"\" order by started_at desc limit 3").fetchall()
print("sessions_covers", rows)
# try rooms
try:
print("settings s3", [(k, str(v)[:80]) for k,v in c.execute("select key,value from kv_settings where key like \"%s3%\" or key like \"%cover%\" or key like \"%S3%\"").fetchall()][:20])
except Exception as e:
print(e)
c.close()
PY
'
""",
90,
)
)
p.close()