Update backend monitor

This commit is contained in:
MacRimi
2026-01-29 17:47:10 +01:00
parent 7eaa692712
commit a20d61037e
12 changed files with 1720 additions and 6361 deletions

View File

@@ -0,0 +1,37 @@
from flask import Blueprint, jsonify
from jwt_middleware import require_auth
import hardware_monitor
# Definimos el Blueprint
hardware_bp = Blueprint('hardware', __name__)
@hardware_bp.route('/api/hardware', methods=['GET'])
@require_auth
def api_hardware():
"""
Obtiene información completa y agregada de todo el hardware.
Incluye CPU, Placa Base, RAM, Discos, GPUs, IPMI y UPS.
"""
try:
data = hardware_monitor.get_hardware_info()
return jsonify(data)
except Exception as e:
# En caso de error crítico, devolvemos un 500 pero intentamos ser descriptivos
return jsonify({'error': str(e)}), 500
@hardware_bp.route('/api/gpu/<slot>/realtime', methods=['GET'])
@require_auth
def api_gpu_realtime(slot):
"""
Obtiene métricas en tiempo real (uso, temperatura, memoria) para una GPU específica.
El 'slot' es la dirección PCI (ej: '01:00.0').
"""
try:
data = hardware_monitor.get_gpu_realtime_data(slot)
if not data:
return jsonify({'error': 'GPU not found'}), 404
return jsonify(data)
except Exception as e:
return jsonify({'error': str(e)}), 500