From e3ae39aa5b8ece9cd69ff0de52471c0a87f966d5 Mon Sep 17 00:00:00 2001 From: Lomanic Date: Tue, 19 Dec 2017 22:52:41 +0100 Subject: [PATCH] Fix #442, trim sensor names and properly handle CentOS in host.SensorsTemperatures() --- host/host_linux.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/host/host_linux.go b/host/host_linux.go index 14893a4..d5ada58 100644 --- a/host/host_linux.go +++ b/host/host_linux.go @@ -541,7 +541,7 @@ func SensorsTemperatures() ([]TemperatureStat, error) { if len(files) == 0 { // CentOS has an intermediate /device directory: // https://github.com/giampaolo/psutil/issues/971 - files, err = filepath.Glob(common.HostSys("/class/hwmon/hwmon*/temp*_*")) + files, err = filepath.Glob(common.HostSys("/class/hwmon/hwmon*/device/temp*_*")) if err != nil { return temperatures, err } @@ -557,12 +557,12 @@ func SensorsTemperatures() ([]TemperatureStat, error) { if err != nil { return temperatures, err } - temperature, err := strconv.ParseFloat(string(current), 64) + temperature, err := strconv.ParseFloat(strings.TrimSpace(string(current)), 64) if err != nil { continue } temperatures = append(temperatures, TemperatureStat{ - SensorKey: string(name), + SensorKey: strings.TrimSpace(string(name)), Temperature: temperature / 1000.0, }) }