Last active
October 8, 2019 02:10
-
-
Save p3x-robot/bd120764afce706f822b9b93098c5df8 to your computer and use it in GitHub Desktop.
🌡️LINUX, it shows your temperature and the CPU speed (I use Debian and Ubuntu).
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 | |
# Debian | |
# sudo apt install lm-sensors bc linux-cpupower | |
# Ubuntu | |
# probably is https://packages.ubuntu.com/search?suite=xenial§ion=all&arch=any&keywords=cpupower&searchon=contents | |
# but you might to have a specific kernel linux-tools-common | |
# sudo apt install lm-sensors bc linux-tools-common | |
# Then you go this: | |
# sudo sensors-detect | |
# It will ask you few questions. Answer default (just ENTER) for all of them. Finally to get your CPU temperature type sensors in your terminal | |
# Enable some services | |
# sudo systemctl enable kmod. | |
# sudo service kmod start | |
if [[ $EUID -ne 0 ]]; then | |
printf "You are not root!\n\n" | |
exit 1 | |
fi | |
sensors | |
function show_temp { | |
echo $1 $(($2/1000))°C | |
} | |
function tempfunction { | |
# THERMAL=/sys/class/thermal | |
# for entry in `ls $THERMAL`; do | |
# class=$THERMAL/$entry/temp | |
# if [ -f $class ]; then | |
# temp=$(< $class) | |
# show_temp $class $temp | |
# fi | |
# done | |
# for entry in `find /sys/devices/virtual/thermal -iname '*temp*' ! -iname "*emul*" `; do | |
# temp=$(< $entry ) | |
# show_temp $entry $temp | |
# done | |
sensors | |
cpupower frequency-info | grep -i "mhz\|ghz" | |
echo | |
scaling_cur_freq=`cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq` | |
cpu_core=1 | |
for freq in $scaling_cur_freq; do | |
freq_in_ghz=$(echo "scale=2; $freq/1000" | bc) | |
echo "CPU/Thread $cpu_core: $freq_in_ghz Mhz" | |
let cpu_core=${cpu_core}+1 | |
done | |
# watch -n1 cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq | |
#cat /proc/cpuinfo | grep 'MHz' | |
} | |
export -f tempfunction | |
export -f show_temp | |
watch -n 1 --exec bash -c "tempfunction" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Linux Mint - Ubuntu (i7 3770k, 32GB RAM DDR3 at 2133Mhz) - my workstation:
