Search code examples
c++fileubuntuinterfacehealth-monitoring

How to find a file containing CPU temperature and fan speed information in all Linux distros at same location?


I am working on a project where I have to get CPU temperature (including cores) and fans speed.

For my PC, I have used /sys/class/hwmon/hwmon2/temp*_input for the CPU and /sys/class/hwmon/hwmon3/device/fan*_input for the fans speed.

My code does not works on some other PCs. First, the OS is Ubuntu 18.04 and the second is 16.04. I would like to find an universal path from where I can get all the necessary information. Is there anything like it that I can use?


Solution

  • It can be read from /sysfs interface, both from /sys/clsss/thermal or /sys/class/hwmon.

    go through below link for more detail:

    https://www.lookup2learn.com/post/thermal-management-in-linux