From 277334ef45b5484a4559fb474e7e67f153bcef5a Mon Sep 17 00:00:00 2001 From: aristocratos Date: Wed, 29 Apr 2020 21:53:57 +0200 Subject: [PATCH 1/6] Fixed: Not showing CPU temperatures when "Package" temp is missing --- bashtop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bashtop b/bashtop index 0bc439a..918535a 100755 --- a/bashtop +++ b/bashtop @@ -1410,7 +1410,7 @@ collect_cpu_temps() { #? Collect cpu temperatures sens_var="$(sensors)" #* Get CPU package temp - if get_value -v 'cpu[temp_0]' -sv "sens_var" -k "Package*:" -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, crit and core temps 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 From e16403f3b2435da7468e20a36a5d3b056c6b38c9 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Thu, 30 Apr 2020 00:50:17 +0200 Subject: [PATCH 2/6] Added: CPU temperature support for AMD Ryzen --- bashtop | 84 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 63 insertions(+), 21 deletions(-) diff --git a/bashtop b/bashtop index 918535a..92d89ea 100755 --- a/bashtop +++ b/bashtop @@ -722,6 +722,8 @@ get_value() { #? Get a value from a file, variable or array by searching for a n shift done + found="" + if [[ -z $input ]]; then return 1; fi if [[ -z $line_nr && -z $key ]]; then line_nr=1; fi @@ -1404,28 +1406,71 @@ collect_cpu() { #? Collects cpu stats from /proc/stat and compares with previous } collect_cpu_temps() { #? Collect cpu temperatures - local unit i it c div threads=${cpu[threads]} sens_var + local unit c div threads=${cpu[threads]} sens_var i it ccd_value breaking core_value + local -a ccd_array core_array #* Fetch output from "sensors" command to a variable sens_var="$(sensors)" - #* Get CPU package temp + #* 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 successful get temperature unit, convert temp to integer and get high, crit and core temps + #* 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 if [[ -z ${cpu[temp_high]} ]]; then - get_value -v 'cpu[temp_high]' -sv "sens_var" -k "Package*high =" -m 2 -r "[^0-9.]" -b -i - get_value -v 'cpu[temp_crit]' -sv "sens_var" -k "Package*crit =" -m 2 -r "[^0-9.]" -b -i + 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 fi - for((i=0,it=1;i15)); then @@ -1434,11 +1479,6 @@ collect_cpu_temps() { #? Collect cpu temperatures cpu_temp_history+=("$(( (${cpu[temp_${i}]}-15)*100/(cpu[temp_high]-15) ))") fi done - - - #* If unsuccessful turn off temperature checking - else - check_temp="false" fi } @@ -2007,7 +2047,7 @@ draw_cpu() { #? Draw cpu and core graphs and print percentages if [[ $check_temp == true ]]; then for((i=0;i<=threads;i++)); do - create_mini_graph -o "cpu_temp_graph_$i" -w 5 -c color_temp_graph "cpu_temp_history_$i" + if [[ -n ${cpu[temp_${i}]} ]]; then create_mini_graph -o "cpu_temp_graph_$i" -w 5 -c color_temp_graph "cpu_temp_history_$i"; fi done fi ((resized++)) @@ -2023,8 +2063,10 @@ draw_cpu() { #? Draw cpu and core graphs and print percentages done if [[ $check_temp == true ]]; then for((i=0;i<=threads;i++)); do - declare -n temp_hist="cpu_temp_history_${i}[-1]" - create_mini_graph -w 5 -c color_temp_graph -add-value "cpu_temp_graph_$i" ${temp_hist} + if [[ -n ${cpu[temp_${i}]} ]]; then + declare -n temp_hist="cpu_temp_history_${i}[-1]" + create_mini_graph -w 5 -c color_temp_graph -add-value "cpu_temp_graph_$i" ${temp_hist} + fi done fi fi @@ -2067,7 +2109,7 @@ draw_cpu() { #? Draw cpu and core graphs and print percentages print -v cpu_out_var -m $((pt_line+y)) $pt_col -rs -fg $p_normal_color -jl 7 -t "$name" -fg ${theme[inactive_fg]} "⡀⡀⡀⡀⡀⡀⡀⡀⡀⡀" -l 10 -t "$meter"\ -fg $cpu_p_color -jr 4 -t "${cpu_usage[i]}" -fg $p_normal_color -t "%" - if [[ $check_temp == true ]]; then + if [[ $check_temp == true && -n ${cpu[temp_${i}]} ]]; then print -v cpu_out_var -fg ${theme[inactive_fg]} " ⡀⡀⡀⡀⡀" -l 7 -t " ${!temp_name}" -fg $temp_color -jr 4 -t ${cpu[temp_${i}]} -fg $p_normal_color -t ${cpu[temp_unit]} fi From c9e0fa53f4cdb59548d4441d64e53d50d7b9829e Mon Sep 17 00:00:00 2001 From: aristocratos Date: Thu, 30 Apr 2020 00:54:40 +0200 Subject: [PATCH 3/6] Change: Minimum size changed from 80x25 to 80x24 --- bashtop | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bashtop b/bashtop index 92d89ea..ed1053e 100755 --- a/bashtop +++ b/bashtop @@ -287,8 +287,8 @@ init_() { #? Collect needed information and set options before startig main loop unset 'proc[reverse]' fi - #* Wait for resize if terminal size is smaller then 80x25 - if (($tty_width<80 | $tty_height<25)); then resized; fi + #* Wait for resize if terminal size is smaller then 80x24 + if (($tty_width<80 | $tty_height<24)); then resized; fi #* Calculate sizes of boxes calc_sizes @@ -470,7 +470,7 @@ resized() { #? Get new terminal size if terminal is resized unset winches while ((++winches<5)); do read tty_height tty_width < <(stty size) - if (($tty_width<80 | $tty_height<25)); then + if (($tty_width<80 | $tty_height<24)); then size_error_msg winches=0 else @@ -488,7 +488,7 @@ size_error_msg() { #? Shows error message if terminal size is below 80x25 tput clear create_box -full -lc "#EE2020" -title "resize window" print -rs -m $((tty_height/2-1)) 2 -fg ${theme[title]} -c -l 11 "Current size: " -bg "#00" -fg dd2020 -d 1 -c "${tty_width}x${tty_height}" -rs - print -d 1 -fg ${theme[title]} -c -l 15 "Need to be atleast:" -bg "#00" -fg 30dd50 -d 1 -c "80x25" -rs + print -d 1 -fg ${theme[title]} -c -l 15 "Need to be atleast:" -bg "#00" -fg 30dd50 -d 1 -c "80x24" -rs while [[ $(stty size) == "$tty_height $tty_width" ]]; do sleep 0.2; done } From b307b8aba75fa97bb8c2a55ce9f5de543b006adf Mon Sep 17 00:00:00 2001 From: aristocratos Date: Thu, 30 Apr 2020 01:08:56 +0200 Subject: [PATCH 4/6] Fixed: High cpu usage on systems with a lot of mounted disks --- bashtop | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/bashtop b/bashtop index ed1053e..6ed960a 100755 --- a/bashtop +++ b/bashtop @@ -226,6 +226,12 @@ init_() { #? Collect needed information and set options before startig main loop proc[pid_len]=${#proc[pid_max]} if [[ ${proc[pid_len]} -lt 5 ]]; then proc[pid_len]=5; fi + #* Wait for resize if terminal size is smaller then 80x24 + if (($tty_width<80 | $tty_height<24)); then resized; fi + + #* Calculate sizes of boxes + calc_sizes + #* Call init for cpu data collection collect_cpu init @@ -287,13 +293,6 @@ init_() { #? Collect needed information and set options before startig main loop unset 'proc[reverse]' fi - #* Wait for resize if terminal size is smaller then 80x24 - if (($tty_width<80 | $tty_height<24)); then resized; fi - - #* Calculate sizes of boxes - calc_sizes - - #* Call init for processes data collection proc[selected]=0 proc[page]=1 @@ -1488,7 +1487,7 @@ collect_mem() { #? Collect memory information from "/proc/meminfo" if ((mem[counter]<5)); then return; fi mem[counter]=0 - local i tmp value array mem_info + local i tmp value array mem_info height=$((box[mem_height]-2)) local -a mem_array swap_array available=("mem") #* Get memory and swap information from "/proc/meminfo" and calculate percentages @@ -1543,10 +1542,9 @@ collect_mem() { #? Collect memory information from "/proc/meminfo" disks_free+=("$(floating_humanizer -s 1 -B ${line_array[3]})") disks_free_percent+=("$((100-${line_array[4]%'%'}))") + if ((${#disks_name[@]}>=height/2)); then break; fi done - - } collect_processes() { #? Collect process information and calculate accurate cpu usage From fcd09fae74d5ed6d4f11037f0fb9d170dcc8d206 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Thu, 30 Apr 2020 01:15:31 +0200 Subject: [PATCH 5/6] updated TODO --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c0c3e1e..848ecfa 100644 --- a/README.md +++ b/README.md @@ -190,7 +190,7 @@ Might finish off items out of order since I usually work on multiple at a time. - [x] Add options to change colors for text, graphs and meters. - [ ] Fix cross platform compatibility: Currently in testing, bashtop-psutil branch. -- [ ] Add support for showing AMD cpu temperatures. +- [x] Add support for showing AMD cpu temperatures. - [ ] Add option to show tree view of processes. - [ ] Add option to reset network download/upload totals. - [ ] Add option to turn of gradient in processes list. From 8c616e0e200381f1e88c9798ab7015ecd4b2019f Mon Sep 17 00:00:00 2001 From: aristocratos Date: Thu, 30 Apr 2020 01:16:11 +0200 Subject: [PATCH 6/6] v0.8.17 --- CHANGELOG.md | 9 ++++++++- bashtop | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71daa11..bd12d4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## v0.8.17 + +* Fixed: Not showing CPU temperatures when "Package" temp is missing +* Added: CPU temperature support for AMD Ryzen +* Changed: Minimum size changed from 80x25 to 80x24 +* Fixed: High cpu usage on systems with a lot of mounted disks + ## v0.8.16 * Added: Bash version check, by Calinou @@ -19,7 +26,7 @@ * Fixed: disks usage runaway array * Fixed: disks used not reporting new values -* Change: memory and disks update frequency increased +* Changed: memory and disks update frequency increased ## v0.8.13 diff --git a/bashtop b/bashtop index 6ed960a..320298c 100755 --- a/bashtop +++ b/bashtop @@ -64,7 +64,7 @@ banner=( "██╔══██╗██╔══██║╚════██║██╔══██║ ██║ ██║ ██║██╔═══╝ " "██████╔╝██║ ██║███████║██║ ██║ ██║ ╚██████╔╝██║ " "╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ") -declare version="0.8.16" +declare version="0.8.17" declare banner_width=${#banner[0]} banner_colors=("#E62525" "#CD2121" "#B31D1D" "#9A1919" "#801414")