more detailed parition data

This commit is contained in:
2025-03-03 20:53:41 -05:00
parent 6e3d537119
commit 30f1ae38c7

View File

@ -901,14 +901,19 @@ class SystemHealthMonitor:
drive_report = { drive_report = {
'device': disk, 'device': disk,
'partitions': [], 'partitions': [],
'smart_status': 'UNKNOWN' 'smart_status': 'UNKNOWN',
'usage_percent': 0
} }
# Add partition information if available # Add partition information if available
if disk in device_partitions: if disk in device_partitions:
total_used = 0
total_space = 0
for partition in device_partitions[disk]: for partition in device_partitions[disk]:
try: try:
usage = psutil.disk_usage(partition.mountpoint) usage = psutil.disk_usage(partition.mountpoint)
total_used += usage.used
total_space += usage.total
part_info = { part_info = {
'device': partition.device, 'device': partition.device,
'mountpoint': partition.mountpoint, 'mountpoint': partition.mountpoint,
@ -921,6 +926,10 @@ class SystemHealthMonitor:
drive_report['partitions'].append(part_info) drive_report['partitions'].append(part_info)
except Exception as e: except Exception as e:
logger.debug(f"Error getting partition usage for {partition.device}: {e}") logger.debug(f"Error getting partition usage for {partition.device}: {e}")
# Calculate overall drive usage percentage
if total_space > 0:
drive_report['usage_percent'] = (total_used / total_space) * 100
# Check SMART health # Check SMART health
smart_health = self._check_smart_health(disk) smart_health = self._check_smart_health(disk)