-1

I have set up a dollar sign as shell prompt that shows the CPU temperature from sysfs sensor files in a color scale. In temperature-colored-bash-prompt- I put two screen shots. But the problem does not seem to be the prompt - the prompt only makes the (very) short peak visible in a drastic way.

I watched the temperature in one xterm with watch and did different commands in another.

With ls -R /usr xterm shows up in top for 2 seconds (15%) and the temperature sensors react very nervous - so far so good.

With ls -R /usr >/dev/null I get no reaction in top, the temperature can peak on one or more of the sensors shortly, and the colored prompt just reflects that.

I can get a green prompt three times in a row after ls -R /usr >/dev/null, and then suddenly: hot pink for more than a second i.e. several quick enter taps. Same with find.

Do these short and very short peaks in sensor readings reflect any reality? How can a core go from 45 to 70 and back in one second (watch) or shorter (prompt color)?

This is how it looks: the last part is the typical case: from green to red and back in two quick enter taps. Yesterday it was more getting stuck on magenta for a short while. Same effect on console.

enter image description here

The prompt:

PS1='$(systemp-color)$  \e[m'

and the function converting temperature to color sequence:

systemp-color() { 
t=$(</sys/class/hwmon/hwmon2/temp1_input)
case $t in
        3?000 )      c='1;34';;
        4[012]000 )     c=36;; 
        4[345]000 )     c=32;; 
        4[6789]000 )   c='33';; 
        5?000 )        c='31';; 
        6?000 )      c='1;35';; 
        * )            c='30';; 
esac

echo -ne "\e[${c}m"
}

Here the sensors:

$  cd /sys/class/hwmon/hwmon2/
$  grep "" temp?_label
temp1_label:Package id 0
temp2_label:Core 0
temp3_label:Core 1
temp4_label:Core 2
temp5_label:Core 3
$  grep "" temp?_input
temp1_input:43000
temp2_input:42000
temp3_input:42000
temp4_input:42000
temp5_input:41000
  • Without "watch" running I get more false alarms - like yesterday. At least one consistency. How can I find out what is happening when my diagnostical tool affects the behaviour??? –  Sep 17 '19 at 13:30

1 Answers1

1

Your CPU will be taken out of idle state; given more voltage, and more Hz when a threshold is passed. Because you are not using a real time operating system all kinds of stuff in the background may occasionally combine with whatever you are running in the foreground to pass this threshold.

lscpu | grep MHz

See

How to change the length of time-slices used by the Linux CPU scheduler?

and

https://askubuntu.com/questions/218567/any-way-to-check-the-clock-speed-of-my-processor/218570

user1133275
  • 5,574
  • This is only general info. It does not explain my observations. –  Sep 17 '19 at 13:25
  • 5
    @S.P. Your observations are not detailed enough to be explained other than generally, Use iotop, iftop, htop/top and/or other tools to check what is actually going on. – user1133275 Sep 17 '19 at 17:15
  • I mention "top" twice, and I "watch" the sensors. –  Sep 18 '19 at 08:20