Skip to content

Commit

Permalink
Merge pull request shirou#475 from Oxileo/issue442
Browse files Browse the repository at this point in the history
Fix shirou#442, trim sensor names and properly handle CentOS in host.SensorsTemperatures()
  • Loading branch information
Lomanic authored Dec 20, 2017
2 parents 27389f0 + e3ae39a commit 7ec06ec
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions host/host_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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,
})
}
Expand Down

0 comments on commit 7ec06ec

Please sign in to comment.