more robust temp parsing only 2 digits
This commit is contained in:
@ -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:
|
||||
|
||||
Reference in New Issue
Block a user