Skip to content

Instantly share code, notes, and snippets.

@Hermann-SW
Last active January 10, 2026 15:57
Show Gist options
  • Select an option

  • Save Hermann-SW/0c3690624375295ddfac919295169222 to your computer and use it in GitHub Desktop.

Select an option

Save Hermann-SW/0c3690624375295ddfac919295169222 to your computer and use it in GitHub Desktop.
Determine temerature statistics for sockets and cores
#!/bin/bash
nsockets=$(grep "physical id" /proc/cpuinfo | sort -u | wc -l)
for((i=0; i<nsockets; ++i))
do
coretemp=$(sensors -A | sed -n "/^coretemp-isa-000$i/,/^$/p")
echo "$coretemp" | grep "Package" | sort
high=$(echo "$coretemp" | grep "Core" | cut -b17- | grep high | sort -n)
ts=$(
(
echo "$high" | sort -n | head -1
echo "$high" | sort -n | \
awk '{ total += $1; count++ } END { printf("%.2f°C\n", total/count) }'
echo "$high" | sort -n | tail -1
) | ( cut -f1 -d\ )
)
echo -n $ts # double quoting as shellcheck suggests would break formatting
echo -e "\t(min/avg/max of $(echo "$coretemp" | grep -c "Core")"" cores)"
done
@Hermann-SW
Copy link
Author

Hermann-SW commented Jan 10, 2026

Sample output for 192C/384T 8-socket server running numactl -C 0-191 gp -q ...

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND  
  23038 hermann   20   0   30.1g   1.3g   8472 S 19202   0.1    4d+13h gp       

... for 4d+13h / 192 = 34min:
(packages 2 and 3 being worse temperature wise even after repair is a known issue)

hermann@x3950-X6:~$ coretemps
Package id 0:  +63.0°C  (high = +87.0°C, crit = +97.0°C)
54.0°C 59.42°C 62.0°C	(min/avg/max of 24 cores)
Package id 1:  +62.0°C  (high = +87.0°C, crit = +97.0°C)
56.0°C 60.04°C 63.0°C	(min/avg/max of 24 cores)
Package id 2:  +71.0°C  (high = +87.0°C, crit = +97.0°C)
64.0°C 68.08°C 71.0°C	(min/avg/max of 24 cores)
Package id 3:  +67.0°C  (high = +87.0°C, crit = +97.0°C)
58.0°C 62.83°C 67.0°C	(min/avg/max of 24 cores)
Package id 4:  +63.0°C  (high = +87.0°C, crit = +97.0°C)
56.0°C 60.29°C 63.0°C	(min/avg/max of 24 cores)
Package id 5:  +65.0°C  (high = +87.0°C, crit = +97.0°C)
59.0°C 61.75°C 65.0°C	(min/avg/max of 24 cores)
Package id 6:  +61.0°C  (high = +87.0°C, crit = +97.0°C)
56.0°C 58.92°C 61.0°C	(min/avg/max of 24 cores)
Package id 7:  +62.0°C  (high = +87.0°C, crit = +97.0°C)
56.0°C 59.58°C 62.0°C	(min/avg/max of 24 cores)
hermann@x3950-X6:~$ 

P.S:
For completeness, the PARI/GP computation done:

hermann@x3950-X6:~$ numactl -C 0-191 gp -q
? 1 + parsum(k=10^10\5+1,2*10^10\5-1, \
 isprime((5*k+0)^2+(5*k+1)^2) \
+isprime((5*k+2)^2+(5*k+3)^2) \
+isprime((5*k+4)^2+(5*k+5)^2) )
577842490
? ##
  ***   last result: cpu time 190h, 49min, 37,645 ms, real time 59min, 46,852 ms.
? 

@Hermann-SW
Copy link
Author

Script does not work on single socket machines.
Just installed lm-sensors on another 2-socket server:
https://www.cyberciti.biz/faq/install-sensors-lm-sensors-on-ubuntu-debian-linux/

coretemps just works, temperatures and correct core count per package:

hermann@E5-2680v4:~$ coretemps 
Package id 0:  +42.0°C  (high = +90.0°C, crit = +100.0°C)
35.0°C 35.79°C 38.0°C	(min/avg/max of 14 cores)
Package id 1:  +39.0°C  (high = +90.0°C, crit = +100.0°C)
33.0°C 34.29°C 35.0°C	(min/avg/max of 14 cores)
hermann@E5-2680v4:~$ 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment