Update flask_server.py

This commit is contained in:
MacRimi
2025-11-03 19:12:07 +01:00
parent a70b33ce13
commit 5158c5f359

View File

@@ -1388,26 +1388,22 @@ 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)")
pass pass
# CHANGE: Use -1 to indicate HDD with unknown RPM instead of inventing 7200 RPM # CHANGE: Use -1 to indicate HDD with unknown RPM instead of inventing 7200 RPM
# Fallback: Check kernel's rotational flag if smartctl didn't provide rotation_rate # Fallback: Check kernel's rotational flag if smartctl didn't provide rotation_rate
# This fixes detection for older disks that don't report RPM via smartctl # This fixes detection for older disks that don't report RPM via smartctl
if smart_data['rotation_rate'] == 0: if smart_data['rotation_rate'] == 0:
try: try:
rotational_path = f"/sys/block/{disk_name}/queue/rotational" rotational_path = f"/sys/block/{disk_name}/queue/rotational"
if os.path.exists(rotational_path): if os.path.exists(rotational_path):
with open(rotational_path, 'r') as f: with open(rotational_path, 'r') as f:
rotational = int(f.read().strip()) rotational = int(f.read().strip())
if rotational == 1: if rotational == 1:
# Disk is rotational (HDD), use -1 to indicate "HDD but RPM unknown" # Disk is rotational (HDD), use -1 to indicate "HDD but RPM unknown"
smart_data['rotation_rate'] = -1 smart_data['rotation_rate'] = -1
# If rotational == 0, it's an SSD, keep rotation_rate as 0 # If rotational == 0, it's an SSD, keep rotation_rate as 0
except Exception as e: except Exception as e:
pass # If we can't read the file, leave rotation_rate as is pass # If we can't read the file, leave rotation_rate as is
except FileNotFoundError:
# print(f"[v0] ERROR: smartctl not found - install smartmontools for disk monitoring.")
pass
except FileNotFoundError: except FileNotFoundError:
# print(f"[v0] ERROR: smartctl not found - install smartmontools for disk monitoring.") # print(f"[v0] ERROR: smartctl not found - install smartmontools for disk monitoring.")
pass pass