69 lines
2.7 KiB
Python
69 lines
2.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Why CDP scrape skips neko 6 on dy."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("108.174.50.68", 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False)
|
|
cmd = r"""
|
|
cd /opt/douyinWEB/backend
|
|
./.venv/bin/python - <<'PY'
|
|
from app import youtube_neko, yt_assign_db
|
|
import json
|
|
|
|
# list instances status
|
|
inst = youtube_neko.list_instances() if hasattr(youtube_neko,'list_instances') else None
|
|
print('list_instances type', type(inst))
|
|
if isinstance(inst, list):
|
|
for x in inst:
|
|
if int(x.get('id') or 0) in (1,6) or x.get('running'):
|
|
print({k:x.get(k) for k in ('id','running','ready','enabled','status','name')})
|
|
elif isinstance(inst, dict):
|
|
print(list(inst.keys())[:20])
|
|
|
|
# find scrape entrypoints
|
|
import inspect
|
|
names=[n for n in dir(youtube_neko) if 'scrape' in n.lower() or 'cdp' in n.lower() or 'telemetry' in n.lower()]
|
|
print('fns', names)
|
|
|
|
# try scrape neko 6 now
|
|
if hasattr(youtube_neko, 'scrape_studio_via_cdp'):
|
|
r = youtube_neko.scrape_studio_via_cdp(6)
|
|
print('scrape6', json.dumps(r, ensure_ascii=False, default=str)[:1500])
|
|
elif hasattr(youtube_neko, 'cdp_scrape_studio'):
|
|
r = youtube_neko.cdp_scrape_studio(6)
|
|
print('scrape6', json.dumps(r, ensure_ascii=False, default=str)[:1500])
|
|
|
|
# inspect how scrape targets chosen
|
|
src=open('app/youtube_neko.py',encoding='utf-8',errors='replace').read()
|
|
for needle in ['neko_enabled', 'cdp_studio_scrape', 'scrape_running', 'for nid', 'instance_ids']:
|
|
print('count', needle, src.count(needle))
|
|
PY
|
|
|
|
echo '=== manual cdp scrape script ==='
|
|
# find how cdp connects to neko 6
|
|
grep -n '9222\|cdp\|neko' /opt/douyinWEB/backend/neko/cdp_studio_scrape.py | head -40
|
|
# docker exec scrape
|
|
docker exec douyinweb-neko-6 curl -sS -m 3 http://127.0.0.1:9222/json/version 2>/dev/null | head -c 300; echo
|
|
# run scrape from host against container? check compose for cdp publish
|
|
docker inspect douyinweb-neko-6 --format '{{range $p,$c := .NetworkSettings.Ports}}{{$p}} -> {{$c}}{{println}}{{end}}' | head -30
|
|
ls /opt/douyinWEB/backend/data/neko/profiles/6/ 2>/dev/null | head
|
|
# extension instance id
|
|
docker exec douyinweb-neko-6 cat /etc/neko/live-ops-extension/instance_id.txt 2>/dev/null; echo
|
|
docker exec douyinweb-neko-6 ls /etc/neko/live-ops-extension/ 2>/dev/null | head
|
|
# recent api ingest logs
|
|
journalctl -u douyinweb-api --since '30 min ago' --no-pager | grep -iE 'studio|telemetry|neko.6|local:6|cdp' | tail -40
|
|
"""
|
|
_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("[stderr]", err[:2000])
|
|
c.close()
|