From b307b8aba75fa97bb8c2a55ce9f5de543b006adf Mon Sep 17 00:00:00 2001 From: aristocratos Date: Thu, 30 Apr 2020 01:08:56 +0200 Subject: [PATCH] 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