Replaced sys by HostSys
Added TemperatureStat string test
This commit is contained in:
parent
8b08ca5fdc
commit
22aefb460a
|
@ -525,14 +525,14 @@ func Virtualization() (string, string, error) {
|
|||
|
||||
func SensorsTemperatures() ([]TemperatureStat, error) {
|
||||
var temperatures []TemperatureStat
|
||||
files, err := filepath.Glob("/sys/class/hwmon/hwmon*/temp*_*")
|
||||
files, err := filepath.Glob(common.HostSys("/class/hwmon/hwmon*/temp*_*"))
|
||||
if err != nil {
|
||||
return temperatures, err
|
||||
}
|
||||
if len(files) == 0 {
|
||||
// CentOS has an intermediate /device directory:
|
||||
// https://github.com/giampaolo/psutil/issues/971
|
||||
files, err = filepath.Glob("/sys/class/hwmon/hwmon*/temp*_*")
|
||||
files, err = filepath.Glob(common.HostSys("/class/hwmon/hwmon*/temp*_*"))
|
||||
if err != nil {
|
||||
return temperatures, err
|
||||
}
|
||||
|
|
|
@ -103,3 +103,14 @@ func TestHostGuid(t *testing.T) {
|
|||
t.Logf("Host id value: %v", hi.HostID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTemperatureStat_String(t *testing.T) {
|
||||
v := TemperatureStat{
|
||||
SensorKey: "CPU",
|
||||
Temperature: 1.1,
|
||||
}
|
||||
s := `{"sensorKey":"CPU","sensorTemperature":1.1}`
|
||||
if s != fmt.Sprintf("%v", v) {
|
||||
t.Errorf("TemperatureStat string is invalid")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue