What if we need to CPU core temperature on Linux machines. its quit important sometime for remote machine where we should monitor CPU core temperature constantly.
In various monitoring system, we always some parameter to make note of it and if it goes above critical threshold, we must need to inform Data Centre team to check reasons behind it.
But what for our daily machine like workstation and laptop which don’t have any monitoring mechanism in-place, here we need to know how we could identify CPU Core temperature.

In Linux/Unix machine, we have few package which used to identify Core temperature. Let’s take an example Ubuntu machine first.

Sensors Command

ssirohi@srv2:~$ apt-file search /usr/bin/sensors
lm-sensors: /usr/bin/sensors

Above command sensors used to find temperature of CPU Cores. we can install it on Ubuntu machine through below commands

installation of Sensors

 On Ubuntu machine
# sudo apt-get install lm-sensors

 On Redhat/CentOS machine
# yum install lm-sensors

Sensors command work like below.

ssirohi@srv2:~$ sensors
coretemp-isa-0000
Adapter: ISA adapter
Package id 0:  +31.0°C  (high = +86.0°C, crit = +100.0°C)
Core 0:        +29.0°C  (high = +86.0°C, crit = +100.0°C)
Core 1:        +30.0°C  (high = +86.0°C, crit = +100.0°C)
Core 2:        +30.0°C  (high = +86.0°C, crit = +100.0°C)
Core 3:        +28.0°C  (high = +86.0°C, crit = +100.0°C)
Core 4:        +31.0°C  (high = +86.0°C, crit = +100.0°C)
Core 5:        +28.0°C  (high = +86.0°C, crit = +100.0°C)
Core 6:        +30.0°C  (high = +86.0°C, crit = +100.0°C)
Core 7:        +28.0°C  (high = +86.0°C, crit = +100.0°C)

iwlwifi_1-virtual-0
Adapter: Virtual device
temp1:        +27.0°C  

acpitz-virtual-0
Adapter: Virtual device
temp1:        +27.8°C  (crit = +119.0°C)

dell_smm-virtual-0
Adapter: Virtual device
fan1:         871 RPM
fan2:         861 RPM
fan3:         789 RPM

pch_cannonlake-virtual-0
Adapter: Virtual device
temp1:        +45.0°C  

Like in above mentioned way, we can find out CPU core temperature in Linux/Unix Machine.

CPU core temperature through Python method

We can also know CPU core temperatures through simple python method like below.

ssirohi@srv2:~$ python
Python 3.7.4 (default, Aug 13 2019, 20:35:49) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil

>>> [i[0:2] for i in psutil.sensors_temperatures()['coretemp']]
[('Package id 0', 30.0), ('Core 0', 28.0), ('Core 1', 29.0), ('Core 2', 29.0), ('Core 3', 27.0), ('Core 4', 30.0), ('Core 5', 28.0), ('Core 6', 29.0), ('Core 7', 28.0)]

See in python this is module psutil which could help to know CPU Core temperature. we can install this module through pip command.

# pip install psutil