import paramiko, time

k = paramiko.Ed25519Key.from_private_key_file(r'C:\Users\fabia\.ssh\id_ed25519')
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect('192.168.178.150', username='fabian', pkey=k, timeout=10)

# 1) Full diagnostic
cmds = {
    "LOG_LAST_40": "tail -40 /tmp/comfyui.log 2>/dev/null",
    "PROCESS": "ps aux | grep -E 'python|comfy' | grep -v grep",
    "GPU": "cat /sys/class/drm/card0/device/gpu_busy_percent 2>/dev/null",
    "GPU_TEMP": "cat /sys/class/drm/card0/device/hwmon/hwmon*/temp1_input 2>/dev/null",
    "CPU_CORES": "mpstat -P ALL 1 1 2>/dev/null | tail -15 || top -bn1 | head -5",
    "MEM": "free -m",
    "OUTPUT": "ls -la ~/ComfyUI/output/ 2>/dev/null",
    "QUEUE": "curl -s http://127.0.0.1:8188/queue 2>/dev/null",
    "ROCM_CHECK": "rocm-smi --showuse --showtemp --showpower 2>/dev/null | head -20",
}

for name, cmd in cmds.items():
    print(f"\n=== {name} ===")
    _, o, e = c.exec_command(cmd)
    out = o.read().decode(errors='replace').strip()
    err = e.read().decode(errors='replace').strip()
    print(out if out else "(empty)")
    if err and name not in ("ROCM_CHECK",):
        print(f"  STDERR: {err}")

c.close()
print("\nDone.")
