refactor: prioritize Current Drive Temperature and Temperature: field patterns over Temperature_Celsius in SMART parsing and reorder -x before -A in sat mode commands
Update temperature line matching to first search for Current Drive Temperature/Drive Temperature/Temperature: patterns, then append Temperature_Celsius lines, before falling back to generic temperature/airflow keywords. Swap smartctl -x -d sat command before -A -d sat in fallback chain to improve attribute detection on SATA drives behind
This commit is contained in:
@@ -362,7 +362,8 @@ def smart_temperature(device):
|
|||||||
# Seagate and similar drives often expose both Airflow_Temperature
|
# Seagate and similar drives often expose both Airflow_Temperature
|
||||||
# and Temperature_Celsius. Prefer the latter because it is the
|
# and Temperature_Celsius. Prefer the latter because it is the
|
||||||
# physical drive temperature shown by the usual terminal command.
|
# physical drive temperature shown by the usual terminal command.
|
||||||
ordered = [line for line in lines if re.search(r"Temperature_Celsius|Drive_Temperature|Current Drive Temperature", line, re.IGNORECASE)]
|
ordered = [line for line in lines if re.search(r"Current Drive Temperature|Drive Temperature|^\s*Temperature:\s*", line, re.IGNORECASE)]
|
||||||
|
ordered += [line for line in lines if line not in ordered and re.search(r"Temperature_Celsius", line, re.IGNORECASE)]
|
||||||
ordered += [line for line in lines if line not in ordered and re.search(r"temperature|airflow", line, re.IGNORECASE)]
|
ordered += [line for line in lines if line not in ordered and re.search(r"temperature|airflow", line, re.IGNORECASE)]
|
||||||
for line in ordered:
|
for line in ordered:
|
||||||
explicit = re.search(r"(\d{1,3})\s*(?:°\s*C|Celsius|degrees?\s*C)\b", line, re.IGNORECASE)
|
explicit = re.search(r"(\d{1,3})\s*(?:°\s*C|Celsius|degrees?\s*C)\b", line, re.IGNORECASE)
|
||||||
@@ -375,8 +376,8 @@ def smart_temperature(device):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
for command in (
|
for command in (
|
||||||
["smartctl", "-A", "-d", "sat", smart_device],
|
|
||||||
["smartctl", "-x", "-d", "sat", smart_device],
|
["smartctl", "-x", "-d", "sat", smart_device],
|
||||||
|
["smartctl", "-A", "-d", "sat", smart_device],
|
||||||
["smartctl", "-A", smart_device],
|
["smartctl", "-A", smart_device],
|
||||||
["smartctl", "-x", smart_device],
|
["smartctl", "-x", smart_device],
|
||||||
):
|
):
|
||||||
|
|||||||
Reference in New Issue
Block a user