| #!/bin/bash |
| |
|
|
| echo "🚀 Iniciando Sistema de Monitoramento GPU (Modo Console)" |
| echo "========================================================" |
|
|
| cd /home/crhon/gpu_monitoring_system |
|
|
| |
| echo "📡 Testando detecção de GPU..." |
| python3 -c " |
| from gpu_monitoring import GPUManager |
| import logging |
| logging.basicConfig(level=logging.INFO) |
| |
| try: |
| manager = GPUManager() |
| if manager.initialize(): |
| gpus = manager.get_gpu_list() |
| print(f'✓ GPUs detectadas: {gpus}') |
| |
| # Testar coleta de status |
| status = manager.get_status() |
| for gpu_name, gpu_status in status.items(): |
| if gpu_status: |
| print(f' {gpu_name}: {gpu_status.temperature}°C, {gpu_status.load}%, {gpu_status.power_draw}W') |
| else: |
| print('✗ Nenhuma GPU detectada') |
| except Exception as e: |
| print(f'✗ Erro na detecção: {e}') |
| " |
|
|
| echo "" |
| echo "💨 Iniciando controle de fan (modo console)..." |
| python3 -c " |
| from gpu_fan_controller import FanController |
| import logging |
| import time |
| |
| logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') |
| |
| try: |
| controller = FanController() |
| if controller.initialize(): |
| print('✓ Fan controller inicializado') |
| print(f' GPU: {controller.gpu_name}') |
| print(f' Perfil padrão: {controller.current_profile.name if controller.current_profile else \"Nenhum\"}') |
| |
| # Testar controle manual |
| controller.set_manual_pwm(100) |
| time.sleep(2) |
| |
| status = controller.get_status() |
| if status: |
| print(f' PWM atual: {status.current_pwm}') |
| print(f' Modo: {status.mode.value}') |
| |
| print('✓ Controle de fan testado com sucesso') |
| else: |
| print('✗ Falha ao inicializar controle de fan') |
| except Exception as e: |
| print(f'✗ Erro no controle de fan: {e}') |
| " & |
|
|
| FAN_PID=$! |
| echo "✓ Controle de fan iniciado (PID: $FAN_PID)" |
|
|
| echo "" |
| echo "🌐 Iniciando interface web..." |
| python3 web_interface.py & |
| WEB_PID=$! |
| echo "✓ Interface web iniciada (PID: $WEB_PID)" |
| echo " Acesse: http://localhost:5000" |
|
|
| echo "" |
| echo "🚨 Iniciando sistema de alertas..." |
| python3 -c " |
| from alert_system import AlertManager |
| import logging |
| import time |
| |
| logging.basicConfig(level=logging.INFO) |
| |
| try: |
| alert_manager = AlertManager() |
| alert_manager.start() |
| print('✓ Sistema de alertas iniciado') |
| |
| # Testar threshold |
| thresholds = alert_manager.thresholds |
| print(f' Thresholds configurados: {len(thresholds)}') |
| for threshold in thresholds[:3]: # Mostrar os 3 primeiros |
| print(f' {threshold.metric} >= {threshold.threshold}°C ({threshold.duration}s)') |
| |
| except Exception as e: |
| print(f'✗ Erro no sistema de alertas: {e}') |
| " & |
| ALERT_PID=$! |
| echo "✓ Sistema de alertas iniciado (PID: $ALERT_PID)" |
|
|
| echo "" |
| echo "📊 Iniciando monitoramento de performance..." |
| python3 -c " |
| from performance_optimizer import SystemOptimizer |
| import logging |
| |
| logging.basicConfig(level=logging.INFO) |
| |
| try: |
| optimizer = SystemOptimizer() |
| optimizer.start_monitoring() |
| print('✓ Monitoramento de performance iniciado') |
| |
| # Testar perfis |
| profiles = optimizer.profiles |
| print(f' Perfis disponíveis: {len(profiles)}') |
| for name, profile in profiles.items(): |
| print(f' {name}: {profile.description}') |
| |
| except Exception as e: |
| print(f'✗ Erro no monitoramento de performance: {e}') |
| " & |
| PERF_PID=$! |
| echo "✓ Monitoramento de performance iniciado (PID: $PERF_PID)" |
|
|
| echo "" |
| echo "✅ Sistema iniciado com sucesso!" |
| echo "===============================" |
| echo "" |
| echo "📍 Componentes ativos:" |
| echo " • Controle de Fan: PID $FAN_PID" |
| echo " • Interface Web: PID $WEB_PID (http://localhost:5000)" |
| echo " • Sistema de Alertas: PID $ALERT_PID" |
| echo " • Monitoramento Performance: PID $PERF_PID" |
| echo "" |
| echo "💡 Dicas:" |
| echo " • Acesse a interface web para controle avançado" |
| echo " • Use Ctrl+C para parar o sistema" |
| echo " • Logs estão sendo salvos nos arquivos de log" |
| echo "" |
| echo "🎯 Sistema pronto para monitoramento!" |
|
|
| |
| stop_system() { |
| echo "" |
| echo "🛑 Parando sistema..." |
| kill $FAN_PID $WEB_PID $ALERT_PID $PERF_PID 2>/dev/null |
| echo "✓ Sistema parado" |
| exit 0 |
| } |
|
|
| |
| trap stop_system INT TERM |
|
|
| |
| echo "" |
| echo "🔄 Sistema em execução. Pressione Ctrl+C para parar." |
| while true; do |
| sleep 30 |
| |
| |
| if ! kill -0 $FAN_PID $WEB_PID $ALERT_PID $PERF_PID 2>/dev/null; then |
| echo "⚠ Atenção: Um ou mais processos foram encerrados inesperadamente" |
| echo " Verifique os logs para detalhes" |
| fi |
| |
| |
| if curl -s http://localhost:5000/api/status > /dev/null 2>&1; then |
| echo "✓ Web interface respondendo" |
| else |
| echo "⚠ Web interface não respondendo" |
| fi |
| done |