temptest (910B)
1 #!/bin/sh 2 # requirements: stress 3 4 get_ncpu() { 5 if [ "$(uname)" = OpenBSD ]; then 6 sysctl -n hw.ncpufound 7 else 8 grep 'cpu cores' /proc/cpuinfo | awk 'END{print $4}' 9 fi 10 } 11 12 get_temp() { 13 if [ "$(uname)" = OpenBSD ]; then 14 sysctl -n hw.sensors.cpu0.temp0 15 else 16 printf '%d/1000\n' "$(cat /sys/class/hwmon/hwmon1/temp1_input)" | bc -l 17 fi 18 } 19 20 get_speed() { 21 if [ "$(uname)" = OpenBSD ]; then 22 sysctl -n hw.cpuspeed 23 else 24 awk ' 25 /cpu MHz/ { avg += $4; n++ } 26 END { print avg/n }' /proc/cpuinfo 27 fi 28 } 29 30 show_temp() { 31 load="$(uptime | sed 's/.*: //')" 32 temp="$(get_temp)" 33 cpuspeed="$(get_speed)" 34 printf '%s\t%.4s C\t%s MHz\n' "$load" "$temp" "$cpuspeed" 35 } 36 37 n_cores="$(get_ncpu)" 38 if [ "$n_cores" -gt 1 ]; then 39 label="cpus" 40 else 41 label="cpu" 42 fi 43 44 printf 'stressing %s %s...\n' "$n_cores" "$label" 45 i=1 46 while [ $i -le 5 ]; do 47 show_temp 48 stress -c "$n_cores" -t 120s >/dev/null 49 i=$(( i + 1 )) 50 done 51 show_temp