Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update temperature functions for darwin #267

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 54 additions & 2 deletions devices/smc.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@
"TH3P" "HDD Bay 4"
"TO0P" "Optical Drive"
"TB0T" "Battery TS_MAX"
"TB1T" "Battery 1"
"TB2T" "Battery 2"
"TB3T" "Battery"
"Tp0P" "Power Supply 1"
"Tp0C" "Power Supply 1 Alt."
Expand Down Expand Up @@ -160,3 +158,57 @@
"PB0R" "Battery Rail"
"PDTR" "DC In Total"
"PSTR" "System Total"
"Ts1P" "Actuator"
"TW0P" "Airport 1"
"TW0P" "Airport"
"TB1T" "Battery 1"
"TB2T" "Battery 2"
"TB2T" "Battery 3"
"Te05" "CPU Efficiency Core 1"
"Te0L" "CPU Efficiency Core 2"
"Te0P" "CPU Efficiency Core 3"
"Tp01" "CPU Performance Core 1"
"Tp05" "CPU Performance Core 2"
"Tp09" "CPU Performance Core 3"
"Tp0D" "CPU Performance Core 4"
"Tp0X" "CPU Performance Core 5"
"Tp0b" "CPU Performance Core 6"
"Tp0f" "CPU Performance Core 7"
"Tp0j" "CPU Performance Core 8"
"TH0x" "Drive 0 OOBv3 Max"
"Tg0j" "GPU 2"
"TG0H" "GPU Heatsink 1"
"TH0x" "NAND"
"tcal" "PMU tcal"
"tdev1" "PMU tdev1"
"tdev2" "PMU tdev2"
"tdev3" "PMU tdev3"
"tdev4" "PMU tdev4"
"tdev5" "PMU tdev5"
"tdev6" "PMU tdev6"
"tdev7" "PMU tdev7"
"tdev8" "PMU tdev8"
"tdie1" "PMU tdie1"
"tdie2" "PMU tdie2"
"tdie3" "PMU tdie3"
"tdie4" "PMU tdie4"
"tdie5" "PMU tdie5"
"tdie6" "PMU tdie6"
"tdie7" "PMU tdie7"
"tdie8" "PMU tdie8"
"tcal" "PMU2 tcal"
"tdev1" "PMU2 tdev1"
"tdev2" "PMU2 tdev2"
"tdev3" "PMU2 tdev3"
"tdev4" "PMU2 tdev4"
"tdev5" "PMU2 tdev5"
"tdie1" "PMU2 tdie1"
"tdie2" "PMU2 tdie2"
"tdie3" "PMU2 tdie3"
"tdie4" "PMU2 tdie4"
"tdie5" "PMU2 tdie5"
"tdie6" "PMU2 tdie6"
"tdie7" "PMU2 tdie7"
"tdie8" "PMU2 tdie8"
"Tp0C" "Power Supply 1 Alt"
"Tp0P" "Powerboard 1"
41 changes: 35 additions & 6 deletions devices/temp_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,30 @@ import (
"encoding/csv"
"io"
"log"

"github.com/shirou/gopsutil/v3/host"
"strings"
"github.com/shirou/gopsutil/v4/sensors"
)

func update(temps map[string]int) map[string]error {

sensors, err := sensors.SensorsTemperatures()

if err != nil {
return map[string]error{"gopsutil": err}
}
for _, sensor := range sensors {
if _, ok := temps[sensor.SensorKey]; ok {
temps[sensor.SensorKey] = int(sensor.Temperature)
}
}
return nil
}

func init() {
RegisterTemp(update)
RegisterDeviceList(Temperatures, devs, devs)
}

// All possible thermometers
func devs() []string {
// Did we already populate the sensorMap?
Expand All @@ -21,7 +41,7 @@ func devs() []string {
}
// Otherwise, get the sensor data from the system & filter it
ids := loadIDs()
sensors, err := host.SensorsTemperatures()
sensors, err := sensors.SensorsTemperatures()
if err != nil {
log.Printf("error getting sensor list for temps: %s", err)
return []string{}
Expand All @@ -33,9 +53,18 @@ func devs() []string {
if sensor.Temperature == 0 {
continue
}
if label, ok := ids[sensor.SensorKey]; ok {
sensorMap[sensor.SensorKey] = label
rv = append(rv, label)

sensor_labels := strings.Split(sensor.SensorKey, " ")

if len(sensor_labels) != 2 {
continue
}

sensor_label := sensor_labels[1]

if _, ok := ids[sensor_label]; ok {
sensorMap[sensor_label] = sensor.SensorKey
rv = append(rv, sensor.SensorKey)
}
}
return rv
Expand Down
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ require (
github.com/mattn/go-runewidth v0.0.13
github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0
github.com/shirou/gopsutil/v3 v3.24.5
github.com/stretchr/testify v1.9.0
github.com/shirou/gopsutil/v4 v4.25.1
github.com/stretchr/testify v1.10.0
github.com/xxxserxxx/lingo/v2 v2.0.1
)

Expand All @@ -21,6 +22,7 @@ require (
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/ebitengine/purego v0.8.2 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/jaypipes/pcidb v1.0.0 // indirect
Expand All @@ -40,7 +42,7 @@ require (
github.com/valyala/fastrand v1.1.0 // indirect
github.com/valyala/histogram v1.2.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
12 changes: 8 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ github.com/distatus/battery v0.10.0 h1:YbizvmV33mqqC1fPCAEaQGV3bBhfYOfM+2XmL+mvt
github.com/distatus/battery v0.10.0/go.mod h1:STnSvFLX//eEpkaN7qWRxCWxrWOcssTDgnG4yqq9BRE=
github.com/droundy/goopt v0.0.0-20220217183150-48d6390ad4d1 h1:6PKU05V7zJIJlTBq7AnEIrLVEUIYF4NjTU2a28Ho6ko=
github.com/droundy/goopt v0.0.0-20220217183150-48d6390ad4d1/go.mod h1:ytRJ64WkuW4kf6/tuYqBATBCRFUP8X9+LDtgcvE+koI=
github.com/ebitengine/purego v0.8.2 h1:jPPGWs2sZ1UgOSgD2bClL0MJIqu58nOmIcBuXr62z1I=
github.com/ebitengine/purego v0.8.2/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
Expand Down Expand Up @@ -91,13 +93,15 @@ github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0 h1:Xuk8ma/ibJ1
github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0/go.mod h1:7AwjWCpdPhkSmNAgUv5C7EJ4AbmjEB3r047r3DXWu3Y=
github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI=
github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U30r2NfcubMVk=
github.com/shirou/gopsutil/v4 v4.25.1 h1:QSWkTc+fu9LTAWfkZwZ6j8MSUk4A2LV7rbH0ZqmLjXs=
github.com/shirou/gopsutil/v4 v4.25.1/go.mod h1:RoUCUpndaJFtT+2zsZzzmhvbfGoDCJ7nFXKJf8GqJbI=
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
Expand Down Expand Up @@ -135,8 +139,8 @@ golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
Expand Down
1 change: 1 addition & 0 deletions vendor/github.com/ebitengine/purego/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

201 changes: 201 additions & 0 deletions vendor/github.com/ebitengine/purego/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading