douyinWEB/scripts/_diag_neko_tm2.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

47 lines
2.1 KiB
Python

# -*- coding: utf-8 -*-
from __future__ import annotations
import sys
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
HOST = "108.174.50.68"
PASS = "Xiao4669805"
CMD = r"""
for id in 1 2 3 4 5; do
name=douyinweb-neko-$id
if docker ps -a --format '{{.Names}} {{.Status}}' | grep -q "^$name "; then
echo "===== $name ====="
docker ps -a --format '{{.Names}} {{.Status}}' | grep "^$name "
if docker ps --format '{{.Names}}' | grep -qx "$name"; then
docker exec "$name" sh -c 'ls -la /home/neko/.config/chromium/Default/Extensions/dhdgffkkebhmkfjojejmpbldmpobfkfo/ 2>/dev/null || echo NO_EXT'
docker exec "$name" python3 -c "import json;from pathlib import Path;p=Path('/home/neko/.config/chromium/Default/Preferences');d=json.loads(p.read_text()) if p.exists() else {};e=d.get('extensions',{}).get('settings',{}).get('dhdgffkkebhmkfjojejmpbldmpobfkfo',{});print('tm',e.get('state'),e.get('path'),e.get('version'))"
docker exec "$name" sh -c 'grep -R -a "YouTube Studio Auto Dismiss" "/home/neko/.config/chromium/Default/Local Extension Settings/dhdgffkkebhmkfjojejmpbldmpobfkfo" 2>/dev/null | wc -c'
docker exec "$name" sh -c 'curl -fsS http://127.0.0.1:9222/json/list 2>/dev/null | python3 -c "import sys,json; tabs=json.load(sys.stdin); print(\"tabs\",len(tabs)); [print(t.get(\"url\",\"\")[:120]) for t in tabs[:15]]" 2>/dev/null || echo no_cdp'
docker exec "$name" sh -c 'grep -E "extension|tampermonkey|error|Extension" /var/log/neko/*.log 2>/dev/null | tail -20 || true'
fi
fi
done
python3 /opt/douyinWEB/backend/neko/render_tampermonkey_provisioning.py 2>/dev/null | tail -1
grep hash /opt/douyinWEB/backend/neko/policies/policies.json || true
"""
def main() -> None:
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(HOST, 22, "root", PASS, timeout=60, allow_agent=False, look_for_keys=False)
_i, o, e = c.exec_command(CMD, timeout=120)
print(o.read().decode("utf-8", "replace"))
err = e.read().decode("utf-8", "replace")
if err.strip():
print("ERR", err[:2000])
c.close()
if __name__ == "__main__":
main()