From 7a0c2dc2613e31ed049cf306423d9021ffbc9574 Mon Sep 17 00:00:00 2001 From: MacRimi Date: Mon, 6 Oct 2025 19:08:21 +0200 Subject: [PATCH] Update AppImage --- AppImage/components/hardware.tsx | 24 +++++++--- AppImage/scripts/flask_server.py | 76 ++++++++++++-------------------- 2 files changed, 46 insertions(+), 54 deletions(-) diff --git a/AppImage/components/hardware.tsx b/AppImage/components/hardware.tsx index f60b25b..ff1a244 100644 --- a/AppImage/components/hardware.tsx +++ b/AppImage/components/hardware.tsx @@ -16,7 +16,6 @@ import { Cpu, MemoryStick, Cpu as Gpu, - Info, } from "lucide-react" import useSWR from "swr" import { useState } from "react" @@ -320,11 +319,6 @@ export default function Hardware() { )} - -
- - Click for detailed information -
))} @@ -357,6 +351,24 @@ export default function Hardware() { PCI Slot {selectedGPU.slot} + {selectedGPU.pci_class && ( +
+ Class + {selectedGPU.pci_class} +
+ )} + {selectedGPU.pci_driver && ( +
+ Driver + {selectedGPU.pci_driver} +
+ )} + {selectedGPU.pci_kernel_module && ( +
+ Kernel Module + {selectedGPU.pci_kernel_module} +
+ )} {selectedGPU.driver_version && (
Driver Version diff --git a/AppImage/scripts/flask_server.py b/AppImage/scripts/flask_server.py index 695a963..288619b 100644 --- a/AppImage/scripts/flask_server.py +++ b/AppImage/scripts/flask_server.py @@ -1696,13 +1696,36 @@ def get_gpu_info(): 'type': 'Discrete' if vendor in ['NVIDIA', 'AMD'] else 'Integrated' } + try: + # Get detailed PCI info for this slot + pci_result = subprocess.run(['lspci', '-vmm', '-s', slot], capture_output=True, text=True, timeout=2) + if pci_result.returncode == 0: + for pci_line in pci_result.stdout.split('\n'): + if ':' in pci_line: + key, value = pci_line.split(':', 1) + key = key.strip() + value = value.strip() + if key == 'Class': + gpu['pci_class'] = value + + # Get driver and kernel module info + driver_result = subprocess.run(['lspci', '-k', '-s', slot], capture_output=True, text=True, timeout=2) + if driver_result.returncode == 0: + for driver_line in driver_result.stdout.split('\n'): + if 'Kernel driver in use:' in driver_line: + gpu['pci_driver'] = driver_line.split(':', 1)[1].strip() + elif 'Kernel modules:' in driver_line: + gpu['pci_kernel_module'] = driver_line.split(':', 1)[1].strip() + except Exception as e: + print(f"[v0] Error getting PCI info for GPU {slot}: {e}") + detailed_info = get_detailed_gpu_info(gpu) gpu.update(detailed_info) gpus.append(gpu) print(f"[v0] Found GPU: {gpu_name} ({vendor}) at slot {slot}") - except Exception as e: - print(f"[v0] Error detecting GPUs from lspci: {e}") + except Exception as e: + print(f"[v0] Error detecting GPUs from lspci: {e}") try: result = subprocess.run(['sensors'], capture_output=True, text=True, timeout=5) @@ -1738,8 +1761,8 @@ def get_gpu_info(): ('i915' in current_adapter.lower() and gpu['vendor'] == 'Intel')): # Parse temperature (only if not already set by nvidia-smi) - if 'temperature' not in gpu or gpu['temperature'] is None: - if '°C' in value_part or 'C' in value_part: + if '°C' in value_part or 'C' in value_part: + if 'temperature' not in gpu or gpu['temperature'] is None: temp_match = re.search(r'([+-]?[\d.]+)\s*°?C', value_part) if temp_match: gpu['temperature'] = float(temp_match.group(1)) @@ -2459,8 +2482,7 @@ def api_info(): '/api/vms', '/api/logs', '/api/health', - '/api/hardware', - '/api/gpu/' + '/api/hardware' ] }) @@ -2495,48 +2517,6 @@ def api_hardware(): return jsonify(formatted_data) -@app.route('/api/gpu/', methods=['GET']) -def api_gpu_detail(slot): - """Get detailed real-time GPU information for a specific GPU""" - try: - # Find the GPU by slot - hardware_info = get_hardware_info() - gpus = hardware_info.get('gpus', []) - - gpu = None - for g in gpus: - if g.get('slot') == slot: - gpu = g - break - - if not gpu: - return jsonify({'error': 'GPU not found'}), 404 - - # Get PCI device information for this GPU - pci_devices = hardware_info.get('pci_devices', []) - pci_info = None - for device in pci_devices: - if device.get('slot') == slot: - pci_info = device - break - - # Enrich GPU with PCI information - if pci_info: - gpu['pci_class'] = pci_info.get('class') - gpu['pci_driver'] = pci_info.get('driver') - gpu['pci_kernel_module'] = pci_info.get('kernel_module') - - # Get fresh detailed information - detailed_info = get_detailed_gpu_info(gpu) - gpu.update(detailed_info) - - print(f"[v0] /api/gpu/{slot} returning detailed GPU info") - return jsonify(gpu) - - except Exception as e: - print(f"[v0] Error getting GPU details: {e}") - return jsonify({'error': str(e)}), 500 - @app.route('/api/vms/', methods=['GET']) def api_vm_details(vmid): """Get detailed information for a specific VM/LXC"""