#!/usr/bin/env python3 """List cleanup candidates on dylive — read only, no deletes.""" from __future__ import annotations import sys import time import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") HOST = "107.173.30.245" PASS = "Xiao4669805" def run(c, cmd, timeout=120): print(f"\n===== {cmd[:100]} =====", flush=True) _i, o, e = c.exec_command(cmd, timeout=timeout) print(o.read().decode("utf-8", "replace")[:20000], flush=True) err = e.read().decode("utf-8", "replace") if err.strip(): print("[stderr]", err[:800], flush=True) def main(): c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) for i in range(6): try: c.connect(HOST, 22, "root", PASS, timeout=30, allow_agent=False, look_for_keys=False) break except Exception as ex: print(ex, flush=True) time.sleep(1 + i) else: raise SystemExit("ssh_fail") run(c, "df -h /; echo free=$(df -BG / | awk 'NR==2{print $4}')") run( c, r""" echo '### journal' journalctl --disk-usage 2>/dev/null du -sh /var/log/journal /var/log 2>/dev/null ls -lhS /var/log/*.log /var/log/*.gz 2>/dev/null | head -15 echo '### apt cache' du -sh /var/cache/apt/archives 2>/dev/null echo '### docker/containerd' docker system df 2>/dev/null du -sh /var/lib/docker /var/lib/containerd 2>/dev/null docker images --format '{{.Repository}}:{{.Tag}}\t{{.Size}}\t{{.ID}}' 2>/dev/null | head -20 docker ps -a --filter status=exited --format '{{.Names}}\t{{.Status}}\t{{.Size}}' 2>/dev/null | head -20 echo '### douyinWEB backups/neko/clips' du -sh /opt/douyinWEB/backend/data/backups /opt/douyinWEB/backend/data/neko /opt/douyinWEB/backend/data/clips /opt/douyinWEB/frontend/.next* 2>/dev/null ls -lhS /opt/douyinWEB/backend/data/backups 2>/dev/null | head -20 du -sh /opt/douyinWEB/backend/data/neko/* 2>/dev/null | sort -h | tail -15 echo '### frontend bak' ls -ld /opt/douyinWEB/frontend/.next* 2>/dev/null du -sh /opt/douyinWEB/frontend/.next* 2>/dev/null echo '### /root /tmp /data' du -sh /root /tmp /data 2>/dev/null du -sh /root/* /tmp/* 2>/dev/null | sort -h | tail -20 du -sh /data/* 2>/dev/null | sort -h | tail -20 echo '### other apps under /opt' du -sh /opt/* 2>/dev/null | sort -h echo '### seaweed / volume' du -sh /opt/seaweedfs /data/seaweed* /var/lib/seaweed* 2>/dev/null find /data /opt -maxdepth 3 -iname '*seaweed*' -o -iname '*volume*' 2>/dev/null | head -20 echo '### old tarballs / deploys' find /tmp /root /opt -maxdepth 2 -type f \( -name '*.tgz' -o -name '*.tar.gz' -o -name '*.zip' -o -name '*recv*' -o -name '*deploy*' \) -printf '%s %p\n' 2>/dev/null | sort -n | tail -30 """, ) c.close() print("DONE", flush=True) if __name__ == "__main__": main()