63 lines
1.9 KiB
Python
63 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Probe memory pressure on dylive (read-only)."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
|
|
def ssh():
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(
|
|
"107.173.30.245",
|
|
22,
|
|
"root",
|
|
"Xiao4669805",
|
|
timeout=45,
|
|
allow_agent=False,
|
|
look_for_keys=False,
|
|
banner_timeout=120,
|
|
)
|
|
return c
|
|
|
|
|
|
def run(c, cmd, t=60):
|
|
print(f"\n$ {cmd[:200]}", flush=True)
|
|
_i, o, e = c.exec_command(cmd, timeout=t)
|
|
print((o.read() + e.read()).decode("utf-8", "replace")[-14000:], flush=True)
|
|
return o.channel.recv_exit_status()
|
|
|
|
|
|
c = ssh()
|
|
run(
|
|
c,
|
|
r"""
|
|
set +e
|
|
echo ===MEM===
|
|
free -h
|
|
swapon --show
|
|
df -h / /swapfile 2>/dev/null | head -5
|
|
echo ===TOP===
|
|
ps -eo pid,user,rss,oom_score_adj,comm --sort=-rss | head -30
|
|
echo ===SLICES===
|
|
systemctl status douyinweb-api.service --no-pager -l 2>/dev/null | head -20
|
|
systemctl show douyinweb-api.service -p MemoryCurrent -p MemoryMax -p OOMScoreAdjust 2>/dev/null
|
|
echo ===NEKO===
|
|
docker stats --no-stream --format '{{.Name}} mem={{.MemUsage}} lim={{.MemPerc}}' $(docker ps -q --filter name=douyinweb-neko)
|
|
docker inspect douyinweb-neko-7 --format 'Mem={{.HostConfig.Memory}} OOMScoreAdj={{.HostConfig.OomScoreAdj}} OOMKilled={{.State.OOMKilled}}'
|
|
echo ===SERVICES_RSS===
|
|
for u in douyinweb-api douyinweb-web pocketbase seaweed-filer seaweed-volume umami; do
|
|
systemctl is-active $u.service 2>/dev/null && systemctl show $u.service -p MemoryCurrent -p NRestarts 2>/dev/null | tr '\n' ' '
|
|
echo " $u"
|
|
done
|
|
echo ===BROWSER_LAUNCH_FLAGS===
|
|
grep -nE 'renderer-process|memory|disable-dev-shm|js-flags|process-per' /opt/douyinWEB/backend/neko/browser-launch.sh 2>/dev/null | head -40
|
|
ls -la /swapfile /swapfile2 /var/swap* 2>/dev/null
|
|
""",
|
|
)
|
|
c.close()
|