Handle AMD Tctl temperature readings (refs #586)
This commit is contained in:
parent
4ba5dcc785
commit
30879c3b7b
2 changed files with 39 additions and 2 deletions
|
|
@ -297,11 +297,18 @@ func (tc *TemperatureCollector) parseCPUTemps(chipMap map[string]interface{}, te
|
|||
continue
|
||||
}
|
||||
|
||||
// Look for Package id (Intel) or Tdie (AMD)
|
||||
if strings.Contains(sensorName, "Package id") || strings.Contains(sensorName, "Tdie") {
|
||||
sensorNameLower := strings.ToLower(sensorName)
|
||||
|
||||
// Look for Package id (Intel) or Tdie/Tctl (AMD control loop temperature)
|
||||
if strings.Contains(sensorName, "Package id") ||
|
||||
strings.Contains(sensorName, "Tdie") ||
|
||||
strings.Contains(sensorNameLower, "tctl") {
|
||||
if tempVal := extractTempInput(sensorMap); !math.IsNaN(tempVal) {
|
||||
temp.CPUPackage = tempVal
|
||||
foundPackageTemp = true
|
||||
if tempVal > temp.CPUMax {
|
||||
temp.CPUMax = tempVal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -133,6 +133,36 @@ func TestParseSensorsJSON_WithCpuAndNvmeData(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestParseSensorsJSON_WithAmdTctlOnly(t *testing.T) {
|
||||
collector := &TemperatureCollector{}
|
||||
|
||||
jsonStr := `{
|
||||
"k10temp-pci-00c3": {
|
||||
"Tctl": {"temp1_input": 55.4}
|
||||
}
|
||||
}`
|
||||
|
||||
temp, err := collector.parseSensorsJSON(jsonStr)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error parsing sensors output: %v", err)
|
||||
}
|
||||
if temp == nil {
|
||||
t.Fatalf("expected temperature struct, got nil")
|
||||
}
|
||||
if !temp.Available {
|
||||
t.Fatalf("expected temperature to be available when Tctl reading present")
|
||||
}
|
||||
if !temp.HasCPU {
|
||||
t.Fatalf("expected HasCPU to be true when AMD Tctl is present")
|
||||
}
|
||||
if temp.CPUPackage != 55.4 {
|
||||
t.Fatalf("expected cpu package temperature 55.4, got %.2f", temp.CPUPackage)
|
||||
}
|
||||
if temp.CPUMax != 55.4 {
|
||||
t.Fatalf("expected cpu max temperature to follow Tctl value, got %.2f", temp.CPUMax)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseSensorsJSON_RPiWrapper(t *testing.T) {
|
||||
collector := &TemperatureCollector{}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue