douyinWEB/scripts/_pve_guest_inventory.py
eric d409e416da Ship physical dual-edge stack, Studio CDP live metrics, and ops tooling.
Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-04 22:42:40 -05:00

55 lines
1.8 KiB
Python

# -*- coding: utf-8 -*-
"""Inventory ONLY the PVE Ubuntu guest (FRP 4014). Never touch PVE host."""
import sys
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("107.173.30.245", 4014, "eric", "4669805", timeout=25, allow_agent=False, look_for_keys=False)
script = r'''
set +e
echo '===== hostname / virt ====='
hostname; hostnamectl 2>/dev/null | grep -E 'hostname|Chassis|Virtualization|Operating'
systemd-detect-virt 2>/dev/null
echo
echo '===== df / lvm (guest disk only) ====='
df -hT /
pvs; vgs; lvs
echo
echo '===== listening / key services ====='
ss -lntp 2>/dev/null | head -80
echo '--- systemd ---'
systemctl list-units --type=service --state=running --no-pager 2>/dev/null | head -60
echo
echo '===== docker / clash / frp / wg ====='
command -v docker; docker ps -a 2>/dev/null | head
command -v clash; command -v mihomo; ls /etc/clash /opt/clash /home/eric/.config/clash 2>/dev/null
ps aux | grep -Ei 'frp|frpc|clash|mihomo|sing-box|v2ray|xray|wireguard|wg-quick' | grep -v grep
echo
echo '===== home /opt /var large ====='
du -xh --max-depth=2 /home/eric 2>/dev/null | sort -hr | head -30
du -xh --max-depth=1 /opt /var /usr /tmp /root 2>/dev/null | sort -hr | head -30
echo
echo '===== snaps ====='
snap list 2>/dev/null
echo
echo '===== apt leftover ====='
dpkg -l | awk '/^ii/ {print $2}' | grep -Ei 'android|sdk|studio|gradle|nodejs|npm|jdk|openjdk|docker' | head -40
'''
sftp = c.open_sftp()
with sftp.file("/tmp/_guest_inv.sh", "w") as f:
f.write(script)
sftp.chmod("/tmp/_guest_inv.sh", 0o755)
sftp.close()
_, o, e = c.exec_command("echo '4669805' | sudo -S -p '' bash /tmp/_guest_inv.sh", timeout=180)
print(o.read().decode("utf-8", "replace"))
err = e.read().decode("utf-8", "replace")
if err.strip():
print("STDERR", err[-2500:])
c.close()