CPU temperature monitoring

versatile 64-bit multi-user Linux distribution

Moderators: kirk, jamesbond, p310don, JakeSFR, step, Forum moderators

Post Reply
Feek
Posts: 398
Joined: Sun Oct 18, 2020 8:48 am
Location: cze
Has thanked: 54 times
Been thanked: 90 times

CPU temperature monitoring

Post by Feek »

So far I have entered „sensors“ into the terminal from time to time.

Now I found out that pmcputemp is already included in Fatdog.
It doesn´t appear in the tray automatically.
I can launch it only via terminal (I created a simple script in /root/startup with text: <urxvt -e & pmcputemp> and it works).

The temperature values displayed simultaneously by pmcputemp in the tray and the „sensors“ in terminal seem to be different.
Which one is closer to reality?

User avatar
JakeSFR
Posts: 277
Joined: Wed Jul 15, 2020 2:23 pm
Been thanked: 159 times

Re: CPU temperature monitoring

Post by JakeSFR »

I don't use pmcputemp, because there's already:

Right-click the LxQt-panel -> Manage Widgets -> + -> Sensors

It supports multiple sensor readings, through libsensors, just like the sensors command.

Greetings!

[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Feek
Posts: 398
Joined: Sun Oct 18, 2020 8:48 am
Location: cze
Has thanked: 54 times
Been thanked: 90 times

Re: CPU temperature monitoring

Post by Feek »

@JakeSFR ,

I didn't know about this.

Very nice :thumbup2: ! Thank you.

I also don't use pmcputemp from today :) .

user1111

Re: CPU temperature monitoring

Post by user1111 »

This is a extract of the code I use to show a temperature icon in the tray of my bespoke containers. Generates its own .svg icon. Updates every 5 seconds (sleep 5 in _temp() function)

Code: Select all

#!/bin/bash

# Requires 'sit' to have been installed (from gslapt/repo) as that is used
# to stuff the temperature icon into the tray

REDTHRESHOLD=66 # CPU temperature at which icon colour turns red

_tempsvg() {                                               # cpu temperature .svg

        cat <<EOF >/tmp/.temperature.svg
<svg height='32' width='32' viewBox='0 0 16 16'>
 <radialGradient id='rg' fx='50%' fy='50%' cx='50%' cy='50%' r='50%'>
   <stop offset='80%' stop-color='white' stop-opacity='1'/>
   <stop offset='100%' stop-color='$2' stop-opacity='1' />
 </radialGradient>
<rect width='14' height='13' x='1' y='1' rx='2' ry='3' fill='url(#rg)'/>
<g font-size='8' font-style='normal' font-variant='normal' font-weight='bold'
font-stretch='normal' text-align='center' line-height='125%' letter-spacing='0'
word-spacing='0' text-anchor='middle' fill='$3' fill-opacity='1' stroke='none'
font-family='sans' dominant-baseline='central'>
<text x='52%' dy='11'>$1</text>
</g>
</svg>
EOF
}


_find_func() {      # find function for Locate where to read cpu temperature from
        FILES="$1"
        for n in `echo $FILES`; do
            read p < $n
            if [ $? = 0 ];then
                FILE=$n                                                # found it
                break
            else
                continue                              # didn't find, search again
            fi
        done
                                  # if we get here we didn't find anything useful
}
                                    # Scan for where to read cpu temperature from
for a in `find /sys/devices/platform -type f -name 'temp*_input'|sort` \
			`find /sys/devices/pci* -type f -name 'temp*_input'|sort` \
			`find /sys/devices/virtual -type f -name 'temp'|sort`
do _find_func "$a"
        [ -z "$FILE" ] && continue || break              # if we found data break
done
CPU_TEMP=$FILE
###

_temp() { # Tray icon for cpu temperature

        if [ -f $CPU_TEMP ]; then
            last=55
            _tempsvg 55 cyan black
            sit /tmp/.temperature.svg "cpu temperature" &
            PIDsittemp=$!
            while :; do
                x=$(cat $CPU_TEMP)
                x=$((x/1000))
                if [ $x -ne $last ];then
                    last=$x
                    [[ $x -ge $REDTHRESHOLD ]] && colour=red || colour=cyan
                    [[ $colour = "red" ]] && textcolour=red || textcolour=black
                    _tempsvg $x $colour $textcolour
                fi
                sleep 5
            done
        else
			Xdialog --msgbox "cpu temperature not found" 0 0
		fi
}

_temp
Post Reply

Return to “FatDog64”