Update flask_server.py

This commit is contained in:
MacRimi
2025-10-10 22:33:45 +02:00
parent 010333a190
commit 44e76f36b4

View File

@@ -960,7 +960,7 @@ def get_smart_data(disk_name):
print(f"[v0] Health: WARNING (temperature {smart_data['temperature']}°C)") print(f"[v0] Health: WARNING (temperature {smart_data['temperature']}°C)")
except FileNotFoundError: except FileNotFoundError:
print(f"[v0] ERROR: smartctl not found - install smartmontools") print(f"[v0] ERROR: smartctl not found - install smartmontools for disk monitoring.")
except Exception as e: except Exception as e:
print(f"[v0] ERROR: Unexpected exception for {disk_name}: {type(e).__name__}: {e}") print(f"[v0] ERROR: Unexpected exception for {disk_name}: {type(e).__name__}: {e}")
import traceback import traceback
@@ -2178,13 +2178,15 @@ def get_detailed_gpu_info(gpu):
mem_str = mem_elem.text.replace(' MiB', '').strip() mem_str = mem_elem.text.replace(' MiB', '').strip()
memory_mb = int(mem_str) memory_mb = int(mem_str)
memory_kb = memory_mb * 1024
# Get process type (C=Compute, G=Graphics) # Get process type (C=Compute, G=Graphics)
proc_type = type_elem.text.strip() if type_elem is not None else 'C' proc_type = type_elem.text.strip() if type_elem is not None else 'C'
process_info = { process_info = {
'pid': pid, 'pid': pid,
'name': name, 'name': name,
'memory': memory_mb, # Changed key from memory_used_mb to memory for consistency 'memory': memory_kb, # Now in KB instead of MB
'engines': {} # Leave engines empty for NVIDIA since we don't have per-process utilization 'engines': {} # Leave engines empty for NVIDIA since we don't have per-process utilization
} }
@@ -3634,7 +3636,7 @@ def api_vm_control(vmid):
'error': control_result.stderr 'error': control_result.stderr
}), 500 }), 500
else: else:
return jsonify({'error': 'Failed to control VM'}), 500 return jsonify({'error': 'Failed to get VM details'}), 500
except Exception as e: except Exception as e:
print(f"Error controlling VM: {e}") print(f"Error controlling VM: {e}")
return jsonify({'error': str(e)}), 500 return jsonify({'error': str(e)}), 500