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

SensorsTemperatures returns 0 values for all sensors on darwin arm64 (M1) #1332

Closed
splmatto opened this issue Jul 23, 2022 · 5 comments · Fixed by #1672
Closed

SensorsTemperatures returns 0 values for all sensors on darwin arm64 (M1) #1332

splmatto opened this issue Jul 23, 2022 · 5 comments · Fixed by #1672

Comments

@splmatto
Copy link

Describe the bug
the temperature value of each TemperatureStat object in the array returned by host.SensorsTemperatures() is 0 on an M1.

To Reproduce

package main

import (
	"encoding/json"
	"fmt"
	"github.com/shirou/gopsutil/v3/host"
)

func main() {
	tstat, _ := host.SensorsTemperatures()
	serialized, _ := json.Marshal(tstat)
	fmt.Printf("%s", string(serialized))
}

Here's the output:

[
  {
    "sensorKey": "TA0P",
    "temperature": 0,
    "sensorHigh": 0,
    "sensorCritical": 0
  },
  {
    "sensorKey": "TA1P",
    "temperature": 0,
    "sensorHigh": 0,
    "sensorCritical": 0
  },
  {
    "sensorKey": "TC0D",
    "temperature": 0,
    "sensorHigh": 0,
    "sensorCritical": 0
  },
  {
    "sensorKey": "TC0H",
    "temperature": 0,
    "sensorHigh": 0,
    "sensorCritical": 0
  },
  {
    "sensorKey": "TC0P",
    "temperature": 0,
    "sensorHigh": 0,
    "sensorCritical": 0
  },
  {
    "sensorKey": "TB0T",
    "temperature": 0,
    "sensorHigh": 0,
    "sensorCritical": 0
  },
  {
    "sensorKey": "TB1T",
    "temperature": 0,
    "sensorHigh": 0,
    "sensorCritical": 0
  },
  {
    "sensorKey": "TB2T",
    "temperature": 0,
    "sensorHigh": 0,
    "sensorCritical": 0
  },
  {
    "sensorKey": "TB3T",
    "temperature": 0,
    "sensorHigh": 0,
    "sensorCritical": 0
  },
  {
    "sensorKey": "TG0D",
    "temperature": 0,
    "sensorHigh": 0,
    "sensorCritical": 0
  },
  {
    "sensorKey": "TG0H",
    "temperature": 0,
    "sensorHigh": 0,
    "sensorCritical": 0
  },
  {
    "sensorKey": "TG0P",
    "temperature": 0,
    "sensorHigh": 0,
    "sensorCritical": 0
  },
  {
    "sensorKey": "TH0P",
    "temperature": 0,
    "sensorHigh": 0,
    "sensorCritical": 0
  },
  {
    "sensorKey": "TM0S",
    "temperature": 0,
    "sensorHigh": 0,
    "sensorCritical": 0
  },
  {
    "sensorKey": "TM0P",
    "temperature": 0,
    "sensorHigh": 0,
    "sensorCritical": 0
  },
  {
    "sensorKey": "TN0H",
    "temperature": 0,
    "sensorHigh": 0,
    "sensorCritical": 0
  },
  {
    "sensorKey": "TN0D",
    "temperature": 0,
    "sensorHigh": 0,
    "sensorCritical": 0
  },
  {
    "sensorKey": "TN0P",
    "temperature": 0,
    "sensorHigh": 0,
    "sensorCritical": 0
  },
  {
    "sensorKey": "TI0P",
    "temperature": 0,
    "sensorHigh": 0,
    "sensorCritical": 0
  },
  {
    "sensorKey": "TI1P",
    "temperature": 0,
    "sensorHigh": 0,
    "sensorCritical": 0
  },
  {
    "sensorKey": "TW0P",
    "temperature": 0,
    "sensorHigh": 0,
    "sensorCritical": 0
  }
]

Expected behavior
Return valid temperature sensor data for one or more of the sensors.

Environment (please complete the following information):

$ sw_vers
ProductName: macOS
ProductVersion: 12.4
BuildVersion: 21F79

$ uname -a
Darwin xxxx 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64

Additional context

go version go1.18 darwin/arm64

In contrast, here's the output from the same program built and executed on a darwin x86_64 host:

