Fix temperature parsing for SAS drives
Added support for SAS drive temperature format "Current Drive Temperature:" and made temperature extraction more robust by: - Removing ^ anchor that was preventing matches with leading whitespace - Using awk to find the first numeric value in the line - Adding explicit SAS drive temperature format handling Fixes: #11 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -749,11 +749,16 @@ parse_smart_data() {
|
|||||||
# - SATA: "194 Temperature_Celsius ... 35" (value at end of line)
|
# - SATA: "194 Temperature_Celsius ... 35" (value at end of line)
|
||||||
# - SATA: "Temperature: 42 Celsius"
|
# - SATA: "Temperature: 42 Celsius"
|
||||||
# - SATA: "Current Temperature: 35 Celsius"
|
# - SATA: "Current Temperature: 35 Celsius"
|
||||||
|
# - SAS: "Current Drive Temperature: 35 C"
|
||||||
# - NVMe: "Temperature: 42 Celsius"
|
# - NVMe: "Temperature: 42 Celsius"
|
||||||
if echo "$smart_info" | grep -q "Temperature_Celsius"; then
|
if echo "$smart_info" | grep -q "Temperature_Celsius"; then
|
||||||
temp="$(echo "$smart_info" | grep "Temperature_Celsius" | head -1 | awk '{for(i=NF;i>0;i--) if($i ~ /^[0-9]+$/) {print $i; exit}}')"
|
temp="$(echo "$smart_info" | grep "Temperature_Celsius" | head -1 | awk '{for(i=NF;i>0;i--) if($i ~ /^[0-9]+$/) {print $i; exit}}')"
|
||||||
elif echo "$smart_info" | grep -qE "^(Current )?Temperature:"; then
|
elif echo "$smart_info" | grep -qE "Current Drive Temperature:"; then
|
||||||
temp="$(echo "$smart_info" | grep -E "^(Current )?Temperature:" | head -1 | awk '{print $2}')"
|
# SAS drives: "Current Drive Temperature: 35 C"
|
||||||
|
temp="$(echo "$smart_info" | grep -E "Current Drive Temperature:" | head -1 | awk '{for(i=1;i<=NF;i++) if($i ~ /^[0-9]+$/) {print $i; exit}}')"
|
||||||
|
elif echo "$smart_info" | grep -qE "(Current )?Temperature:"; then
|
||||||
|
# SATA/NVMe: "Temperature: 42 Celsius" (may have leading whitespace)
|
||||||
|
temp="$(echo "$smart_info" | grep -E "(Current )?Temperature:" | head -1 | awk '{for(i=1;i<=NF;i++) if($i ~ /^[0-9]+$/) {print $i; exit}}')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Device type detection - handles SSD, HDD, and NVMe
|
# Device type detection - handles SSD, HDD, and NVMe
|
||||||
|
|||||||
Reference in New Issue
Block a user