mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-12-16 00:56:26 +00:00
Update flask_server.py
This commit is contained in:
@@ -1728,7 +1728,7 @@ def get_detailed_gpu_info(gpu):
|
|||||||
process.terminate()
|
process.terminate()
|
||||||
process.wait(timeout=1)
|
process.wait(timeout=1)
|
||||||
|
|
||||||
print(f"[v0] Collected {len(json_objects)} JSON objects total", flush=True)
|
print(f"[v0] Checking if any JSON has clients...", flush=True)
|
||||||
|
|
||||||
if not any('clients' in obj for obj in json_objects):
|
if not any('clients' in obj for obj in json_objects):
|
||||||
try:
|
try:
|
||||||
@@ -1738,6 +1738,8 @@ def get_detailed_gpu_info(gpu):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
print(f"[v0] Selecting best JSON object...", flush=True)
|
||||||
|
|
||||||
best_json = None
|
best_json = None
|
||||||
for json_obj in json_objects:
|
for json_obj in json_objects:
|
||||||
if 'clients' in json_obj and len(json_obj['clients']) > 0:
|
if 'clients' in json_obj and len(json_obj['clients']) > 0:
|
||||||
@@ -1749,8 +1751,12 @@ def get_detailed_gpu_info(gpu):
|
|||||||
best_json = json_objects[0]
|
best_json = json_objects[0]
|
||||||
print(f"[v0] No JSON with clients found, using first JSON object as fallback", flush=True)
|
print(f"[v0] No JSON with clients found, using first JSON object as fallback", flush=True)
|
||||||
|
|
||||||
|
print(f"[v0] About to parse JSON object (best_json is None: {best_json is None})", flush=True)
|
||||||
|
|
||||||
if best_json:
|
if best_json:
|
||||||
print(f"[v0] Parsing selected JSON object...", flush=True)
|
print(f"[v0] Parsing selected JSON object...", flush=True)
|
||||||
|
|
||||||
|
try:
|
||||||
data_retrieved = False
|
data_retrieved = False
|
||||||
|
|
||||||
# Initialize engine totals
|
# Initialize engine totals
|
||||||
@@ -1767,6 +1773,8 @@ def get_detailed_gpu_info(gpu):
|
|||||||
'VideoEnhance': 0.0
|
'VideoEnhance': 0.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print(f"[v0] Initialized engine totals", flush=True)
|
||||||
|
|
||||||
# Parse clients section (processes using GPU)
|
# Parse clients section (processes using GPU)
|
||||||
if 'clients' in best_json:
|
if 'clients' in best_json:
|
||||||
print(f"[v0] Parsing clients section...", flush=True)
|
print(f"[v0] Parsing clients section...", flush=True)
|
||||||
@@ -1803,6 +1811,8 @@ def get_detailed_gpu_info(gpu):
|
|||||||
else:
|
else:
|
||||||
print(f"[v0] WARNING: No 'clients' section in selected JSON", flush=True)
|
print(f"[v0] WARNING: No 'clients' section in selected JSON", flush=True)
|
||||||
|
|
||||||
|
print(f"[v0] About to parse engines section...", flush=True)
|
||||||
|
|
||||||
# Parse global engines section
|
# Parse global engines section
|
||||||
if 'engines' in best_json:
|
if 'engines' in best_json:
|
||||||
print(f"[v0] Parsing engines section...", flush=True)
|
print(f"[v0] Parsing engines section...", flush=True)
|
||||||
@@ -1816,6 +1826,8 @@ def get_detailed_gpu_info(gpu):
|
|||||||
if clean_name in engine_totals:
|
if clean_name in engine_totals:
|
||||||
engine_totals[clean_name] = busy_value
|
engine_totals[clean_name] = busy_value
|
||||||
|
|
||||||
|
print(f"[v0] Calculating final engines...", flush=True)
|
||||||
|
|
||||||
# Use client engine totals if available, otherwise use global engines
|
# Use client engine totals if available, otherwise use global engines
|
||||||
final_engines = client_engine_totals if any(v > 0 for v in client_engine_totals.values()) else engine_totals
|
final_engines = client_engine_totals if any(v > 0 for v in client_engine_totals.values()) else engine_totals
|
||||||
|
|
||||||
@@ -1828,6 +1840,8 @@ def get_detailed_gpu_info(gpu):
|
|||||||
max_utilization = max(final_engines.values())
|
max_utilization = max(final_engines.values())
|
||||||
detailed_info['utilization_gpu'] = f"{max_utilization:.1f}%"
|
detailed_info['utilization_gpu'] = f"{max_utilization:.1f}%"
|
||||||
|
|
||||||
|
print(f"[v0] Parsing frequency...", flush=True)
|
||||||
|
|
||||||
# Parse frequency
|
# Parse frequency
|
||||||
if 'frequency' in best_json:
|
if 'frequency' in best_json:
|
||||||
freq_data = best_json['frequency']
|
freq_data = best_json['frequency']
|
||||||
@@ -1835,6 +1849,8 @@ def get_detailed_gpu_info(gpu):
|
|||||||
detailed_info['clock_graphics'] = f"{actual_freq} MHz"
|
detailed_info['clock_graphics'] = f"{actual_freq} MHz"
|
||||||
data_retrieved = True
|
data_retrieved = True
|
||||||
|
|
||||||
|
print(f"[v0] Parsing power...", flush=True)
|
||||||
|
|
||||||
# Parse power
|
# Parse power
|
||||||
if 'power' in best_json:
|
if 'power' in best_json:
|
||||||
power_data = best_json['power']
|
power_data = best_json['power']
|
||||||
@@ -1844,6 +1860,8 @@ def get_detailed_gpu_info(gpu):
|
|||||||
detailed_info['power_limit'] = f"{package_power:.2f} W"
|
detailed_info['power_limit'] = f"{package_power:.2f} W"
|
||||||
data_retrieved = True
|
data_retrieved = True
|
||||||
|
|
||||||
|
print(f"[v0] Finalizing data (data_retrieved={data_retrieved})...", flush=True)
|
||||||
|
|
||||||
if data_retrieved:
|
if data_retrieved:
|
||||||
detailed_info['has_monitoring_tool'] = True
|
detailed_info['has_monitoring_tool'] = True
|
||||||
print(f"[v0] Intel GPU monitoring successful", flush=True)
|
print(f"[v0] Intel GPU monitoring successful", flush=True)
|
||||||
@@ -1852,6 +1870,12 @@ def get_detailed_gpu_info(gpu):
|
|||||||
print(f"[v0] - Processes: {len(detailed_info['processes'])}", flush=True)
|
print(f"[v0] - Processes: {len(detailed_info['processes'])}", flush=True)
|
||||||
else:
|
else:
|
||||||
print(f"[v0] WARNING: No data retrieved from intel_gpu_top", flush=True)
|
print(f"[v0] WARNING: No data retrieved from intel_gpu_top", flush=True)
|
||||||
|
|
||||||
|
except Exception as parse_error:
|
||||||
|
print(f"[v0] ERROR parsing JSON data: {parse_error}", flush=True)
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print(f"[v0] WARNING: No valid JSON objects found", flush=True)
|
print(f"[v0] WARNING: No valid JSON objects found", flush=True)
|
||||||
|
|
||||||
@@ -2983,3 +3007,4 @@ if __name__ == '__main__':
|
|||||||
print("API endpoints available at: /api/system, /api/system-info, /api/storage, /api/proxmox-storage, /api/network, /api/vms, /api/logs, /api/health, /api/hardware")
|
print("API endpoints available at: /api/system, /api/system-info, /api/storage, /api/proxmox-storage, /api/network, /api/vms, /api/logs, /api/health, /api/hardware")
|
||||||
|
|
||||||
app.run(host='0.0.0.0', port=8008, debug=False)
|
app.run(host='0.0.0.0', port=8008, debug=False)
|
||||||
|
', port=8008, debug=False)
|
||||||
|
|||||||
Reference in New Issue
Block a user