Last Updated: February 25, 2016
·
664
· imiric

Average CPU temperature

This is a one-liner to get the average CPU temperature using lm-sensors and Perl. Useful for status bars such as Dzen, commonly used in lightweight window managers.

sensors | perl -ne 'if (/^Core \d+:\s+\+(.*?)°C/) { $s += $1; $c++; } END { printf("%.1fC", $s/$c) }'

It averages the temperature readout for all available CPU cores.