You are not logged in.

#1 2024-09-01 07:07:23

amixra
Member
Registered: 2022-01-24
Posts: 125

[Solved] Which one of the 6 temperature is the CPU one?

$ sensors
iwlwifi_1-virtual-0
Adapter: Virtual device
temp1:        +49.0°C

nvme-pci-e100
Adapter: PCI adapter
Composite:    +41.9°C  (low  =  -0.1°C, high = +82.8°C)
                       (crit = +89.8°C)
Sensor 1:     +42.9°C  (low  = -273.1°C, high = +65261.8°C)

coretemp-isa-0000
Adapter: ISA adapter
Package id 0:  +57.0°C  (high = +100.0°C, crit = +100.0°C)
Core 0:        +54.0°C  (high = +100.0°C, crit = +100.0°C)
Core 1:        +54.0°C  (high = +100.0°C, crit = +100.0°C)
Core 2:        +55.0°C  (high = +100.0°C, crit = +100.0°C)
Core 3:        +54.0°C  (high = +100.0°C, crit = +100.0°C)

dell_smm-virtual-0
Adapter: Virtual device
fan1:           0 RPM  (min =    0 RPM, max = 5800 RPM)
temp1:        +58.0°C
temp2:        +47.0°C
temp3:        +43.0°C
temp4:        +35.0°C

BAT0-acpi-0
Adapter: ACPI interface
in0:          11.69 V
curr1:       741.00 mA
$ cat /sys/class/thermal/thermal_zone0/temp
20000
$ cat /sys/class/thermal/thermal_zone1/temp                
47050
$ cat /sys/class/thermal/thermal_zone2/temp                
43050
$ cat /sys/class/thermal/thermal_zone3/temp                
58050
$ cat /sys/class/thermal/thermal_zone4/temp                
49000
$ cat /sys/class/thermal/thermal_zone5/temp                
57000

By default, I always see thermal_zone0 temperature, which is 20 degree Celsius.

Last edited by amixra (2024-09-03 14:47:17)


Experiment at-least.

Offline

#2 2024-09-01 08:14:41

mesaprotector
Member
Registered: 2024-03-03
Posts: 170

Re: [Solved] Which one of the 6 temperature is the CPU one?

coretemp-isa-0000 is where your CPU's temperature sensors are listed. Core 0-3 show the individual temperatures for each core, and "Package id 0" is usually the highest temperature out of all of the sensors the CPU has.

Offline

#3 2024-09-01 12:00:42

amixra
Member
Registered: 2022-01-24
Posts: 125

Re: [Solved] Which one of the 6 temperature is the CPU one?

May you also help which file contains the required value? I have to display that in a widget in wm that takes file paths as input.


Experiment at-least.

Offline

#4 2024-09-01 15:45:08

mesaprotector
Member
Registered: 2024-03-03
Posts: 170

Re: [Solved] Which one of the 6 temperature is the CPU one?

amixra wrote:

May you also help which file contains the required value? I have to display that in a widget in wm that takes file paths as input.

When I needed to do something similar I just grepped it from the sensors command. I think I did something like "sensors | grep -i Package | head -n1 | cut -c17-18". But you could probably figure it out by monitoring both at the same time and seeing which temperature matches the one in "package id 0".

Offline

#5 2024-09-01 17:54:00

stanczew
Member
Registered: 2021-03-02
Posts: 91

Re: [Solved] Which one of the 6 temperature is the CPU one?

Look in /sys/class/hwmon instead of /sys/class/thermal. There are "name" files in hwmonX subdirectories, one of these should read "coretemp", which would be the CPU. Then go through tempX_label files to find "Package id 0".

Last edited by stanczew (2024-09-01 17:55:13)

Offline

#6 2024-09-02 14:45:57

amixra
Member
Registered: 2022-01-24
Posts: 125

Re: [Solved] Which one of the 6 temperature is the CPU one?

stanczew wrote:

Look in /sys/class/hwmon instead of /sys/class/thermal. There are "name" files in hwmonX subdirectories, one of these should read "coretemp", which would be the CPU. Then go through tempX_label files to find "Package id 0".

Yeah I followed that
Found

/sys/class/hwmon/hwmon5/name
--------------------------------------------
coretemp 

then

/sys/class/hwmon/hwmon5/temp1_label
-----------------------------------------------------
Package id 0

Where is the temperature? I suppose you intended that temp1_label was the location of the file path where I would find temperature.


Experiment at-least.

Offline

#7 2024-09-02 15:08:52

stanczew
Member
Registered: 2021-03-02
Posts: 91

Re: [Solved] Which one of the 6 temperature is the CPU one?

