Added: Support for Raspberry Pi cpu temp reporting

pull/102/head
aristocratos 2020-05-03 15:07:35 +02:00
parent 89253debe8
commit d4933fd26a
1 changed files with 16 additions and 2 deletions

18
bashtop
View File

@ -1450,7 +1450,7 @@ collect_cpu_temps() { #? Collect cpu temperatures
#* Get CPU package temp for intel cpus #* Get CPU package temp for intel cpus
if get_value -v 'cpu[temp_0]' -sv "sens_var" -k "Package*:" -mk 1 || get_value -v 'cpu[temp_0]' -sv "sens_var" -k "Core 0:" -mk 1; then if get_value -v 'cpu[temp_0]' -sv "sens_var" -k "Package*:" -mk 1 || get_value -v 'cpu[temp_0]' -sv "sens_var" -k "Core 0:" -mk 1; then
#* If successful get temperature unit, convert temp to integer and get high and crit #* If successful get temperature unit, convert temp to integer and get high and crit
cpu[temp_unit]=${cpu[temp_0]:(-2)}; cpu[temp_0]=${cpu[temp_0]%.*}; if [[ ${cpu[temp_0]::1} == "+" ]]; then cpu[temp_0]=${cpu[temp_0]#+}; fi cpu[temp_unit]="${cpu[temp_0]:(-2)}"; cpu[temp_0]="${cpu[temp_0]%.*}"; if [[ ${cpu[temp_0]::1} == "+" ]]; then cpu[temp_0]="${cpu[temp_0]#+}"; fi
if [[ -z ${cpu[temp_high]} ]]; then if [[ -z ${cpu[temp_high]} ]]; then
if ! get_value -v 'cpu[temp_high]' -sv "sens_var" -k "Package*high =" -m 2 -r "[^0-9.]" -b -i; then cpu[temp_high]="85"; cpu[temp_crit]=$((cpu[temp_high]+10)) if ! get_value -v 'cpu[temp_high]' -sv "sens_var" -k "Package*high =" -m 2 -r "[^0-9.]" -b -i; then cpu[temp_high]="85"; cpu[temp_crit]=$((cpu[temp_high]+10))
else get_value -v 'cpu[temp_crit]' -sv "sens_var" -k "Package*crit =" -m 2 -r "[^0-9.]" -b -i; fi else get_value -v 'cpu[temp_crit]' -sv "sens_var" -k "Package*crit =" -m 2 -r "[^0-9.]" -b -i; fi
@ -1479,7 +1479,7 @@ collect_cpu_temps() { #? Collect cpu temperatures
#* Get CPU package temp for amd ryzen cpus #* Get CPU package temp for amd ryzen cpus
elif get_value -v 'cpu[temp_0]' -sv "sens_var" -k "Tdie:" -mk 1; then elif get_value -v 'cpu[temp_0]' -sv "sens_var" -k "Tdie:" -mk 1; then
#* If successful get temperature unit, convert temp to integer and get high #* If successful get temperature unit, convert temp to integer and get high
cpu[temp_unit]=${cpu[temp_0]:(-2)}; cpu[temp_0]=${cpu[temp_0]%.*}; if [[ ${cpu[temp_0]::1} == "+" ]]; then cpu[temp_0]=${cpu[temp_0]#+}; fi cpu[temp_unit]="${cpu[temp_0]:(-2)}"; cpu[temp_0]="${cpu[temp_0]%.*}"; if [[ ${cpu[temp_0]::1} == "+" ]]; then cpu[temp_0]="${cpu[temp_0]#+}"; fi
if [[ -z ${cpu[temp_high]} ]]; then if [[ -z ${cpu[temp_high]} ]]; then
if ! get_value -v 'cpu[temp_high]' -sv "sens_var" -k "Tdie*high =" -m 2 -r "[^0-9.]" -b -i; then cpu[temp_high]="85"; fi if ! get_value -v 'cpu[temp_high]' -sv "sens_var" -k "Tdie*high =" -m 2 -r "[^0-9.]" -b -i; then cpu[temp_high]="85"; fi
cpu[temp_crit]=$((cpu[temp_high]+10)) cpu[temp_crit]=$((cpu[temp_high]+10))
@ -1500,6 +1500,20 @@ collect_cpu_temps() { #? Collect cpu temperatures
z=$((z+i)) z=$((z+i))
done done
#* Get CPU package temp for Rapberry Pi cpus
elif command -v vcgencmd >/dev/null 2>&1; then
cpu[temp_0]="$(vcgencmd measure_temp 2>/dev/null ||true)"
if [[ -z ${cpu[temp_0]} ]]; then cpu[temp_0]="temp=0.0°C"; fi
cpu[temp_0]="${cpu[temp_0]#temp=}"
cpu[temp_unit]="°${cpu[temp_0]:(-1)}"; cpu[temp_0]=${cpu[temp_0]%.*}; if [[ ${cpu[temp_0]::1} == "+" ]]; then cpu[temp_0]=${cpu[temp_0]#+}; fi
cpu[temp_high]="75"; cpu[temp_crit]=$((cpu[temp_high]+10))
#* Copy cpu temp to cores
for((i=1;i<=threads;i++)); do
cpu[temp_${i}]="${cpu[temp_0]}"
done
#* If unsuccessful turn off temperature checking #* If unsuccessful turn off temperature checking
else else
check_temp="false" check_temp="false"