41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import time
|
|
|
|
import paramiko
|
|
|
|
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
|
LANES = ["youtube2__ch_mpwri36r_z5lm2", "youtube2__ch_mpyvqkc0_gj63k"]
|
|
|
|
|
|
def run(c, cmd, timeout=60):
|
|
_, o, e = c.exec_command(cmd, timeout=timeout, get_pty=True)
|
|
return (o.read() + e.read()).decode("utf-8", "replace")
|
|
|
|
|
|
def main():
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, username=USER, password=PASS, timeout=20)
|
|
print("waiting 45s for stable push...")
|
|
time.sleep(45)
|
|
print(run(c, "pgrep -af 'ffmpeg.*rtmps' || echo none"))
|
|
for lane in LANES:
|
|
print(f"\n=== {lane} log tail ===")
|
|
print(run(c, f"grep -E 'speed=|stream copy|并发推流|FFmpeg]' /home/eric/d2ypp2-src/.pm2/logs/{lane}-out.log | tail -8"))
|
|
raw = run(c, "curl -sS -m 15 'http://127.0.0.1:8001/process_monitor?family=youtube&light=1'")
|
|
data = json.loads(raw)
|
|
for entry in data.get("entries", []):
|
|
if entry.get("pm2") in LANES:
|
|
print(
|
|
f"\n{entry['pm2']}: {entry.get('business_status')} "
|
|
f"speed={entry.get('ffmpeg_speed')} low={entry.get('ffmpeg_speed_low')}"
|
|
)
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|