diff --git a/hwmonDaemon.py b/hwmonDaemon.py index da8bcf8..90ff224 100644 --- a/hwmonDaemon.py +++ b/hwmonDaemon.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -import os, sys, json, requests, psutil, socket, subprocess, logging, argparse, urllib.request +import os, sys, json, requests, psutil, socket, subprocess, logging, argparse, urllib.request, re from typing import Dict, Any, List # Create a logger @@ -236,15 +236,24 @@ class SystemHealthMonitor: return issues + def _is_physical_disk(self, device_path): + """ + Check if the device is a physical SATA or NVMe disk. + + :param device_path: Path to the device + :return: Boolean indicating if it's a physical disk + """ + return bool(re.match(r'/dev/(sd[a-z]|nvme\d+n\d+)', device_path)) + def _check_drives_health(self) -> Dict[str, Any]: """ - Check overall health of drives including disk usage and SMART status. + Check overall health of physical SATA and NVMe drives including disk usage and SMART status. :return: Combined health report of all drives and their status. """ drives_health = {'overall_status': 'NORMAL', 'drives': []} try: - partitions = psutil.disk_partitions() + partitions = [p for p in psutil.disk_partitions() if self._is_physical_disk(p.device)] overall_status = 'NORMAL' for partition in partitions: drive_report = {