3

I'm using conky to show a status of my CPU temperatures, and overall I'm satisfied, except for one thing: Every time I reboot, the temperature status breaks!

Looking at conky's stderr I see this:

conky: can't open '/sys/bus/platform/devices/coretemp.0/hwmon/hwmon3/temp1_input': No such file or directory

"That's odd," I think, "this worked fine before I rebooted."

So then I go look in /sys/bus/platform/devices/coretemp.0/hwmon, and I discover that the folder that used to be called hwmon3 is now called hwmon4. "Okay," so I tweak my .conkyrc to refer to hwmon4 instead.

But then I reboot again and it's broken again!

Is there a way I can force that coretemp.0/hwmon device to always have the same folder hierarchy underneath it?

feuGene
  • 131
  • look at the middle of the accepted answer of this post .. https://stackoverflow.com/questions/2530096/how-to-find-all-serial-devices-ttys-ttyusb-on-linux-without-opening-them – jsotola Jan 27 '19 at 01:54
  • 1
    There's a lot of things in /sys that are ordered based on the order devices respond to the kernel while it's initializing itself, and they're essentially random. But to my naive mind, /sys/devices/platform/coretemp.0 shouldn't be among those. CPU0 is basically a guarantee; if it didn't exist, you wouldn't get to the part of the bootup process where your computer discovers the BIOS. But I can confirm your finding. I'd be tempted to just dynamically update my .conkyrc based on what's in that directory in my login script. – Ed Grimm Jan 27 '19 at 02:01
  • 1
    You might find the other hwmon devices listed in /sys/class/hwmon/, and in particular each name file will tell you what the device is. Perhaps they are discovered in a parallel way and so get assigned numbers depending on the speed at which they respond. – meuh Jan 27 '19 at 17:09

1 Answers1

1

/sys/class/hwmon/ symlinks seem to get created based on the order in which modules load, which you can force by blacklisting them and then manually loading them in the desired order as specified in this post.

However, conky's hwmon actually accepts the name of the device so you can just use that!

For example, instead of ${hwmon 5 temp 1} I can do ${hwmon coretemp temp 1}.

Then the following will list the current number > name mapping:

for dir in /sys/class/hwmon/*; do echo -n "$dir: "; cat $dir/name; done

sensors also lists the device names, but joined up with adapter name.


If you wish to access those values without conky's hwmon (e.g. for conky's execgraph), this is probably a hack and I can't guarantee it's reliable, but: all of the directories that /sys/class/hwmon/ symlink to that have a numbered hwmon folder in them only seem to have one folder, so you can just get in there with *.

For example, my /sys/class/hwmon/hwmon5 links to /sys/bus/platform/devices/coretemp.0/hwmon/hwmon5, but there are no other directories in /sys/bus/platform/devices/coretemp.0/hwmon/ so I can access values just with e.g. cat /sys/bus/platform/devices/coretemp.0/hwmon/*/temp1_input.

tobek
  • 388
  • 4
  • 11
  • Thanks for the response. I'm actually using conky's ${platform}, not ${hwmon}, like ${platform coretemp.0/hwmon/hwmon4 temp 1 1.8 32.0} – feuGene Nov 20 '20 at 06:50