From eb73e034953ac6ab7ae3018e41d076aa3c241fea Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Thu, 5 Feb 2026 20:19:24 -0500 Subject: [PATCH] Fix temperature parsing with parenthetical data SMART output for Temperature_Celsius often includes extra sensor data in parentheses like "26 (0 14 0 0 0)". The previous awk command was finding "0" from the parenthetical instead of the actual temperature. Now strips parenthetical content with sed before extracting the last numeric value. Fixes: https://code.lotusguild.org/LotusGuild/driveAtlas/issues/11 Co-Authored-By: Claude Opus 4.5 --- driveAtlas.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/driveAtlas.sh b/driveAtlas.sh index f80baa6..ed04310 100644 --- a/driveAtlas.sh +++ b/driveAtlas.sh @@ -746,13 +746,14 @@ parse_smart_data() { fi # Temperature parsing - handles multiple formats: - # - SATA: "194 Temperature_Celsius ... 35" (value at end of line) + # - SATA: "194 Temperature_Celsius ... 26 (0 14 0 0 0)" (value before parenthetical) # - SATA: "Temperature: 42 Celsius" # - SATA: "Current Temperature: 35 Celsius" # - SAS: "Current Drive Temperature: 35 C" # - NVMe: "Temperature: 42 Celsius" 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}}')" + # Strip parenthetical data like "(0 14 0 0 0)" before finding last number + temp="$(echo "$smart_info" | grep "Temperature_Celsius" | head -1 | sed 's/([^)]*)//g' | awk '{for(i=NF;i>0;i--) if($i ~ /^[0-9]+$/) {print $i; exit}}')" elif echo "$smart_info" | grep -qE "Current Drive Temperature:"; then # 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}}')"