You are not logged in.

#1 2018-12-07 16:31:27

rxl_980
Member
Registered: 2016-12-09
Posts: 12

[SOLVED] How can I find absolute device paths for hwmon sensors?

Hello,

What command can I use in the terminal to find hwmon absolute device paths? I'm trying to setup fan control and wanted to use the absolute device paths in my fancontrol file but I am not able to work out what command I need to use to find these.

In the wiki, under  the fan control page  https://wiki.archlinux.org/index.php/Fan_speed_control it says "Another alternative is to use absolute device names in the configuration" under the section healed "Fancontrol (lm-sensors)". There is a link to another forum post where someone has shown a configuration file specified in that way. But what I cannot understand is how the author of that file got the path names specified in it.

I've got my config file set up already, I just would like to use the absolute paths. If only to know how to do it.

Last edited by rxl_980 (2018-12-08 10:59:38)

Offline

#2 2018-12-07 16:39:57

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 20,424
Website

Re: [SOLVED] How can I find absolute device paths for hwmon sensors?

My initial answer was going to be just to explore /sys/devices.  But it seems the hwmon names are identical to the file names, you just need to find the correct path.  For example, in the referenced thread, there is a hwmon device named fan3_input.  To find the absolute path for that, just use the following:

find /sys/devices/ -name fan3_input

If by chance there are too many matches, add the flag `-path */hwmon/*`.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2018-12-07 17:23:31

Ropid
Member
Registered: 2015-03-09
Posts: 446

Re: [SOLVED] How can I find absolute device paths for hwmon sensors?

Look at the detailed directory listing of the entries in /sys/class/hwmon. The entries will be links that point to somewhere in /sys/devices/:

ls -l /sys/devices/hwmon

For me here I see these links:

$ tree /sys/class/hwmon
/sys/class/hwmon
├── hwmon0 -> ../../devices/virtual/thermal/thermal_zone0/hwmon0
├── hwmon1 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/hwmon/hwmon1
├── hwmon2 -> ../../devices/platform/coretemp.0/hwmon/hwmon2
└── hwmon3 -> ../../devices/platform/it87.2608/hwmon/hwmon3

So for example "/sys/class/hwmon2" is also "/sys/devices/platform/coretemp.0/hwmon/hwmon2".

In your scripts, do something like this to get the path into a variable:

device_path=$(echo /sys/devices/platform/coretemp.0/hwmon/hwmon*)

Doing it like this is needed because the number in the "hwmon*" name will change depending on how fast different things initialize at boot.

Last edited by Ropid (2018-12-07 17:25:15)

Offline

#4 2018-12-07 18:20:05

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 20,424
Website

Re: [SOLVED] How can I find absolute device paths for hwmon sensors?

If you know where a symlink will be, just use `readlink -f /path/to/symlink`.  Using echo with a wildcard could be very error-prone.

Last edited by Trilby (2018-12-07 18:20:18)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2018-12-07 19:39:19

Ropid
Member
Registered: 2015-03-09
Posts: 446

Re: [SOLVED] How can I find absolute device paths for hwmon sensors?

Trilby wrote:

If you know where a symlink will be, just use `readlink -f /path/to/symlink`.  Using echo with a wildcard could be very error-prone.

I couldn't come up with a better solution. The problem is I couldn't find symlinks with a fixed name to use. A real device's location is for example this here:

/sys/devices/platform/coretemp.0/hwmon/hwmon2

And then the symlink I could find that points to this spot is also changing that number in its name. I tried searching like this:

find /sys -type l -printf '%p -> %l\n' | grep hwmon

Last edited by Ropid (2018-12-07 19:39:41)

Offline

#6 2018-12-07 23:07:31

rxl_980
Member
Registered: 2016-12-09
Posts: 12

Re: [SOLVED] How can I find absolute device paths for hwmon sensors?

Thank you both.

'find' with the name flag worked for me to locate the device paths for the temperature sensors and fan inputs.

But it had not crossed my mind that the hwmon numbers (e.g. hwmon2) might change on boot. In the example thread the wiki links to the author of the fancontrol file with the 'absolute' device paths has used [[:print:]]* in place of the numbers and now I can see why. I'll give that a try.

Offline

Board footer

Powered by FluxBB