Dedicated hardware poller + read-only consumers #4
@@ -45,6 +45,10 @@ def _parse_ipmi(text: str) -> list[dict]:
|
|||||||
if len(parts) < 5:
|
if len(parts) < 5:
|
||||||
continue
|
continue
|
||||||
name, _sid, status, entity, reading = parts[:5]
|
name, _sid, status, entity, reading = parts[:5]
|
||||||
|
# Skip relative/derived sensors (e.g. "P1 Therm Margin") — they read in
|
||||||
|
# "degrees C" but are a distance-to-throttle, not an absolute temp.
|
||||||
|
if "margin" in name.lower():
|
||||||
|
continue
|
||||||
m = re.search(r"(-?\d+(?:\.\d+)?)\s*degrees?\s*C", reading, re.IGNORECASE)
|
m = re.search(r"(-?\d+(?:\.\d+)?)\s*degrees?\s*C", reading, re.IGNORECASE)
|
||||||
if not m: # "no reading", "disabled", "ns", etc.
|
if not m: # "no reading", "disabled", "ns", etc.
|
||||||
continue
|
continue
|
||||||
@@ -74,22 +78,28 @@ def read_coretemp() -> list[dict]:
|
|||||||
continue
|
continue
|
||||||
except OSError:
|
except OSError:
|
||||||
continue
|
continue
|
||||||
|
packages: list[dict] = []
|
||||||
|
cores: list[int] = []
|
||||||
for label_f in sorted(hw.glob("temp*_label")):
|
for label_f in sorted(hw.glob("temp*_label")):
|
||||||
try:
|
try:
|
||||||
label = label_f.read_text().strip()
|
label = label_f.read_text().strip()
|
||||||
except OSError:
|
except OSError:
|
||||||
continue
|
continue
|
||||||
if not label.lower().startswith("package id"):
|
|
||||||
continue
|
|
||||||
input_f = label_f.with_name(label_f.name.replace("_label", "_input"))
|
input_f = label_f.with_name(label_f.name.replace("_label", "_input"))
|
||||||
try:
|
try:
|
||||||
milli = int(input_f.read_text().strip())
|
temp = round(int(input_f.read_text().strip()) / 1000)
|
||||||
except (OSError, ValueError):
|
except (OSError, ValueError):
|
||||||
continue
|
continue
|
||||||
pkg = label.split("id")[-1].strip()
|
low = label.lower()
|
||||||
cpus.append({
|
if low.startswith("package id"):
|
||||||
"name": f"CPU {pkg}",
|
pkg = label.split("id")[-1].strip()
|
||||||
"temperature_c": round(milli / 1000),
|
packages.append({"name": f"CPU {pkg}", "temperature_c": temp, "kind": "cpu"})
|
||||||
"kind": "cpu",
|
elif low.startswith("core"):
|
||||||
})
|
cores.append(temp)
|
||||||
|
# Prefer the per-package sensor; older CPUs (no package sensor) fall back
|
||||||
|
# to the hottest core as the CPU temp.
|
||||||
|
if packages:
|
||||||
|
cpus.extend(packages)
|
||||||
|
elif cores:
|
||||||
|
cpus.append({"name": "CPU", "temperature_c": max(cores), "kind": "cpu"})
|
||||||
return cpus
|
return cpus
|
||||||
|
|||||||
Reference in New Issue
Block a user