diff options
Diffstat (limited to 'devices/temp_linux.go')
-rw-r--r-- | devices/temp_linux.go | 28 |
1 files changed, 3 insertions, 25 deletions
diff --git a/devices/temp_linux.go b/devices/temp_linux.go index 09e7d3c..6967232 100644 --- a/devices/temp_linux.go +++ b/devices/temp_linux.go @@ -5,37 +5,15 @@ package devices import ( "strings" - psHost "github.com/shirou/gopsutil/host" + "github.com/shirou/gopsutil/host" ) -func init() { - devs() // Populate the sensorMap - RegisterTemp(getTemps) - RegisterDeviceList(Temperatures, devs, defs) -} - -func getTemps(temps map[string]int) map[string]error { - sensors, err := psHost.SensorsTemperatures() - if err != nil { - return map[string]error{"psHost": err} - } - for _, sensor := range sensors { - label := sensorMap[sensor.SensorKey] - if _, ok := temps[label]; ok { - temps[label] = int(sensor.Temperature) - } - } - return nil -} - -// Optimization to avoid string manipulation every update -var sensorMap map[string]string - +// All possible thermometers func devs() []string { if sensorMap == nil { sensorMap = make(map[string]string) } - sensors, err := psHost.SensorsTemperatures() + sensors, err := host.SensorsTemperatures() if err != nil { return []string{} } |