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

temperature on rasbian #391

Closed
JuanRamino opened this issue Jun 27, 2017 · 7 comments · Fixed by #861
Closed

temperature on rasbian #391

JuanRamino opened this issue Jun 27, 2017 · 7 comments · Fixed by #861

Comments

@JuanRamino
Copy link

JuanRamino commented Jun 27, 2017

Hi,

On Rasbian (ARMv6 ) host.SensorsTemperatures() return []

I found the right place to get CPU temp is /sys/class/thermal/thermal_zone*
and not /sys/class/hwmon/hwmon*/temp*_*

@Lomanic
Copy link
Collaborator

Lomanic commented Dec 21, 2017

I can confirm on raspbian on an old Raspberry Model B 512 Mb. This is the same behavior as psutil too.

Note this line in python psutil that says that /sys/class/thermal/thermal_zone is an older interface more difficult to parse.

@muratsplat
Copy link

I want to take a note in here..
https://www.raspberrypi.org/forums/viewtopic.php?t=34994

#!/bin/bash
cpuTemp0=$(cat /sys/class/thermal/thermal_zone0/temp)
cpuTemp1=$(($cpuTemp0/1000))
cpuTemp2=$(($cpuTemp0/100))
cpuTempM=$(($cpuTemp2 % $cpuTemp1))

gpuTemp0=$(/opt/vc/bin/vcgencmd measure_temp)
gpuTemp0=${gpuTemp0//\'/º}
gpuTemp0=${gpuTemp0//temp=/}

echo CPU Temp: $cpuTemp1"."$cpuTempM"ºC"
echo GPU Temp: $gpuTemp0

@cjbassi
Copy link

cjbassi commented Aug 15, 2018

Not getting any temperatures either on Pi Zero W with the latest image of Raspian Strech Lite. cjbassi/gotop#37

edit: and same issue on a Raspberry Pi Model 3 B+

@Lomanic Lomanic self-assigned this Aug 18, 2019
Lomanic added a commit to Lomanic/gopsutil that referenced this issue Aug 18, 2019
@Lomanic
Copy link
Collaborator

Lomanic commented Aug 18, 2019

I pushed a commit in https://github.com/Lomanic/gopsutil/tree/issue391, this is what is returned on a RPi model 1 B 512 MB

{"sensorKey":"bcm2835_thermal","sensorTemperature":42.236}
package main

// https://github.com/shirou/gopsutil/issues/340

import (
        "fmt"
        "os"

        "github.com/shirou/gopsutil/host"
)

func main() {
        temps, err := host.SensorsTemperatures()
        if err != nil {
                fmt.Println("err:", err)
                os.Exit(1)
        }
        for _, t := range temps {
                fmt.Printf("%+v\n", t)
        }
}

I see in https://github.com/cjbassi/gotop/blob/9bde31ff9ace22a5f667e9037e69713fa134653b/src/widgets/temp_linux.go#L21 that you check if a sensor name finishes with _input, so as-is @cjbassi you will have to adapt your code to include *_thermal readings.

Using only thermal readings, results are even different on my x64 Dell laptop

{"sensorKey":"acpitz","sensorTemperature":25}
{"sensorKey":"INT3400 Thermal","sensorTemperature":20}
{"sensorKey":"TSKN","sensorTemperature":44}
{"sensorKey":"NGFF","sensorTemperature":43}
{"sensorKey":"B0D4","sensorTemperature":49}
{"sensorKey":"x86_pkg_temp","sensorTemperature":56}
{"sensorKey":"iwlwifi","sensorTemperature":43}

So this bears the question, shall we append _input to these values, shall we lowercase them? (as a middle ground and to be able to differentiate these results against hwmon ones, we could append _thermal if the sensor name doesn't already include it, this would be even better). Please note also that reading from thermal_zone was rejected in psutil at giampaolo/psutil#371 (comment) because it's not compatible with hwmon (no max values and different names).

@Lomanic
Copy link
Collaborator

Lomanic commented Aug 18, 2019

hwmon driver will be enabled by default in next kernel version (current is 4.19) of Raspbian, see raspberrypi/linux#2182 (comment)
So implementing thermal driver readings in gopsutil might be simply unnecessary and this issue may be closed.

@elipavlov
Copy link

elipavlov commented Apr 29, 2020

Hi there.

Why we can't create PR with @Lomanic's commit. It's looking fine and resolves the issue as i may see.

About my case.
I've encountered this issue not directly.
i've deployed ubuntu 20.04 with kernel such as:

$ uname -srm
Linux 5.4.0-1008-raspi aarch64

I've installed telegraf (by influxdata) agent to achieve monitoring goals.
Since i enabled input.temp plugin i've interested why it didn't work properly.
That's all, i'm here.
(Related issue on telegraf forum: https://community.influxdata.com/t/telegraf-inputs-temp-plugin-on-raspberry-pi/7435)

@Lomanic
Copy link
Collaborator

Lomanic commented Apr 30, 2020

Just tested my old branch on my Raspberry Pi and returned value (bcm2835_thermal) is the same as psutil (reading thermal_zone files was implemented in psutil in giampaolo/psutil#1345), so this should be OK regarding API.

Using the previous test program and python -c "import psutil; print psutil.sensors_temperatures()"

{"sensorKey":"bcm2835_thermal","sensorTemperature":44.388} # gopsutil
{'bcm2835_thermal': [shwtemp(label='', current=44.388, high=None, critical=None)]} # psutil

(our TemperatureStat type doesn't include high and critical values)

Why we can't create PR with @Lomanic's commit. It's looking fine and resolves the issue as i may see.

I didn't create the corresponding PR at the time because of my concerns expressed in the last paragraph of #391 (comment), as it changes the API with different values returned. But as psutil doesn't change their name like I was suggesting, we are already aligned with it and can move forward.

shirou added a commit that referenced this issue May 1, 2020
[host][linux] Fix #391 retrieve sensors temps on OSes lacking hwmon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants