62 lines
2.0 KiB
Python
62 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""Compare live-map counts on VPS vs physical via SSH (no auth)."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
REMOTE = r'''
|
|
import asyncio, json, os, sys
|
|
os.chdir("/opt/douyinWEB/backend")
|
|
sys.path.insert(0, ".")
|
|
from app import youtube_live
|
|
from app import youtube_relay_pipeline as yrp
|
|
|
|
async def main():
|
|
m = await youtube_live.build_live_map(force=True)
|
|
entries = m.get("entries") or {}
|
|
live = [(k, v.get("source"), (v.get("title") or "")[:40]) for k,v in entries.items() if v.get("is_live")]
|
|
print("live_count", m.get("live_count"), "source", m.get("source"), "svc_error", (m.get("svc_error") or "")[:120])
|
|
print("live_entries", len(live))
|
|
for row in live[:20]:
|
|
print(" ", row)
|
|
st = yrp.youtube_relay_pipeline.status()
|
|
pushing = [g for g in (st.get("groups") or []) if g.get("is_pushing") or str(g.get("status") or "") == "pushing"]
|
|
print("relay_pushing", len(pushing))
|
|
for g in pushing[:8]:
|
|
print(" ", g.get("group_id"), g.get("name") or g.get("title"), g.get("status"))
|
|
|
|
asyncio.run(main())
|
|
'''
|
|
|
|
|
|
def probe(label, host, port, user, pwd, sudo=False):
|
|
print(f"\n===== {label} =====")
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(host, port, user, pwd, timeout=30, allow_agent=False, look_for_keys=False)
|
|
sftp = c.open_sftp()
|
|
with sftp.file("/tmp/_cmp_live_map.py", "w") as f:
|
|
f.write(REMOTE)
|
|
sftp.close()
|
|
py = "/opt/douyinWEB/backend/.venv/bin/python"
|
|
cmd = f"{py} /tmp/_cmp_live_map.py"
|
|
if sudo:
|
|
cmd = f"echo '{pwd}' | sudo -S -p '' {cmd}"
|
|
_, o, e = c.exec_command(cmd, timeout=120)
|
|
print((o.read() + e.read()).decode("utf-8", "replace")[:2500])
|
|
c.close()
|
|
|
|
|
|
def main():
|
|
probe("dylive/VPS", "107.173.30.245", 22, "root", "Xiao4669805", sudo=False)
|
|
probe("dy/physical", "107.173.30.245", 4014, "eric", "4669805", sudo=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|