File size: 3,527 Bytes
fb37e1c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
# Script de inicialização rápido do sistema de monitoramento GPU

echo "🚀 Iniciando Sistema de Monitoramento e Controle GPU"
echo "=================================================="

# Verifica se o diretório está correto
if [ ! -f "gpu_monitoring.py" ]; then
    echo "❌ Erro: Arquivos do sistema não encontrados. Execute a partir do diretório correto."
    exit 1
fi

# Verifica dependências básicas
echo "📋 Verificando dependências..."
python3 -c "import sys; print('✓ Python 3.x detectado')" 2>/dev/null || { echo "❌ Python 3 não encontrado"; exit 1; }

# Tenta importar módulos principais
echo "🔧 Testando módulos principais..."
python3 -c "
try:
    from gpu_monitoring import GPUManager
    print('✓ GPU Monitoring carregado')
except ImportError as e:
    print(f'⚠ GPU Monitoring: {e}')

try:
    from gpu_fan_controller import FanController
    print('✓ Fan Controller carregado')
except ImportError as e:
    print(f'⚠ Fan Controller: {e}')

try:
    from alert_system import AlertManager
    print('✓ Alert System carregado')
except ImportError as e:
    print(f'⚠ Alert System: {e}')
"

echo ""
echo "🎮 Iniciando componentes principais..."
echo "----------------------------------------"

# Iniciar monitoramento GPU em segundo plano
echo "📡 Iniciando monitoramento GPU..."
python3 gpu_monitor_desktop.py --display overlay &
GPU_MONITOR_PID=$!
echo "✓ Monitoramento GPU iniciado (PID: $GPU_MONITOR_PID)"

# Iniciar controle de fan em segundo plano
echo "💨 Iniciando controle de fan..."
python3 gpu_fan_controller.py --profile balanced &
FAN_CONTROLLER_PID=$!
echo "✓ Controle de fan iniciado (PID: $FAN_CONTROLLER_PID)"

# Iniciar interface web
echo "🌐 Iniciando interface web..."
python3 web_interface.py &
WEB_INTERFACE_PID=$!
echo "✓ Interface web iniciada (PID: $WEB_INTERFACE_PID)"

# Iniciar alertas
echo "🚨 Iniciando sistema de alertas..."
python3 -c "
from alert_system import AlertManager
import time
alert_manager = AlertManager()
alert_manager.start()
print('✓ Sistema de alertas iniciado')
" &
ALERT_MANAGER_PID=$!
echo "✓ Sistema de alertas iniciado (PID: $ALERT_MANAGER_PID)"

echo ""
echo "✅ Sistema iniciado com sucesso!"
echo "================================"
echo ""
echo "📍 Componentes ativos:"
echo "   • Monitoramento GPU: Overlay flutuante"
echo "   • Controle de Fan: Perfil Balanced"
echo "   • Interface Web: http://localhost:5000"
echo "   • Sistema de Alertas: Ativo"
echo ""
echo "🔧 PIDs dos processos:"
echo "   • GPU Monitor: $GPU_MONITOR_PID"
echo "   • Fan Controller: $FAN_CONTROLLER_PID"
echo "   • Web Interface: $WEB_INTERFACE_PID"
echo "   • Alert Manager: $ALERT_MANAGER_PID"
echo ""
echo "💡 Dicas:"
echo "   • Arraste o overlay para reposicionar"
echo "   • Acesse a interface web para controle avançado"
echo "   • Use Ctrl+C para parar o sistema"
echo ""
echo "🎯 Sistema pronto para monitoramento!"

# Mantém o script rodando para permitir parada controlada
trap 'echo "🛑 Parando sistema..."; kill $GPU_MONITOR_PID $FAN_CONTROLLER_PID $WEB_INTERFACE_PID $ALERT_MANAGER_PID 2>/dev/null; exit 0' INT TERM

# Loop para manter o script ativo
while true; do
    sleep 10
    # Verifica se os processos ainda estão ativos
    if ! kill -0 $GPU_MONITOR_PID $FAN_CONTROLLER_PID $WEB_INTERFACE_PID $ALERT_MANAGER_PID 2>/dev/null; then
        echo "⚠ Aviso: Um ou mais processos foram encerrados"
        echo "   Reinicie o sistema se necessário"
    fi
done