Skip to content

Commit

Permalink
Merge pull request #38 from pschmitt/amdcputemp
Browse files Browse the repository at this point in the history
fix: CPU temperature on AMD machines
  • Loading branch information
tobias-kuendig committed Nov 6, 2023
2 parents 187bd96 + 894dae1 commit 8e4727b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sensor/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

var (
reCPUTemp = regexp.MustCompile(`(?m)(temp1|Package id|Core \d)[\s\d]*:\s+.?([\d\.]+)°`)
reCPUTemp = regexp.MustCompile(`(?m)(temp1|Package id|Core \d|CPU)[\s\d]*:\s+.?([\d\.]+)°`)
// This is currently unused.
//reCPUTemp2 = regexp.MustCompile(`(?mi)^\s?(?P<name>[^:]+):\s+(?P<value>\d+)`)
reCPUUsage = regexp.MustCompile(`(?m)^\s*cpu(\d+)?.*`)
Expand Down Expand Up @@ -56,7 +56,7 @@ func (c CPUTemp) process(output string) (*entity.Payload, error) {
if len(match) < 3 {
return nil, fmt.Errorf("invalid output form lm-sensors received: %s", output)
}
if strings.EqualFold(match[1], "Package id") {
if strings.EqualFold(match[1], "Package id") || strings.EqualFold(match[1], "CPU") {
p.State = match[2]
} else {
p.Attributes[util.ToSnakeCase(match[1])] = match[2]
Expand Down
1 change: 1 addition & 0 deletions sensor/cpu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func TestCPUTemp(t *testing.T) {
"core_3": "37.0",
"core_4": "38.0",
"core_5": "39.0",
"temp_1": "37.0",
},
}

Expand Down

0 comments on commit 8e4727b

Please sign in to comment.