ministo

A tmux status bar and scripts for CPU miners.
git clone git://git.swab.dev/ministo.git
Log | Files | Refs | README | LICENSE

getAverageCpuTemp.sh (536B)


      1 #!/bin/sh
      2 
      3 hasCoreTemp=$(sensors | grep 'coretemp')
      4 if [ ! "$hasCoreTemp" = "" ]; then
      5 	cpus=$(sensors | awk '/Core/ { print $3 }' | sed 's/\+//' | sed 's/°C//')
      6 
      7 	n=0
      8 	i=0
      9 	sum=0
     10 
     11 	for _ in $cpus; do
     12 		n=$((n+1))
     13 	done
     14 
     15 	while [ $i -le $n ]; do
     16 		i=$((i+1))
     17 	done
     18 
     19 	for num in $cpus; do
     20 		sum=$(echo "$sum" + "$num" | bc -l)
     21 	done
     22 
     23 	avgTemp="$(echo "$sum" / "$n" | bc -l)"
     24 	printf '%0.1f°C' "$avgTemp"
     25 	exit 0;
     26 fi
     27 
     28 ## Some AMD Ryzen CPUs report CPU tempurature with "Tdie" in `sensors`
     29 sensors | awk '/Tdie:/ { print $2}' && exit 0;