[
    {
        "sensorKey": "TA0P",
        "temperature": 0,
        "sensorHigh": 0,
        "sensorCritical": 0
    },
    {
        "sensorKey": "TA1P",
        "temperature": 0,
        "sensorHigh": 0,
        "sensorCritical": 0
    },
    {
        "sensorKey": "TC0D",
        "temperature": 0,
        "sensorHigh": 0,
        "sensorCritical": 0
    },
    {
        "sensorKey": "TC0H",
        "temperature": 0,
        "sensorHigh": 0,
        "sensorCritical": 0
    },
    {
        "sensorKey": "TC0P",
        "temperature": 31,
        "sensorHigh": 0,
        "sensorCritical": 0
    },
    {
        "sensorKey": "TB0T",
        "temperature": 0,
        "sensorHigh": 0,
        "sensorCritical": 0
    },
    {
        "sensorKey": "TB1T",
        "temperature": 0,
        "sensorHigh": 0,
        "sensorCritical": 0
    },
    {
        "sensorKey": "TB2T",
        "temperature": 0,
        "sensorHigh": 0,
        "sensorCritical": 0
    },
    {
        "sensorKey": "TB3T",
        "temperature": 0,
        "sensorHigh": 0,
        "sensorCritical": 0
    },
    {
        "sensorKey": "TG0D",
        "temperature": 0,
        "sensorHigh": 0,
        "sensorCritical": 0
    },
    {
        "sensorKey": "TG0H",
        "temperature": 0,
        "sensorHigh": 0,
        "sensorCritical": 0
    },
    {
        "sensorKey": "TG0P",
        "temperature": 0,
        "sensorHigh": 0,
        "sensorCritical": 0
    },
    {
        "sensorKey": "TH0P",
        "temperature": 0,
        "sensorHigh": 0,
        "sensorCritical": 0
    },
    {
        "sensorKey": "TM0S",
        "temperature": 0,
        "sensorHigh": 0,
        "sensorCritical": 0
    },
    {
        "sensorKey": "TM0P",
        "temperature": 30,
        "sensorHigh": 0,
        "sensorCritical": 0
    },
    {
        "sensorKey": "TN0H",
        "temperature": 0,
        "sensorHigh": 0,
        "sensorCritical": 0
    },
    {
        "sensorKey": "TN0D",
        "temperature": 0,
        "sensorHigh": 0,
        "sensorCritical": 0
    },
    {
        "sensorKey": "TN0P",
        "temperature": 0,
        "sensorHigh": 0,
        "sensorCritical": 0
    },
    {
        "sensorKey": "TI0P",
        "temperature": 0,
        "sensorHigh": 0,
        "sensorCritical": 0
    },
    {
        "sensorKey": "TI1P",
        "temperature": 0,
        "sensorHigh": 0,
        "sensorCritical": 0
    },
    {
        "sensorKey": "TW0P",
        "temperature": 31,
        "sensorHigh": 0,
        "sensorCritical": 0
    }
]
@SiegfredRodriguez
Copy link

Can confirm also happens on M2 Pro,

[ { "sensorKey": "TA0P", "sensorTemperature": 0 }, { "sensorKey": "TA1P", "sensorTemperature": 0 }, { "sensorKey": "TC0D", "sensorTemperature": 0 }, { "sensorKey": "TC0H", "sensorTemperature": 0 }, { "sensorKey": "TC0P", "sensorTemperature": 0 }, { "sensorKey": "TB0T", "sensorTemperature": 0 }, { "sensorKey": "TB1T", "sensorTemperature": 0 }, { "sensorKey": "TB2T", "sensorTemperature": 0 }, { "sensorKey": "TB3T", "sensorTemperature": 0 }, { "sensorKey": "TG0D", "sensorTemperature": 0 }, { "sensorKey": "TG0H", "sensorTemperature": 0 }, { "sensorKey": "TG0P", "sensorTemperature": 0 } { "sensorKey": "TH0P", "sensorTemperature": 0 }, { "sensorKey": "TM0S", "sensorTemperature": 0 } { "sensorKey": "TM0P", "sensorTemperature": 0 }, { "sensorKey": "TN0H", "sensorTemperature": 0 }, { "sensorKey": "TN0D", "sensorTemperature": 0 }, { "sensorKey": "TN0P", "sensorTemperature": 0 }, { "sensorKey": "TI0P", "sensorTemperature": 0 }, { "sensorKey": "TI1P", "sensorTemperature": 0 }, { "sensorKey": "TW0P", "sensorTemperature": 0 } ]

@e154
Copy link

e154 commented Nov 10, 2023

Is there progress in solving the problem?

@davidnewhall
Copy link
Contributor

Same problem with v4. Macs have no temperatures. Test code:

package main

import (
	"encoding/json"
	"fmt"
	"github.com/shirou/gopsutil/v4/sensors"
)

func main() {
	tstat, _ := sensors.SensorsTemperatures()
	serialized, _ := json.MarshalIndent(tstat, "", " ")
	fmt.Printf("%s", string(serialized))
}

Partial output (the rest looks like the original post):

[
 {
  "sensorKey": "TA0P",
  "temperature": 0,
  "sensorHigh": 0,
  "sensorCritical": 0
 },
 {
  "sensorKey": "TA1P",
  "temperature": 0,
  "sensorHigh": 0,
  "sensorCritical": 0
 },

@davidnewhall
Copy link
Contributor

@Girbons - any chance you know how to fix this? <3

@Girbons
Copy link
Contributor

Girbons commented Jul 4, 2024

@Girbons - any chance you know how to fix this? <3

I'll take a look why it isn't working on arm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants