diff --git a/hwmonDaemon.py b/hwmonDaemon.py index befba59..6e04276 100644 --- a/hwmonDaemon.py +++ b/hwmonDaemon.py @@ -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): @@ -607,6 +608,15 @@ class SystemHealthMonitor: 'is_problematic': False, '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( @@ -616,20 +626,23 @@ 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 and not firmware_info['model']: + model_line = line firmware_info['model'] = line.split(':')[1].strip() - elif 'Device Model:' in line: - if not firmware_info['model']: - firmware_info['model'] = line.split(':')[1].strip() # Determine manufacturer - for manufacturer in self.PROBLEMATIC_FIRMWARE.keys(): - if manufacturer in firmware_info['model']: - firmware_info['manufacturer'] = manufacturer - break + 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 # Check against known problematic versions if firmware_info['manufacturer'] and firmware_info['model']: @@ -812,7 +825,20 @@ class SystemHealthMonitor: logger.debug(f"{attr}: {value}") logger.debug(f"Temperature: {smart_health['temp']}°C") logger.debug(f"Detected Issues: {smart_health['issues']}") - logger.debug("=== End SMART Check ===\n") + 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' @@ -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({