mirror of
https://github.com/status-im/consul.git
synced 2025-01-11 22:34:55 +00:00
95c027a3ea
https://github.com/shirou/gopsutil/pull/895 is merged and fixes our problem. Time to update. Since there is no new version just yet, updating to the sha.
52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
// +build darwin
|
|
// +build cgo
|
|
|
|
package host
|
|
|
|
// #cgo LDFLAGS: -framework IOKit
|
|
// #include "smc_darwin.h"
|
|
import "C"
|
|
import "context"
|
|
|
|
func SensorsTemperatures() ([]TemperatureStat, error) {
|
|
return SensorsTemperaturesWithContext(context.Background())
|
|
}
|
|
|
|
func SensorsTemperaturesWithContext(ctx context.Context) ([]TemperatureStat, error) {
|
|
temperatureKeys := []string{
|
|
C.AMBIENT_AIR_0,
|
|
C.AMBIENT_AIR_1,
|
|
C.CPU_0_DIODE,
|
|
C.CPU_0_HEATSINK,
|
|
C.CPU_0_PROXIMITY,
|
|
C.ENCLOSURE_BASE_0,
|
|
C.ENCLOSURE_BASE_1,
|
|
C.ENCLOSURE_BASE_2,
|
|
C.ENCLOSURE_BASE_3,
|
|
C.GPU_0_DIODE,
|
|
C.GPU_0_HEATSINK,
|
|
C.GPU_0_PROXIMITY,
|
|
C.HARD_DRIVE_BAY,
|
|
C.MEMORY_SLOT_0,
|
|
C.MEMORY_SLOTS_PROXIMITY,
|
|
C.NORTHBRIDGE,
|
|
C.NORTHBRIDGE_DIODE,
|
|
C.NORTHBRIDGE_PROXIMITY,
|
|
C.THUNDERBOLT_0,
|
|
C.THUNDERBOLT_1,
|
|
C.WIRELESS_MODULE,
|
|
}
|
|
var temperatures []TemperatureStat
|
|
|
|
C.open_smc()
|
|
defer C.close_smc()
|
|
|
|
for _, key := range temperatureKeys {
|
|
temperatures = append(temperatures, TemperatureStat{
|
|
SensorKey: key,
|
|
Temperature: float64(C.get_temperature(C.CString(key))),
|
|
})
|
|
}
|
|
return temperatures, nil
|
|
}
|