diff --git a/hwmonDaemon.py b/hwmonDaemon.py index 1b62af9..bd30e19 100644 --- a/hwmonDaemon.py +++ b/hwmonDaemon.py @@ -665,6 +665,9 @@ class SystemHealthMonitor: # Ensure history directory exists os.makedirs(self.CONFIG['HISTORY_DIR'], exist_ok=True) + # Drive details cache (per-run, cleared on next execution) + self._drive_details_cache = {} + def _enforce_storage_limit(self, history_dir: str, max_bytes: int = None): """ Delete oldest history files if directory exceeds size limit. @@ -1072,7 +1075,10 @@ class SystemHealthMonitor: # DRIVE HEALTH CHECKING METHODS # ============================================================================= def _get_drive_details(self, device: str) -> Dict[str, str]: - """Get detailed drive information using smartctl.""" + """Get detailed drive information using smartctl (cached per run).""" + if device in self._drive_details_cache: + return self._drive_details_cache[device] + drive_details = { 'model': None, 'serial': None, @@ -1126,7 +1132,8 @@ class SystemHealthMonitor: except Exception as e: logger.debug(f"Error getting drive details for {device}: {e}") - + + self._drive_details_cache[device] = drive_details return drive_details