summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxxxserxxx <60757196+xxxserxxx@users.noreply.github.com>2022-07-28 13:46:58 -0500
committerGitHub <noreply@github.com>2022-07-28 13:46:58 -0500
commitb892b792b2689703aa673ba0590713c07d76821e (patch)
treec8b499515d29847b3ceb171afcc6b364d79216d5
parentba918ce4b3b1cbc5ec88295b18d5be31e1f9d9bf (diff)
parent3518c5262ffb3277b3e0f5bda0d801cd7430d7a4 (diff)
Merge pull request #225 from anatol/master
Adjust nvme temperature from Kelvins to Celsius
-rw-r--r--devices/temp_nix.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/devices/temp_nix.go b/devices/temp_nix.go
index 1c40a52..1f0d583 100644
--- a/devices/temp_nix.go
+++ b/devices/temp_nix.go
@@ -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() {
@@ -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:
}
}