From bc62e215ee3e14e96879e0c88599d2286d34c741 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Mon, 3 Mar 2025 20:32:45 -0500 Subject: [PATCH] more robust temp parsing only 2 digits --- hwmonDaemon.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hwmonDaemon.py b/hwmonDaemon.py index 27fb2ec..d9f2cd6 100644 --- a/hwmonDaemon.py +++ b/hwmonDaemon.py @@ -843,23 +843,23 @@ class SystemHealthMonitor: logger.debug(f"NVMe smart-log raw output for {device}:") logger.debug(nvme_result.stdout) + # Add this line to initialize the temperature attribute + smart_health['attributes']['Temperature_Celsius'] = None + for line in nvme_result.stdout.split('\n'): if 'temperature' in line.lower(): temp_str = line.split(':')[1].strip() logger.debug(f"Raw temperature string: {temp_str}") + # Extract first temperature value temp_value = int(''.join(c for c in temp_str if c.isdigit())[0:2]) logger.debug(f"Parsed temperature value: {temp_value}") + # Set both temperature fields smart_health['temp'] = temp_value - logger.debug(f"Final temperature recorded: {smart_health['temp']}") + smart_health['attributes']['Temperature_Celsius'] = temp_value - if temp_value >= SMART_THRESHOLDS['Temperature_Celsius']['critical']: - smart_health['severity'] = 'CRITICAL' - smart_health['issues'].append(f"Critical temperature: {temp_value}°C") - elif temp_value >= SMART_THRESHOLDS['Temperature_Celsius']['warning']: - smart_health['severity'] = 'WARNING' - smart_health['issues'].append(f"High temperature: {temp_value}°C") + logger.debug(f"Final temperature recorded: {smart_health['temp']}") break except Exception as e: