Skip to content

Commit

Permalink
v6.25
Browse files Browse the repository at this point in the history
+ DietPi-Globals | G_OBTAIN_CPU_TEMP(): Add support for Core2Duo CPUs and make $print_full_info input failsafe.
  • Loading branch information
MichaIng authored May 21, 2019
1 parent 75c5daa commit 662ff28
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions dietpi/func/dietpi-globals
Original file line number Diff line number Diff line change
Expand Up @@ -1826,11 +1826,11 @@ $print_logfile_info
}

# Returns current CPU temp 'C
# print_full_info=1# optional input to print full colour text output and temp warnings.
# print_full_info=1 # optional input to print full colour text output and temp warnings.
G_OBTAIN_CPU_TEMP(){

local cpu_temp_current='N/A' # We must always return a value, due to VM lacking this feature + benchmark online
local print_full_info=${print_full_info:-0}
[[ $print_full_info == [01] ]] || local print_full_info=0

# Read CPU temp from file
# - Sparky/Asus: Requires special case as in others array this would break other SBC temp readouts with 2 zones
Expand All @@ -1847,6 +1847,7 @@ $print_logfile_info
'/sys/class/thermal/thermal_zone0/temp'
'/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/temp1_input'
'/sys/class/hwmon/hwmon0/device/temp_label'
'/sys/class/hwmon/hwmon0/temp2_input'

)

Expand Down Expand Up @@ -1916,12 +1917,12 @@ $print_logfile_info
ps -axo %cpu | sed '1d' | sed 's/ //' > $fp_temp
while read line; do

cpu_usage=$( echo "scale=1;$cpu_usage + $line" | bc -l )
cpu_usage=$(echo "scale=1;$cpu_usage + $line" | bc -l)

done < "$fp_temp"

# - ps returns usage of each core, so we devide the total by #n cores
cpu_usage=$(echo "scale=1;$cpu_usage / $G_HW_CPU_CORES" | bc -l )
cpu_usage=$(echo "scale=1;$cpu_usage / $G_HW_CPU_CORES" | bc -l)

echo $cpu_usage

Expand Down

0 comments on commit 662ff28

Please sign in to comment.