sh2/d2ypp2/tools/diag_host04_ffmpeg_match.py
2026-06-14 10:41:48 -05:00

41 lines
1.5 KiB
Python

#!/usr/bin/env python3
import paramiko
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
BASE = "/home/eric/d2ypp2-src"
REMOTE_PY = f"""
import os, json
from pathlib import Path
os.chdir('{BASE}')
import sys
sys.path.insert(0, '{BASE}')
from src.web_process_backend import (
_linux_ffmpeg_pids_for_process_tree,
_linux_ffmpeg_pids_for_stack,
_ffmpeg_cmdline_markers,
_ffmpeg_pid_matches_process,
_read_proc_env_value,
)
ff = [int(x) for x in os.popen("pgrep -f 'ffmpeg.*rtmps'").read().split() if x.strip().isdigit()]
print('ffmpeg_pids', ff)
for pid in ff[:3]:
cmd = (Path('/proc')/str(pid)/'cmdline').read_bytes().replace(b'\\0', b' ').decode('utf-8','replace')[:300]
print('cmd', pid, cmd)
for proc in ['youtube2__ch_mpwri36r_z5lm2','youtube2__ch_mpyvqkc0_gj63k']:
print(' env_match', proc, _ffmpeg_pid_matches_process(pid, proc))
print(' markers', _ffmpeg_cmdline_markers(proc, Path('{BASE}'))[:4])
for proc in ['youtube2__ch_mpwri36r_z5lm2','youtube2__ch_mpyvqkc0_gj63k']:
ypid = [x for x in os.popen(f"pgrep -f 'youtube.py'").read().split() if x.strip().isdigit()]
print('proc', proc, 'youtube_pids', ypid[:4])
stack = _linux_ffmpeg_pids_for_stack(proc, Path('{BASE}'))
print(' stack_match', stack)
"""
c = paramiko.SSHClient(); c.set_missing_host_key_policy(paramiko.AutoAddPolicy()); c.connect(HOST, username=USER, password=PASS, timeout=20)
_, o, e = c.exec_command(f"cd {BASE} && .venv/bin/python - <<'PY'\n{REMOTE_PY}\nPY", timeout=90)
print((o.read()+e.read()).decode('utf-8','replace'))
c.close()