Skip to content

Commit

Permalink
Merge pull request #225 from anatol/master
Browse files Browse the repository at this point in the history
Adjust nvme temperature from Kelvins to Celsius
  • Loading branch information
xxxserxxx authored Jul 28, 2022
2 parents ba918ce + 3518c52 commit b892b79
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion devices/temp_nix.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import (
"github.com/shirou/gopsutil/host"
)

// offset for converting temperature from Kelvins to Celsius (273.15)
const kelvinOffset = 273

var smDevices map[string]smart.Device

func init() {
Expand Down Expand Up @@ -88,7 +91,8 @@ func getTemps(temps map[string]int) map[string]error {
log.Printf("error getting smart data for %s: %s", name, err)
continue
}
temps[name] = int(data.Temperature)
// nvme reports the temperature in Kelvins
temps[name] = int(data.Temperature) - kelvinOffset
default:
}
}
Expand Down

0 comments on commit b892b79

Please sign in to comment.