Updated drive ticket creation

This commit is contained in:
2025-05-12 15:47:14 -04:00
parent 20f51e0b25
commit af1121e3d9

View File

@ -467,9 +467,12 @@ class SystemHealthMonitor:
- Possible drive failure!
"""
if "Drive" in issue:
if "Drive" in issue and "/dev/" in issue:
try:
device = re.search(r'/dev/[a-zA-Z0-9]+', issue).group(0) if '/dev/' in issue else None
drive_info = next((d for d in health_report['drives_health']['drives'] if d['device'] == device), None)
if drive_info:
drive_details = self._get_drive_details(device)
smart_data = {
@ -493,11 +496,11 @@ class SystemHealthMonitor:
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
""".format(
device,
drive_details['model'],
drive_details['serial'],
drive_details['capacity'],
drive_details['type'],
drive_details['firmware']
drive_details.get('model', 'N/A'),
drive_details.get('serial', 'N/A'),
drive_details.get('capacity', 'N/A'),
drive_details.get('type', 'N/A'),
drive_details.get('firmware', 'N/A')
)
if drive_info:
@ -520,29 +523,27 @@ class SystemHealthMonitor:
age
)
for drive in health_report.get('drives_health', {}).get('drives', []):
if drive['device'] == device:
description += """
┏━ SMART STATUS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Status │ {:<60}
┃ Temperature │ {:<60}
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
""".format(
drive['smart_status'],
f"{drive.get('temperature')}°C" if drive.get('temperature') else 'N/A'
drive_info.get('smart_status', 'N/A'),
f"{drive_info.get('temperature')}°C" if drive_info.get('temperature') else 'N/A'
)
if drive.get('smart_attributes'):
if drive_info.get('smart_attributes'):
description += "\n┏━ SMART ATTRIBUTES " + "" * 48 + "\n"
for attr, value in drive['smart_attributes'].items():
for attr, value in drive_info['smart_attributes'].items():
description += "{:<25}{:<37}\n".format(
attr.replace('_', ' '), value
)
description += "" + "" * 71 + "\n"
if drive.get('partitions'):
for partition in drive['partitions']:
usage_percent = partition['usage_percent']
if drive_info.get('partitions'):
for partition in drive_info['partitions']:
usage_percent = partition.get('usage_percent', 0)
blocks = int(usage_percent / 5) # 20 blocks total = 100%
usage_meter = '' * blocks + '' * (20 - blocks)
@ -556,12 +557,12 @@ class SystemHealthMonitor:
┃ Usage │ {:<60}
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
""".format(
partition['mountpoint'],
partition['fstype'],
partition.get('mountpoint', 'N/A'),
partition.get('fstype', 'N/A'),
usage_meter,
partition['total_space'],
partition['used_space'],
partition['free_space'],
partition.get('total_space', 'N/A'),
partition.get('used_space', 'N/A'),
partition.get('free_space', 'N/A'),
f"{usage_percent}%"
)
@ -571,6 +572,8 @@ class SystemHealthMonitor:
for issue in firmware_info['known_issues']:
description += "┃ ⚠ {:<67}\n".format(issue)
description += "" + "" * 71 + "\n"
except Exception as e:
description += f"\nError generating drive details: {str(e)}\n"
if "Temperature" in issue:
description += """