#!/bin/bash
# Monitor generation progress
echo "=== START MONITORING ==="
for i in $(seq 1 24); do
    echo "--- T=${i}0s ---"
    grep -v "clip missing" /home/fabian/comfyui6.log | tail -3
    echo "log_bytes: $(wc -c < /home/fabian/comfyui6.log)"
    echo "output: $(ls /home/fabian/ComfyUI/output/ 2>/dev/null | grep -v _output)"
    PID=$(pgrep -f "main.py" | head -1)
    if [ -n "$PID" ]; then
        echo "cpu: $(cat /proc/$PID/stat 2>/dev/null | awk '{print "utime="$14}')"
        echo "gpu_vram: $(cat /sys/class/drm/card0/device/mem_info_vram_used 2>/dev/null)"
        echo "gpu_gtt: $(cat /sys/class/drm/card0/device/mem_info_gtt_used 2>/dev/null)"
    fi
    sleep 10
done
echo "=== DONE ==="
