meccatronis commited on
Commit
4485fc2
·
verified ·
1 Parent(s): 93936b3

Upload start_console.sh with huggingface_hub

Browse files
Files changed (1) hide show
  1. start_console.sh +173 -0
start_console.sh ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Script de inicialização em modo console (sem GUI)
3
+
4
+ echo "🚀 Iniciando Sistema de Monitoramento GPU (Modo Console)"
5
+ echo "========================================================"
6
+
7
+ cd /home/crhon/gpu_monitoring_system
8
+
9
+ # Testar detecção de GPU
10
+ echo "📡 Testando detecção de GPU..."
11
+ python3 -c "
12
+ from gpu_monitoring import GPUManager
13
+ import logging
14
+ logging.basicConfig(level=logging.INFO)
15
+
16
+ try:
17
+ manager = GPUManager()
18
+ if manager.initialize():
19
+ gpus = manager.get_gpu_list()
20
+ print(f'✓ GPUs detectadas: {gpus}')
21
+
22
+ # Testar coleta de status
23
+ status = manager.get_status()
24
+ for gpu_name, gpu_status in status.items():
25
+ if gpu_status:
26
+ print(f' {gpu_name}: {gpu_status.temperature}°C, {gpu_status.load}%, {gpu_status.power_draw}W')
27
+ else:
28
+ print('✗ Nenhuma GPU detectada')
29
+ except Exception as e:
30
+ print(f'✗ Erro na detecção: {e}')
31
+ "
32
+
33
+ echo ""
34
+ echo "💨 Iniciando controle de fan (modo console)..."
35
+ python3 -c "
36
+ from gpu_fan_controller import FanController
37
+ import logging
38
+ import time
39
+
40
+ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
41
+
42
+ try:
43
+ controller = FanController()
44
+ if controller.initialize():
45
+ print('✓ Fan controller inicializado')
46
+ print(f' GPU: {controller.gpu_name}')
47
+ print(f' Perfil padrão: {controller.current_profile.name if controller.current_profile else \"Nenhum\"}')
48
+
49
+ # Testar controle manual
50
+ controller.set_manual_pwm(100)
51
+ time.sleep(2)
52
+
53
+ status = controller.get_status()
54
+ if status:
55
+ print(f' PWM atual: {status.current_pwm}')
56
+ print(f' Modo: {status.mode.value}')
57
+
58
+ print('✓ Controle de fan testado com sucesso')
59
+ else:
60
+ print('✗ Falha ao inicializar controle de fan')
61
+ except Exception as e:
62
+ print(f'✗ Erro no controle de fan: {e}')
63
+ " &
64
+
65
+ FAN_PID=$!
66
+ echo "✓ Controle de fan iniciado (PID: $FAN_PID)"
67
+
68
+ echo ""
69
+ echo "🌐 Iniciando interface web..."
70
+ python3 web_interface.py &
71
+ WEB_PID=$!
72
+ echo "✓ Interface web iniciada (PID: $WEB_PID)"
73
+ echo " Acesse: http://localhost:5000"
74
+
75
+ echo ""
76
+ echo "🚨 Iniciando sistema de alertas..."
77
+ python3 -c "
78
+ from alert_system import AlertManager
79
+ import logging
80
+ import time
81
+
82
+ logging.basicConfig(level=logging.INFO)
83
+
84
+ try:
85
+ alert_manager = AlertManager()
86
+ alert_manager.start()
87
+ print('✓ Sistema de alertas iniciado')
88
+
89
+ # Testar threshold
90
+ thresholds = alert_manager.thresholds
91
+ print(f' Thresholds configurados: {len(thresholds)}')
92
+ for threshold in thresholds[:3]: # Mostrar os 3 primeiros
93
+ print(f' {threshold.metric} >= {threshold.threshold}°C ({threshold.duration}s)')
94
+
95
+ except Exception as e:
96
+ print(f'✗ Erro no sistema de alertas: {e}')
97
+ " &
98
+ ALERT_PID=$!
99
+ echo "✓ Sistema de alertas iniciado (PID: $ALERT_PID)"
100
+
101
+ echo ""
102
+ echo "📊 Iniciando monitoramento de performance..."
103
+ python3 -c "
104
+ from performance_optimizer import SystemOptimizer
105
+ import logging
106
+
107
+ logging.basicConfig(level=logging.INFO)
108
+
109
+ try:
110
+ optimizer = SystemOptimizer()
111
+ optimizer.start_monitoring()
112
+ print('✓ Monitoramento de performance iniciado')
113
+
114
+ # Testar perfis
115
+ profiles = optimizer.profiles
116
+ print(f' Perfis disponíveis: {len(profiles)}')
117
+ for name, profile in profiles.items():
118
+ print(f' {name}: {profile.description}')
119
+
120
+ except Exception as e:
121
+ print(f'✗ Erro no monitoramento de performance: {e}')
122
+ " &
123
+ PERF_PID=$!
124
+ echo "✓ Monitoramento de performance iniciado (PID: $PERF_PID)"
125
+
126
+ echo ""
127
+ echo "✅ Sistema iniciado com sucesso!"
128
+ echo "==============================="
129
+ echo ""
130
+ echo "📍 Componentes ativos:"
131
+ echo " • Controle de Fan: PID $FAN_PID"
132
+ echo " • Interface Web: PID $WEB_PID (http://localhost:5000)"
133
+ echo " • Sistema de Alertas: PID $ALERT_PID"
134
+ echo " • Monitoramento Performance: PID $PERF_PID"
135
+ echo ""
136
+ echo "💡 Dicas:"
137
+ echo " • Acesse a interface web para controle avançado"
138
+ echo " • Use Ctrl+C para parar o sistema"
139
+ echo " • Logs estão sendo salvos nos arquivos de log"
140
+ echo ""
141
+ echo "🎯 Sistema pronto para monitoramento!"
142
+
143
+ # Função para parar o sistema
144
+ stop_system() {
145
+ echo ""
146
+ echo "🛑 Parando sistema..."
147
+ kill $FAN_PID $WEB_PID $ALERT_PID $PERF_PID 2>/dev/null
148
+ echo "✓ Sistema parado"
149
+ exit 0
150
+ }
151
+
152
+ # Configurar trap para parada controlada
153
+ trap stop_system INT TERM
154
+
155
+ # Loop de monitoramento
156
+ echo ""
157
+ echo "🔄 Sistema em execução. Pressione Ctrl+C para parar."
158
+ while true; do
159
+ sleep 30
160
+
161
+ # Verificar se os processos ainda estão ativos
162
+ if ! kill -0 $FAN_PID $WEB_PID $ALERT_PID $PERF_PID 2>/dev/null; then
163
+ echo "⚠ Atenção: Um ou mais processos foram encerrados inesperadamente"
164
+ echo " Verifique os logs para detalhes"
165
+ fi
166
+
167
+ # Testar status do web server
168
+ if curl -s http://localhost:5000/api/status > /dev/null 2>&1; then
169
+ echo "✓ Web interface respondendo"
170
+ else
171
+ echo "⚠ Web interface não respondendo"
172
+ fi
173
+ done