Added manufacturer and better nvme temp support
This commit is contained in:
@ -576,7 +576,8 @@ class SystemHealthMonitor:
|
||||
r'/dev/loop', # Loop devices
|
||||
r'/dev/rbd', # Ceph RBD devices
|
||||
r'/boot', # Boot partitions
|
||||
r'/boot/efi' # EFI partitions
|
||||
r'/boot/efi', # EFI partitions
|
||||
r'[0-9]+$' # Partition numbers
|
||||
]
|
||||
|
||||
if any(re.search(pattern, device_path) for pattern in excluded_patterns):
|
||||
@ -608,6 +609,15 @@ class SystemHealthMonitor:
|
||||
'known_issues': []
|
||||
}
|
||||
|
||||
MANUFACTURER_PATTERNS = {
|
||||
'Western Digital': ['WDC', 'Western Digital', 'Ultrastar'],
|
||||
'Samsung': ['Samsung', 'SAMSUNG'],
|
||||
'Seagate': ['Seagate', 'ST'],
|
||||
'Intel': ['Intel', 'INTEL'],
|
||||
'Micron': ['Micron', 'Crucial'],
|
||||
'Toshiba': ['Toshiba', 'TOSHIBA']
|
||||
}
|
||||
|
||||
try:
|
||||
result = subprocess.run(
|
||||
['smartctl', '-i', device],
|
||||
@ -616,18 +626,21 @@ class SystemHealthMonitor:
|
||||
text=True
|
||||
)
|
||||
|
||||
model_line = None
|
||||
for line in result.stdout.split('\n'):
|
||||
if 'Firmware Version:' in line:
|
||||
firmware_info['version'] = line.split(':')[1].strip()
|
||||
elif 'Model Family:' in line:
|
||||
model_line = line
|
||||
firmware_info['model'] = line.split(':')[1].strip()
|
||||
elif 'Device Model:' in line:
|
||||
if not firmware_info['model']:
|
||||
elif 'Device Model:' in line and not firmware_info['model']:
|
||||
model_line = line
|
||||
firmware_info['model'] = line.split(':')[1].strip()
|
||||
|
||||
# Determine manufacturer
|
||||
for manufacturer in self.PROBLEMATIC_FIRMWARE.keys():
|
||||
if manufacturer in firmware_info['model']:
|
||||
if model_line:
|
||||
for manufacturer, patterns in MANUFACTURER_PATTERNS.items():
|
||||
if any(pattern in model_line for pattern in patterns):
|
||||
firmware_info['manufacturer'] = manufacturer
|
||||
break
|
||||
|
||||
@ -814,6 +827,19 @@ class SystemHealthMonitor:
|
||||
logger.debug(f"Detected Issues: {smart_health['issues']}")
|
||||
logger.debug("=== End SMART Check ===\n")
|
||||
|
||||
# Special handling for NVMe drives
|
||||
if 'nvme' in device:
|
||||
nvme_result = subprocess.run(
|
||||
['nvme', 'smart-log', device],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True
|
||||
)
|
||||
for line in nvme_result.stdout.split('\n'):
|
||||
if 'temperature' in line.lower():
|
||||
smart_health['temp'] = int(line.split(':')[1].strip().split()[0])
|
||||
break
|
||||
|
||||
except Exception as e:
|
||||
smart_health['status'] = 'ERROR'
|
||||
smart_health['severity'] = 'UNKNOWN'
|
||||
@ -828,11 +854,15 @@ class SystemHealthMonitor:
|
||||
drives_health = {'overall_status': 'NORMAL', 'drives': []}
|
||||
|
||||
try:
|
||||
# Get physical disks only (exclude RBD devices)
|
||||
# Get physical disks only
|
||||
physical_disks = [disk for disk in self._get_all_disks()
|
||||
if disk.startswith(('/dev/sd', '/dev/nvme'))]
|
||||
logger.debug(f"Checking physical disks: {physical_disks}")
|
||||
|
||||
# Get partition information
|
||||
partitions = psutil.disk_partitions(all=True)
|
||||
disk_to_mount = {part.device: part.mountpoint for part in partitions}
|
||||
|
||||
overall_status = 'NORMAL'
|
||||
for disk in physical_disks:
|
||||
drive_report = {
|
||||
@ -846,6 +876,17 @@ class SystemHealthMonitor:
|
||||
'smart_status': 'UNKNOWN'
|
||||
}
|
||||
|
||||
# Get disk usage if mounted
|
||||
if mountpoint:
|
||||
usage = psutil.disk_usage(mountpoint)
|
||||
drive_report.update({
|
||||
'usage_status': 'MOUNTED',
|
||||
'usage_percent': usage.percent,
|
||||
'total_space': self._convert_bytes(usage.total),
|
||||
'used_space': self._convert_bytes(usage.used),
|
||||
'free_space': self._convert_bytes(usage.free)
|
||||
})
|
||||
|
||||
# Check SMART health first
|
||||
smart_health = self._check_smart_health(disk)
|
||||
drive_report.update({
|
||||
|
||||
Reference in New Issue
Block a user