mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-12-15 00:26:23 +00:00
Update AppImage
This commit is contained in:
@@ -74,7 +74,7 @@ export default function Hardware() {
|
|||||||
try {
|
try {
|
||||||
console.log("[v0] Fetching real-time GPU data for slot:", gpu.slot)
|
console.log("[v0] Fetching real-time GPU data for slot:", gpu.slot)
|
||||||
const response = await fetch(`http://localhost:8008/api/gpu/${gpu.slot}/realtime`, {
|
const response = await fetch(`http://localhost:8008/api/gpu/${gpu.slot}/realtime`, {
|
||||||
signal: AbortSignal.timeout(3000),
|
signal: AbortSignal.timeout(6000),
|
||||||
})
|
})
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
|
|||||||
@@ -1625,7 +1625,7 @@ def get_detailed_gpu_info(gpu):
|
|||||||
data_retrieved = False
|
data_retrieved = False
|
||||||
process = None
|
process = None
|
||||||
try:
|
try:
|
||||||
cmd = ['intel_gpu_top', '-J', '-s', '250', '-o', '-', '-d', f'sys:{sys_real}']
|
cmd = ['intel_gpu_top', '-J', '-s', '1000', '-o', '-', '-d', f'sys:{sys_real}']
|
||||||
print(f"[v0] Starting intel_gpu_top with command: {' '.join(cmd)}")
|
print(f"[v0] Starting intel_gpu_top with command: {' '.join(cmd)}")
|
||||||
|
|
||||||
process = subprocess.Popen(
|
process = subprocess.Popen(
|
||||||
@@ -1638,174 +1638,177 @@ def get_detailed_gpu_info(gpu):
|
|||||||
|
|
||||||
print(f"[v0] intel_gpu_top process started, reading output...")
|
print(f"[v0] intel_gpu_top process started, reading output...")
|
||||||
|
|
||||||
# Read output with timeout
|
|
||||||
output_lines = []
|
output_lines = []
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
timeout_seconds = 5.0
|
timeout_seconds = 8.0
|
||||||
json_objects_found = 0
|
json_objects_found = 0
|
||||||
|
valid_data_found = False
|
||||||
|
|
||||||
while time.time() - start_time < timeout_seconds:
|
while time.time() - start_time < timeout_seconds:
|
||||||
if process.poll() is not None:
|
if process.poll() is not None:
|
||||||
break
|
break
|
||||||
|
|
||||||
try:
|
|
||||||
line = process.stdout.readline()
|
|
||||||
if line:
|
|
||||||
output_lines.append(line)
|
|
||||||
output = ''.join(output_lines)
|
|
||||||
|
|
||||||
if len(output_lines) <= 10:
|
|
||||||
print(f"[v0] Received line {len(output_lines)}: {line.strip()[:100]}")
|
|
||||||
|
|
||||||
# Find all complete JSON objects
|
|
||||||
search_start = 0
|
|
||||||
while True:
|
|
||||||
object_start = -1
|
|
||||||
for i in range(search_start, len(output)):
|
|
||||||
if output[i] == '{':
|
|
||||||
object_start = i
|
|
||||||
break
|
|
||||||
elif output[i] not in [',', '\n', '\r', ' ', '\t']:
|
|
||||||
# Si encontramos algo que no es separador ni llave, salir
|
|
||||||
break
|
|
||||||
|
|
||||||
if object_start == -1:
|
|
||||||
break
|
|
||||||
|
|
||||||
# Count braces to find complete object
|
|
||||||
brace_count = 0
|
|
||||||
object_end = -1
|
|
||||||
|
|
||||||
for i in range(object_start, len(output)):
|
|
||||||
if output[i] == '{':
|
|
||||||
brace_count += 1
|
|
||||||
elif output[i] == '}':
|
|
||||||
brace_count -= 1
|
|
||||||
if brace_count == 0:
|
|
||||||
object_end = i + 1
|
|
||||||
break
|
|
||||||
|
|
||||||
if object_end > object_start:
|
|
||||||
json_objects_found += 1
|
|
||||||
json_str = output[object_start:object_end]
|
|
||||||
|
|
||||||
if json_objects_found == 1:
|
|
||||||
print(f"[v0] Found first JSON object ({len(json_str)} chars) - skipping (baseline)")
|
|
||||||
search_start = object_end
|
|
||||||
# Saltar comas y espacios después del primer objeto
|
|
||||||
while search_start < len(output) and output[search_start] in [',', '\n', '\r', ' ', '\t']:
|
|
||||||
search_start += 1
|
|
||||||
continue
|
|
||||||
|
|
||||||
print(f"[v0] Found second JSON object ({len(json_str)} chars) - using this one")
|
|
||||||
print(f"[v0] JSON preview (first 300 chars): {json_str[:300]}")
|
|
||||||
|
|
||||||
try:
|
|
||||||
json_data = json.loads(json_str)
|
|
||||||
print(f"[v0] Successfully parsed JSON from intel_gpu_top")
|
|
||||||
print(f"[v0] JSON keys: {list(json_data.keys())}")
|
|
||||||
|
|
||||||
# Parse frequency data
|
try:
|
||||||
if 'frequency' in json_data:
|
# Use select for non-blocking read to avoid hanging
|
||||||
freq = json_data['frequency']
|
ready_fds, _, _ = select.select([process.stdout], [], [], 0.1)
|
||||||
if 'actual' in freq:
|
if ready_fds:
|
||||||
detailed_info['clock_graphics'] = f"{freq['actual']:.0f} MHz"
|
line = process.stdout.readline()
|
||||||
data_retrieved = True
|
if line:
|
||||||
if 'requested' in freq:
|
output_lines.append(line)
|
||||||
detailed_info['clock_max'] = f"{freq['requested']:.0f} MHz"
|
output = ''.join(output_lines)
|
||||||
data_retrieved = True
|
|
||||||
|
if len(output_lines) <= 10:
|
||||||
|
print(f"[v0] Received line {len(output_lines)}: {line.strip()[:100]}")
|
||||||
|
|
||||||
|
# Find all complete JSON objects
|
||||||
|
search_start = 0
|
||||||
|
while True:
|
||||||
|
object_start = -1
|
||||||
|
for i in range(search_start, len(output)):
|
||||||
|
if output[i] == '{':
|
||||||
|
object_start = i
|
||||||
|
break
|
||||||
|
elif output[i] not in [',', '\n', '\r', ' ', '\t']:
|
||||||
|
# Si encontramos algo que no es separador ni llave, salir
|
||||||
|
break
|
||||||
|
|
||||||
|
if object_start == -1:
|
||||||
|
break
|
||||||
|
|
||||||
|
# Count braces to find complete object
|
||||||
|
brace_count = 0
|
||||||
|
object_end = -1
|
||||||
|
|
||||||
|
for i in range(object_start, len(output)):
|
||||||
|
if output[i] == '{':
|
||||||
|
brace_count += 1
|
||||||
|
elif output[i] == '}':
|
||||||
|
brace_count -= 1
|
||||||
|
if brace_count == 0:
|
||||||
|
object_end = i + 1
|
||||||
|
break
|
||||||
|
|
||||||
|
if object_end > object_start:
|
||||||
|
json_objects_found += 1
|
||||||
|
json_str = output[object_start:object_end]
|
||||||
|
|
||||||
# Parse power data
|
if json_objects_found == 1:
|
||||||
if 'power' in json_data:
|
print(f"[v0] Found first JSON object ({len(json_str)} chars) - skipping (baseline)")
|
||||||
power = json_data['power']
|
search_start = object_end
|
||||||
if 'GPU' in power:
|
# Saltar comas y espacios después del primer objeto
|
||||||
detailed_info['power_draw'] = f"{power['GPU']:.2f} W"
|
while search_start < len(output) and output[search_start] in [',', '\n', '\r', ' ', '\t']:
|
||||||
data_retrieved = True
|
search_start += 1
|
||||||
if 'Package' in power:
|
continue
|
||||||
detailed_info['power_limit'] = f"{power['Package']:.2f} W"
|
|
||||||
data_retrieved = True
|
|
||||||
|
|
||||||
# Parse RC6 state
|
print(f"[v0] Found second JSON object ({len(json_str)} chars) - using this one")
|
||||||
if 'rc6' in json_data:
|
print(f"[v0] JSON preview (first 300 chars): {json_str[:300]}")
|
||||||
rc6_value = json_data['rc6'].get('value', 0)
|
|
||||||
detailed_info['power_state'] = f"RC6: {rc6_value:.1f}%"
|
|
||||||
data_retrieved = True
|
|
||||||
|
|
||||||
# Parse interrupts
|
try:
|
||||||
if 'interrupts' in json_data:
|
json_data = json.loads(json_str)
|
||||||
irq_count = json_data['interrupts'].get('count', 0)
|
print(f"[v0] Successfully parsed JSON from intel_gpu_top")
|
||||||
detailed_info['irq_rate'] = int(irq_count)
|
print(f"[v0] JSON keys: {list(json_data.keys())}")
|
||||||
data_retrieved = True
|
|
||||||
|
# Parse frequency data
|
||||||
# Parse engines and calculate utilization
|
if 'frequency' in json_data:
|
||||||
if 'engines' in json_data:
|
freq = json_data['frequency']
|
||||||
engines_data = json_data['engines']
|
if 'actual' in freq:
|
||||||
engine_map = {
|
detailed_info['clock_graphics'] = f"{freq['actual']:.0f} MHz"
|
||||||
'Render/3D': 'engine_render',
|
data_retrieved = True
|
||||||
'Blitter': 'engine_blitter',
|
if 'requested' in freq:
|
||||||
'Video': 'engine_video',
|
detailed_info['clock_max'] = f"{freq['requested']:.0f} MHz"
|
||||||
'VideoEnhance': 'engine_video_enhance'
|
|
||||||
}
|
|
||||||
|
|
||||||
engine_values = []
|
|
||||||
for engine_name, key in engine_map.items():
|
|
||||||
if engine_name in engines_data:
|
|
||||||
busy_value = engines_data[engine_name].get('busy', 0)
|
|
||||||
detailed_info[key] = float(busy_value)
|
|
||||||
engine_values.append(busy_value)
|
|
||||||
data_retrieved = True
|
data_retrieved = True
|
||||||
|
|
||||||
# Calculate overall GPU utilization
|
# Parse power data
|
||||||
if engine_values:
|
if 'power' in json_data:
|
||||||
avg_utilization = sum(engine_values) / len(engine_values)
|
power = json_data['power']
|
||||||
detailed_info['utilization_gpu'] = f"{avg_utilization:.1f}%"
|
if 'GPU' in power:
|
||||||
|
detailed_info['power_draw'] = f"{power['GPU']:.2f} W"
|
||||||
# Parse client processes
|
data_retrieved = True
|
||||||
if 'clients' in json_data:
|
if 'Package' in power:
|
||||||
clients_data = json_data['clients']
|
detailed_info['power_limit'] = f"{power['Package']:.2f} W"
|
||||||
processes = []
|
data_retrieved = True
|
||||||
for client_id, client_info in clients_data.items():
|
|
||||||
process_info = {
|
# Parse RC6 state
|
||||||
'name': client_info.get('name', 'Unknown'),
|
if 'rc6' in json_data:
|
||||||
'pid': client_info.get('pid', 'N/A')
|
rc6_value = json_data['rc6'].get('value', 0)
|
||||||
|
detailed_info['power_state'] = f"RC6: {rc6_value:.1f}%"
|
||||||
|
data_retrieved = True
|
||||||
|
|
||||||
|
# Parse interrupts
|
||||||
|
if 'interrupts' in json_data:
|
||||||
|
irq_count = json_data['interrupts'].get('count', 0)
|
||||||
|
detailed_info['irq_rate'] = int(irq_count)
|
||||||
|
data_retrieved = True
|
||||||
|
|
||||||
|
# Parse engines and calculate utilization
|
||||||
|
if 'engines' in json_data:
|
||||||
|
engines_data = json_data['engines']
|
||||||
|
engine_map = {
|
||||||
|
'Render/3D': 'engine_render',
|
||||||
|
'Blitter': 'engine_blitter',
|
||||||
|
'Video': 'engine_video',
|
||||||
|
'VideoEnhance': 'engine_video_enhance'
|
||||||
}
|
}
|
||||||
|
|
||||||
if 'memory' in client_info and 'system' in client_info['memory']:
|
engine_values = []
|
||||||
mem_info = client_info['memory']['system']
|
for engine_name, key in engine_map.items():
|
||||||
if 'resident' in mem_info:
|
if engine_name in engines_data:
|
||||||
mem_mb = int(mem_info['resident']) / (1024 * 1024)
|
busy_value = engines_data[engine_name].get('busy', 0)
|
||||||
process_info['memory_used'] = f"{mem_mb:.0f} MB"
|
detailed_info[key] = float(busy_value)
|
||||||
|
engine_values.append(busy_value)
|
||||||
|
data_retrieved = True
|
||||||
|
|
||||||
if 'engine-classes' in client_info:
|
# Calculate overall GPU utilization
|
||||||
engine_classes = client_info['engine-classes']
|
if engine_values:
|
||||||
if 'Render/3D' in engine_classes:
|
avg_utilization = sum(engine_values) / len(engine_values)
|
||||||
render_busy = engine_classes['Render/3D'].get('busy', '0')
|
detailed_info['utilization_gpu'] = f"{avg_utilization:.1f}%"
|
||||||
process_info['gpu_utilization'] = f"{float(render_busy):.1f}%"
|
|
||||||
|
|
||||||
processes.append(process_info)
|
|
||||||
|
|
||||||
if processes:
|
# Parse client processes
|
||||||
detailed_info['processes'] = processes
|
if 'clients' in json_data:
|
||||||
data_retrieved = True
|
clients_data = json_data['clients']
|
||||||
|
processes = []
|
||||||
print(f"[v0] Intel GPU data retrieved successfully")
|
for client_id, client_info in clients_data.items():
|
||||||
|
process_info = {
|
||||||
|
'name': client_info.get('name', 'Unknown'),
|
||||||
|
'pid': client_info.get('pid', 'N/A')
|
||||||
|
}
|
||||||
|
|
||||||
|
if 'memory' in client_info and 'system' in client_info['memory']:
|
||||||
|
mem_info = client_info['memory']['system']
|
||||||
|
if 'resident' in mem_info:
|
||||||
|
mem_mb = int(mem_info['resident']) / (1024 * 1024)
|
||||||
|
process_info['memory_used'] = f"{mem_mb:.0f} MB"
|
||||||
|
|
||||||
|
if 'engine-classes' in client_info:
|
||||||
|
engine_classes = client_info['engine-classes']
|
||||||
|
if 'Render/3D' in engine_classes:
|
||||||
|
render_busy = engine_classes['Render/3D'].get('busy', '0')
|
||||||
|
process_info['gpu_utilization'] = f"{float(render_busy):.1f}%"
|
||||||
|
|
||||||
|
processes.append(process_info)
|
||||||
|
|
||||||
|
if processes:
|
||||||
|
detailed_info['processes'] = processes
|
||||||
|
data_retrieved = True
|
||||||
|
|
||||||
|
print(f"[v0] Intel GPU data retrieved successfully")
|
||||||
|
break
|
||||||
|
|
||||||
|
except json.JSONDecodeError as e:
|
||||||
|
print(f"[v0] JSON decode error: {e}")
|
||||||
|
search_start = object_end
|
||||||
|
while search_start < len(output) and output[search_start] in [',', '\n', '\r', ' ', '\t']:
|
||||||
|
search_start += 1
|
||||||
|
continue
|
||||||
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
except json.JSONDecodeError as e:
|
# If we found and parsed the second object, break out of the main loop
|
||||||
print(f"[v0] JSON decode error: {e}")
|
if json_objects_found >= 2 and data_retrieved:
|
||||||
search_start = object_end
|
|
||||||
while search_start < len(output) and output[search_start] in [',', '\n', '\r', ' ', '\t']:
|
|
||||||
search_start += 1
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
# If we found and parsed the second object, break out of the main loop
|
time.sleep(0.05) # Sleep briefly if no output, to avoid busy-waiting
|
||||||
if json_objects_found >= 2 and data_retrieved:
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
time.sleep(0.05)
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"[v0] Error reading intel_gpu_top output: {e}")
|
print(f"[v0] Error reading intel_gpu_top output: {e}")
|
||||||
break
|
break
|
||||||
@@ -2349,7 +2352,7 @@ def get_hardware_info():
|
|||||||
# Graphics Cards (from lspci - will be duplicated by new PCI device listing, but kept for now)
|
# Graphics Cards (from lspci - will be duplicated by new PCI device listing, but kept for now)
|
||||||
try:
|
try:
|
||||||
# Try nvidia-smi first
|
# Try nvidia-smi first
|
||||||
result = subprocess.run(['nvidia-smi', '--query-gpu=name,memory.total,temperature.gpu,power.draw', '--format=csv,noheader'],
|
result = subprocess.run(['nvidia-smi', '--query-gpu=name,memory.total,temperature.gpu,power.draw', '--format=csv,noheader,nounits'],
|
||||||
capture_output=True, text=True, timeout=5)
|
capture_output=True, text=True, timeout=5)
|
||||||
if result.returncode == 0:
|
if result.returncode == 0:
|
||||||
for line in result.stdout.strip().split('\n'):
|
for line in result.stdout.strip().split('\n'):
|
||||||
@@ -2785,7 +2788,7 @@ def api_hardware():
|
|||||||
formatted_data = {
|
formatted_data = {
|
||||||
'cpu': hardware_info.get('cpu', {}),
|
'cpu': hardware_info.get('cpu', {}),
|
||||||
'motherboard': hardware_info.get('motherboard', {}),
|
'motherboard': hardware_info.get('motherboard', {}),
|
||||||
'bios': hardware_info.get('bios', {}),
|
'bios': hardware_info.get('motherboard', {}).get('bios', {}), # Extract BIOS info
|
||||||
'memory_modules': hardware_info.get('memory_modules', []),
|
'memory_modules': hardware_info.get('memory_modules', []),
|
||||||
'storage_devices': hardware_info.get('storage_devices', []),
|
'storage_devices': hardware_info.get('storage_devices', []),
|
||||||
'pci_devices': hardware_info.get('pci_devices', []),
|
'pci_devices': hardware_info.get('pci_devices', []),
|
||||||
|
|||||||
Reference in New Issue
Block a user