cpu temperature measurement in Ubuntu

Post Reply
nikodemus
Posts: 25
Joined: Fri Mar 08, 2019 2:15 pm
languages_spoken: german, english
ODROIDs: C1, C2, XU4, N2
Has thanked: 3 times
Been thanked: 1 time
Contact:

cpu temperature measurement in Ubuntu

Unread post by nikodemus » Wed May 15, 2019 3:25 am

Someone has an idea why it takes 10 seconds for these commands

echo -n 'CPU Frequency: ' && sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
echo -n 'TEMP: ' && sudo cat /sys/devices/virtual/thermal/thermal_zone0/temp
echo -n 'TEMP: ' && sudo cat /sys/devices/virtual/thermal/thermal_zone1/temp

it looks a little that a timeout occurs
i have no issue with the command cpufreq-info, but currently i dont know a workaround for temperature
(though its not very urgent to have an eye on it, because the N2 definitely has no thermal problems :) )
# cpufreq-info -f && cpufreq-info -w && /usr/bin/cpufreq-info | grep 'current CPU freq'|head -n 3 | tail -n 2

OS version:
ubuntu-18.04.2-4.9-mate-odroid-n2-20190325
# uname -a
Linux odroid 4.9.170-25 #1 SMP PREEMPT Thu Apr 25 20:03:24 -03 2019 aarch64 aarch64 aarch64 GNU/Linux

thanks in advance

User avatar
tobetter
Posts: 4263
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Has thanked: 58 times
Been thanked: 234 times
Contact:

Re: cpu temperature measurement in Ubuntu

Unread post by tobetter » Wed May 15, 2019 11:47 am

nikodemus wrote:
Wed May 15, 2019 3:25 am
Someone has an idea why it takes 10 seconds for these commands

echo -n 'CPU Frequency: ' && sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
echo -n 'TEMP: ' && sudo cat /sys/devices/virtual/thermal/thermal_zone0/temp
echo -n 'TEMP: ' && sudo cat /sys/devices/virtual/thermal/thermal_zone1/temp

it looks a little that a timeout occurs
i have no issue with the command cpufreq-info, but currently i dont know a workaround for temperature
(though its not very urgent to have an eye on it, because the N2 definitely has no thermal problems :) )
# cpufreq-info -f && cpufreq-info -w && /usr/bin/cpufreq-info | grep 'current CPU freq'|head -n 3 | tail -n 2

OS version:
ubuntu-18.04.2-4.9-mate-odroid-n2-20190325
# uname -a
Linux odroid 4.9.170-25 #1 SMP PREEMPT Thu Apr 25 20:03:24 -03 2019 aarch64 aarch64 aarch64 GNU/Linux

thanks in advance
Have you try to run the 'cat' command to read the temp directly? Does it take long?

nikodemus
Posts: 25
Joined: Fri Mar 08, 2019 2:15 pm
languages_spoken: german, english
ODROIDs: C1, C2, XU4, N2
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: cpu temperature measurement in Ubuntu

Unread post by nikodemus » Thu May 16, 2019 12:16 am

Thank you for answering.
I must admit everything works as expected after a reboot (tested with Ubuntu and Debian stretch) 8-) .

Sometimes it helps to keep things simple.

nikodemus
Posts: 25
Joined: Fri Mar 08, 2019 2:15 pm
languages_spoken: german, english
ODROIDs: C1, C2, XU4, N2
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: cpu temperature measurement in Ubuntu

Unread post by nikodemus » Thu May 16, 2019 9:21 am

to finish this topic:
here is my current comand line to monitor temperatures and system activity, some might find it useful

Code: Select all

while true ; do 
clear; 
mydelay=2;
echo -n 'Hostname: ' && hostname && echo -n 'governor: ';
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor;
echo -n 'CPU Frequency: ' && sudo echo $(sudo cat /sys/devices/system/cpu/cpu[0-5]/cpufreq/cpuinfo_cur_freq);
paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) | column -s $'\t' -t | sed 's/\(.\)..$/.\1°C/';
echo ""; echo free; free -h; 
echo "" ; echo dstat; echo "--total-cpu-usage-- -dsk/total- -net/total- ---paging-- ---syste--"; echo "usrSysIdlWaiStl|read  writ| recv  send|  in   out | int   csw"; 
echo $a0; echo $a1; echo $a2; 
#a0=$a1; a1=$a2; a2=$(dstat -a --nocolor 1 2| sed '1,3d'); 
a0=$a1; a1=$a2; a2=$(dstat -a --nocolor mydelay=3; 2); a2=$(sed '1,3d'<<<$a2);
sleep .1;
done


to have it on one line:

Code: Select all

mydelay=3;while true ; do clear; echo -n 'Hostname: ' && hostname && echo -n 'governor: '; cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor; echo -n 'CPU Frequency: ' && sudo echo $(sudo cat /sys/devices/system/cpu/cpu[0-5]/cpufreq/cpuinfo_cur_freq); paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) | column -s $'\t' -t | sed 's/\(.\)..$/.\1°C/'; echo ""; echo free; free -h; echo "" ; echo dstat; echo "--total-cpu-usage-- -dsk/total- -net/total- ---paging-- ---system--"; echo "usrSysIdlWaiStl|read  writ| recv  send|  in   out | int   csw"; echo $a0; echo $a1; echo $a2; a0=$a1; a1=$a2; a2=$(dstat -a --nocolor $mydelay 2); a2=$(sed '1,3d'<<<$a2); sleep .1; done 
one additional word to the tool dstat:
- in most ubuntu versions it should already be present, if not install with sudo apt install dstat.
- dstats main purpose is to watch current disk transfer speed, midnight commander is not recommended for measurements, because of its low copy speed

Post Reply

Return to “Issues”

Who is online

Users browsing this forum: No registered users and 0 guests