Next to temp1_label should be temp1_input, which returns the temperature reading.

Offline

#8 2024-09-02 17:19:33

amixra
Member
Registered: 2022-01-24
Posts: 125

Re: [Solved] Which one of the 6 temperature is the CPU one?

Yeah thanks!


Experiment at-least.

Offline

#9 2024-09-03 14:29:00

amixra
Member
Registered: 2022-01-24
Posts: 125

Re: [Solved] Which one of the 6 temperature is the CPU one?

No actually it changes with probably every boot. This time, same files are in hwmon4.

But yeah! Now I know how to find in which one hwmon* I will find the temperature. And probably use solution given above by invoking command and grepping and cutting required piece.

Last edited by amixra (2024-09-03 14:46:41)


Experiment at-least.

Offline

#10 2024-09-03 17:10:20

stanczew
Member
Registered: 2021-03-02
Posts: 91

Re: [Solved] Which one of the 6 temperature is the CPU one?

You can look at the target of hwmonX symlink, and use that directly.
E.g.

$ cat /sys/class/hwmon/hwmon3/name
k10temp
$ ls -l /sys/class/hwmon/hwmon3
lrwxrwxrwx 1 root root 0 Aug 29 17:29 /sys/class/hwmon/hwmon3 -> ../../devices/pci0000:00/0000:00:18.3/hwmon/hwmon3
$ cat /sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon*/name
k10temp

Offline

#11 2024-09-04 04:24:02

amixra
Member
Registered: 2022-01-24
Posts: 125

Re: [Solved] Which one of the 6 temperature is the CPU one?

Hmm... let see if hwmon* stays same this time

$ cat /sys/devices/platform/coretemp.0/hwmon/hwmon5/temp1_label /sys/devices/platform/coretemp.0/hwmon/hwmon5/temp1_input                         
Package id 0
53000

Experiment at-least.

Offline

#12 2024-09-04 09:01:20

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 23,606

Re: [Solved] Which one of the 6 temperature is the CPU one?

hwmon5 will not stay the same (that's assigned dynamically among all hwmonitors and not deterministic unless you enforce it with udev rules), but you can just wildcard that away with a * or a ? since the rest of the path should enforce the actual monitor. What widget only takes a hard coded file path?

Offline

#13 2024-09-04 14:50:40

amixra
Member
Registered: 2022-01-24
Posts: 125

Re: [Solved] Which one of the 6 temperature is the CPU one?

OK, so grepping and cutting FTW. Widget can take as many file as I want and already have few directories by default as given below:

/sys/class/devices/virtual/thermal/thermal_zone*
/sys/class/devices/platform/coretemp*/hwmon/hwon*

It has always been showing 20 C on this laptop from day 1 but was working for another laptop without any changes.
Apparently, I have none of those directories.
So, I tried providing it one file if that can reduce confusion for the widget. As providing following path rendered N/A C in the widget.
/sys/class/hwmon/hwmon*/temp1_input


Experiment at-least.

Offline

#14 2024-09-04 14:54:18

amixra
Member
Registered: 2022-01-24
Posts: 125

Re: [Solved] Which one of the 6 temperature is the CPU one?

Following is widget code

-- Coretemp
local tempicon = wibox.widget.imagebox(theme.widget_temp)
local temp = lain.widget.temp({
    tempfile = '/sys/class/hwmon/hwmon*/temp1_input',
    settings = function()
        widget:set_markup(markup.fontfg(theme.font, "#f1af5f", coretemp_now .. "°C "))
    end
})

Following is the relevant markdown I was referring (text editor showed me that reference on hovering)

## Usage

[Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage)

### Description

Shows the current CPU temperature.

```lua
local mytemp = lain.widget.temp()
```

## Input table

Variable | Meaning | Type | Default
--- | --- | --- | ---
`timeout` | Refresh timeout (in seconds) | integer | 30
`tempfile` | Path of file which stores core temperature value | string | "/sys/devices/virtual/thermal/thermal_zone0/temp"
`settings` | User settings | function | empty function
`widget` | Widget to render | function | `wibox.widget.textbox`

`settings` can use the string `coretemp_now`, which contains the info retrieved from `tempfile`, and the table `temp_now`, which contains an entry for each `*temp*` file in each directory in the following paths:

```shell
/sys/class/devices/virtual/thermal/thermal_zone*
/sys/class/devices/platform/coretemp*/hwmon/hwon*
```

All values are expressed in Celsius (GNU/Linux standard).

## Output table

Variable | Meaning | Type
--- | --- | ---
`widget` | The widget | `wibox.widget.textbox`
`update` | Update `widget` | function

Experiment at-least.

Offline

Board footer

Powered by FluxBB