Linux CLI: fail-proof way to check temperature

6

3

I usually use one of the following to check temperature of Linux-based computers:

$ cat /proc/acpi/thermal_zone/THM/temperature
$ acpi -V
$ sensors

However, on the current system I am using (Debian derived distro) the first one doesn't exist and the second does not show the temperature. The third one only worked after convincing the server admin to install lm_sensors. Is there another way to check in the event that for whatever reason a server admin would deny my request to install lm_sensors? From where does lm_sensors get the temp?

Thanks.

dotancohen

Posted 2012-06-13T10:54:17.723

Reputation: 9 798

Answers

4

For reading out temperatures and voltages there is also the Linux hwmon API which has a sysfs interface:

$ ls -l /sys/class/hwmon/
total 0
lrwxrwxrwx 1 root root 0 Jun 30 00:05 hwmon0 -> ../../devices/virtual/hwmon/hwmon0
lrwxrwxrwx 1 root root 0 Jun 30 00:05 hwmon1 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/hwmon/hwmon1
lrwxrwxrwx 1 root root 0 Jun 30 00:05 hwmon2 -> ../../devices/platform/coretemp.0/hwmon/hwmon2
lrwxrwxrwx 1 root root 0 Jun 30 00:05 hwmon3 -> ../../devices/platform/nct6775.2560/hwmon/hwmon3

$ cat /sys/class/hwmon/hwmon2/temp1_input 
43000

AFAIK sensors uses this interface (maybe among others).

dasup

Posted 2012-06-13T10:54:17.723

Reputation: 206

1Thank you very much. I did +1 for the information, but neither of my systems have temp1_input in the hwmon3 directories. I seem to have only device/, power/, subsystem/, uevent. Note that these are hardware-installed machines, not virtual machines. – dotancohen – 2014-06-30T05:40:58.877

What is the name of the directory hwmon3 points to on your system? The examples I posted were taken from a real, non-virtualized system (Core i5 processor, MSI H81M-E34 mainboard). – dasup – 2014-07-01T20:16:56.423

hwmon0 -> ../../devices/pci0000:00/0000:00:18.3/hwmon/hwmon0 This also is a real, non-virtualized system (MD A4-5300). – dotancohen – 2014-07-02T11:56:32.480

3

A thermometer... (No joke) I would suggest a surface mounted thermocouple if your server admin will deny your request (as long as you have physical access to the machine).

I use an Omega SA1XL.

I hesitated to post this because I realize you are asking for a software solution, but I must say it works quite well. Note that depending on where you place the thermocouple, the absolute readings that you get may vary from what any software solution might give you, but the relative readings (relative to room temperature or normal use) will be most useful.

jds

Posted 2012-06-13T10:54:17.723

Reputation: 632

but no software monitoring when you're on holidays :( – Felipe Alvarez – 2014-12-24T04:04:58.617

@FelipeAlvarez I’m sure you could connect it to a smart thing to get that remote monitoring ;-) – binki – 2018-07-30T14:16:23.300

1Ah, yes, a hacker solution! – dotancohen – 2012-06-13T14:01:58.143

2

On my linux mint debian, this gives me the temperature of my two CPUs:

cat /sys/devices/platform/coretemp.0/temp?_input

If you can convince your sysadmin to load a module, this should let you use sensors (as root):

modprobe coretemp
sensors

terdon

Posted 2012-06-13T10:54:17.723

Reputation: 45 216

@dotancohen: It looks like sensors abstracts from the different APIs for you. If using sensors is not an option, why not look into its source code to find out what it is doing and recreate the essential parts using e.g. a shell script? – dasup – 2014-07-01T23:07:48.797

@dasup: Yes, it looks like that is what I will have to do. I'll see if I can keep a binary of sensors around to run from my personal ~/bin/ as well. – dotancohen – 2014-07-02T11:55:09.090

Interesting, my Ubuntu 11.10 machine lacks /sys/devices/platform/coretemp.0. Thanks. – dotancohen – 2012-08-10T10:28:37.730

If memory serves, ubuntu should have this info at /proc/acpi/thermal_zone/THM0/temperature (THM1, THM2 etc for other cores). – terdon – 2012-08-10T12:38:40.860

1Ubuntu does have that, I mention that in the OP. But not all systems have that, hence this thread! In fact, my current desktop Ubuntu doesn't have that either, but the same version on a laptop does. – dotancohen – 2012-08-10T13:03:09.237

Yeah, I know. After posting my comment, I logged on to an Ubuntu 10.04.3 machine and can't find it either. Have a look at this post, might be helpful: link

– terdon – 2012-08-10T13:21:35.060

1The link is broken, but I was able to figure it out. But yes, the issue seems to be that the temperature information could be anywhere, but there is no specific somewhere where it always resides. From where do applications such as lm-sensors poll the info? – dotancohen – 2012-08-10T14:31:20.357

@dotancohen Sorry, this should work : link

– terdon – 2012-08-10T14:57:59.920