Last active
January 10, 2026 15:57
-
-
Save Hermann-SW/0c3690624375295ddfac919295169222 to your computer and use it in GitHub Desktop.
Determine temerature statistics for sockets and cores
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: