#!/bin/bash
# Script de monitoring optimisation BNB

echo "════════════════════════════════════════════════════════════"
echo "📊 MONITORING OPTIMISATION BNB - Refresh toutes les 10s"
echo "════════════════════════════════════════════════════════════"
echo ""

while true; do
    clear
    echo "════════════════════════════════════════════════════════════"
    echo "🕐 $(date '+%H:%M:%S') - OPTIMISATION BNB HYBRIDE"
    echo "════════════════════════════════════════════════════════════"
    echo ""
    
    # Processus actif
    if ps aux | grep -q "[o]ptimize_bnb_hybrid.py"; then
        echo "✅ Processus: ACTIF"
        ps aux | grep "[o]ptimize_bnb_hybrid.py" | awk '{print "   PID:", $2, "| CPU:", $3"%", "| MEM:", $4"%"}'
    else
        echo "❌ Processus: ARRÊTÉ"
    fi
    
    echo ""
    echo "────────────────────────────────────────────────────────────"
    echo "📈 PROGRESSION"
    echo "────────────────────────────────────────────────────────────"
    
    # Dernière ligne de progression
    tail -100 bnb_optimization_clean.log | grep -E "\[[0-9]+/16384\]" | tail -1
    
    echo ""
    echo "────────────────────────────────────────────────────────────"
    echo "💰 MEILLEURE CONFIG ACTUELLE"
    echo "────────────────────────────────────────────────────────────"
    
    # Meilleure config trouvée
    tail -100 bnb_optimization_clean.log | grep "💰 Meilleur:" | tail -1 | sed 's/    //'
    
    echo ""
    echo "────────────────────────────────────────────────────────────"
    echo "📊 HISTORIQUE RÉCENT (5 dernières progressions)"
    echo "────────────────────────────────────────────────────────────"
    
    tail -200 bnb_optimization_clean.log | grep -E "\[[0-9]+/16384\]" | tail -5
    
    echo ""
    echo "════════════════════════════════════════════════════════════"
    echo "Ctrl+C pour arrêter | Refresh automatique toutes les 10s"
    echo "════════════════════════════════════════════════════════════"
    
    sleep 10
done
