From eb88e50dfc17716d87fb0986847a91a86baa1993 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Sat, 2 May 2020 20:28:24 +0200 Subject: [PATCH 01/30] Added tree sorting option to show tree structure for processes --- bashtop | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/bashtop b/bashtop index 156549d..58e5518 100755 --- a/bashtop +++ b/bashtop @@ -79,7 +79,7 @@ color_theme="Default" #* Update time in milliseconds, increases automatically if set below internal loops processing time, recommended 2000 ms or above for better sample times for graphs update_ms="2500" -#* Processes sorting, "pid" "program" "arguments" "threads" "user" "memory" "cpu lazy" "cpu responsive" +#* Processes sorting, "pid" "program" "arguments" "threads" "user" "memory" "cpu lazy" "cpu responsive" "tree" #* "cpu lazy" updates sorting over time, "cpu responsive" updates sorting directly at a cpu usage cost proc_sorting="cpu lazy" @@ -145,7 +145,7 @@ declare resized=1 size_error clock tty_width tty_height hex="16#" cpu_p_box swap declare -a options_array=("color_theme" "update_ms" "proc_sorting" "check_temp" "draw_clock" "background_update" "custom_cpu_name" "proc_reversed" "proc_gradient" "disks_filter" "net_totals_reset" "error_logging") declare -a save_array=(${options_array[*]/net_totals_reset/}) -declare -a sorting=( "pid" "program" "arguments" "threads" "user" "memory" "cpu lazy" "cpu responsive" ) +declare -a sorting=( "pid" "program" "arguments" "threads" "user" "memory" "cpu lazy" "cpu responsive" "tree" ) declare -a pid_history detail_graph detail_history detail_mem_history declare time_left timestamp_start timestamp_end timestamp_input_start timestamp_input_end time_string mem_out proc_misc prev_screen pause_screen filter input_to_filter declare no_epoch proc_det proc_misc2 sleeping=0 detail_mem_graph proc_det2 proc_out curled git_version has_iostat @@ -1617,8 +1617,8 @@ collect_mem() { #? Collect memory information from "/proc/meminfo" collect_processes() { #? Collect process information and calculate accurate cpu usage local argument="$1" if [[ -n $skip_process_draw && $argument != "now" ]]; then return; fi - local width=${box[processes_width]} height=${box[processes_height]} format_args format_cmd readline sort symbol="▼" cpu_title options pid_string tmp selected - local -a grep_array + local width=${box[processes_width]} height=${box[processes_height]} format_args format_cmd readline sort symbol="▼" cpu_title options pid_string tmp selected tree tree_compare1 tree_compare2 tree_compare3 + local -a grep_array saved_proc_array if [[ $argument == "now" ]]; then skip_process_draw=1; fi @@ -1631,12 +1631,14 @@ collect_processes() { #? Collect process information and calculate accurate cpu "user") selected="User:"; sort="euser";; "memory") selected="Mem%"; sort="pmem";; "cpu lazy"|"cpu responsive") sort="pcpu"; selected="Cpu%";; + "tree") selected="Tree:"; tree="Tree:"; sort="pid"; esac #* Collect output from ps command to array - if ((width>60)); then format_args=",args:$(( width-(47+proc[pid_len]) ))=Arguments:"; format_cmd=15 + if ((width>60)) && [[ $proc_sorting != "tree" ]] ; then format_args=",args:$(( width-(47+proc[pid_len]) ))=Arguments:"; format_cmd=15 else format_cmd=$(( width-(31+proc[pid_len]) )); fi + saved_proc_array=("${proc_array[@]}") unset 'proc_array[@]' 'pid_array[@]' if ((proc[detailed]==0)) && [[ -n ${proc[detailed_name]} ]]; then @@ -1652,7 +1654,7 @@ collect_processes() { #? Collect process information and calculate accurate cpu options="-t" fi - readarray ${options} proc_array < <(ps ax -o pid:${proc[pid_len]}=Pid:,comm:${format_cmd}=Program:${format_args},nlwp:3=Tr:,euser:6=User:,pmem=Mem%,pcpu:10=Cpu% --sort ${proc[reverse]:--}${sort}) + readarray ${options} proc_array < <(ps ax${tree:+f} -o pid:${proc[pid_len]}=Pid:,comm:${format_cmd}=${tree:-Program:}${format_args},nlwp:3=Tr:,euser:6=User:,pmem=Mem%,pcpu:10=Cpu% --sort ${proc[reverse]:--}${sort}) proc_array[0]="${proc_array[0]/ Tr:/ Threads:}" proc_array[0]="${proc_array[0]/ ${selected}/${symbol}${selected}}" @@ -1682,13 +1684,24 @@ collect_processes() { #? Collect process information and calculate accurate cpu else breaking=1; fi fi - if get_key -save && [[ ${#saved_key[@]} -gt 0 ]]; then return; fi + if get_key -save && [[ ${#saved_key[@]} -gt 0 ]]; then proc_array=("${saved_proc_array[@]}"); return; fi work_array=(${readline}) pid="${work_array[0]}" pcpu_usage="${work_array[-1]}" + #* If showing tree structure replace slashes and pipes with actual lines and terminate them at the correct places + if [[ $proc_sorting == "tree" ]]; then + tree_compare1="${proc_array[$((count+1))]%'\_'*}" + tree_compare2="${proc_array[count]%'\_'*}" + tree_compare3="${proc_array[$((count+1))]%'|'*}" + proc_array[count]="${proc_array[count]//'|'/│}" + proc_array[count]="${proc_array[count]//'\_'/└─}" + if ((count<${#proc_array[@]}-1)) && [[ ${#tree_compare1} -eq ${#tree_compare2} || ${#tree_compare2} -eq ${#tree_compare3} ]]; then + proc_array[count]="${proc_array[count]//'└'/├}" + fi + fi if [[ ! ${pid_history[*]} =~ ${pid} ]]; then pid_history+=("${pid}") @@ -1821,7 +1834,7 @@ collect_processes() { #? Collect process information and calculate accurate cpu if ((breaking==1)); then if [[ ${proc[detailed]} == "1" && -z ${proc[detailed_cpu]} ]] && ps ${proc[detailed_pid]} >/dev/null 2>&1; then - readarray ${options} -O ${#proc_array[@]} proc_array < <(ps -o pid:${proc[pid_len]}=Pid:,comm:${format_cmd}=Program:${format_args},nlwp:3=Tr:,euser:6=User:,pmem=Mem%,pcpu:10=Cpu% --no-headers -p ${proc[detailed_pid]} || true) + readarray ${options} -O ${#proc_array[@]} proc_array < <(ps -o pid:${proc[pid_len]}=Pid:,comm:${format_cmd}=${tree:-Program:}${format_args},nlwp:3=Tr:,euser:6=User:,pmem=Mem%,pcpu:10=Cpu% --no-headers -p ${proc[detailed_pid]} || true) else break fi @@ -2895,14 +2908,17 @@ options_() { #? Shows the options overlay "Max value: 86400000 ms = 24 hours.") desc_proc_sorting=( "Processes sorting." "Valid values are \"pid\", \"program\", \"arguments\"," - "\"threads\", \"user\", \"memory\", \"cpu lazy\" and" - "\"cpu responsive\"." + "\"threads\", \"user\", \"memory\", \"cpu lazy\"" + "\"cpu responsive\" and \"tree\"." " " "\"cpu lazy\" uses ps commands internal sorting" "and updates top process over a period of time." " " "\"cpu responsive\" updates sorting directly at a" - "cost of cpu time.") + "cost of cpu time." + " " + "\"tree\" shows a tree structure of running" + "processes.") desc_check_temp=( "Check cpu temperature." " " "Only works if sensors command is available" From 5c299d2a3f8d712495e00a535f255e4337fb8469 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Sat, 2 May 2020 21:08:25 +0200 Subject: [PATCH 02/30] Added option to toggle process cpu usage per core instead of total cpu --- bashtop | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/bashtop b/bashtop index 58e5518..336c9a3 100755 --- a/bashtop +++ b/bashtop @@ -104,6 +104,9 @@ error_logging="true" #* Show color gradient in process list, "true" or "false" proc_gradient="true" +#* If process cpu usage should be of the core it's running on or usage of the total available cpu power +proc_per_core="false" + #* Optional filter for shown disks, should be names of mountpoints, "root" replaces "/", separate multiple values with space disks_filter="" @@ -142,7 +145,7 @@ declare -A cpu mem swap proc net box theme disks declare -a cpu_usage cpu_graph_a cpu_graph_b color_meter color_temp_graph color_cpu color_cpu_graph cpu_history color_mem_graph color_swap_graph declare -a mem_history swap_history net_history_download net_history_upload mem_graph swap_graph proc_array download_graph upload_graph trace_array declare resized=1 size_error clock tty_width tty_height hex="16#" cpu_p_box swap_on=1 draw_out esc_character boxes_out last_screen clock_out update_string -declare -a options_array=("color_theme" "update_ms" "proc_sorting" "check_temp" "draw_clock" "background_update" "custom_cpu_name" +declare -a options_array=("color_theme" "update_ms" "proc_sorting" "check_temp" "draw_clock" "background_update" "custom_cpu_name" "proc_per_core" "proc_reversed" "proc_gradient" "disks_filter" "net_totals_reset" "error_logging") declare -a save_array=(${options_array[*]/net_totals_reset/}) declare -a sorting=( "pid" "program" "arguments" "threads" "user" "memory" "cpu lazy" "cpu responsive" "tree" ) @@ -1617,7 +1620,8 @@ collect_mem() { #? Collect memory information from "/proc/meminfo" collect_processes() { #? Collect process information and calculate accurate cpu usage local argument="$1" if [[ -n $skip_process_draw && $argument != "now" ]]; then return; fi - local width=${box[processes_width]} height=${box[processes_height]} format_args format_cmd readline sort symbol="▼" cpu_title options pid_string tmp selected tree tree_compare1 tree_compare2 tree_compare3 + local width=${box[processes_width]} height=${box[processes_height]} format_args format_cmd readline sort symbol="▼" cpu_title options pid_string tmp selected + local tree tree_compare1 tree_compare2 tree_compare3 no_core_divide local -a grep_array saved_proc_array if [[ $argument == "now" ]]; then skip_process_draw=1; fi @@ -1634,6 +1638,7 @@ collect_processes() { #? Collect process information and calculate accurate cpu "tree") selected="Tree:"; tree="Tree:"; sort="pid"; esac + if [[ $proc_per_core == true ]]; then no_core_divide="1"; fi #* Collect output from ps command to array if ((width>60)) && [[ $proc_sorting != "tree" ]] ; then format_args=",args:$(( width-(47+proc[pid_len]) ))=Arguments:"; format_cmd=15 @@ -1726,10 +1731,10 @@ collect_processes() { #? Collect process information and calculate accurate cpu time_elapsed=$((proc[new_timestamp]-proc[old_timestamp])) #* Calculate current cpu usage for process, * 1000 (for conversion from ms to seconds) * 1000 (for conversion to floating point) - cpu_percent[count]=$(( ( ( ${proc[new_${pid}_ticks]}-${proc[old_${pid}_ticks]} ) * 1000 * 1000 ) / ( cpu[hz]*time_elapsed*cpu[threads] ) )) + cpu_percent[count]=$(( ( ( ${proc[new_${pid}_ticks]}-${proc[old_${pid}_ticks]} ) * 1000 * 1000 ) / ( cpu[hz]*time_elapsed*${no_core_divide:-${cpu[threads]}} ) )) if ((cpu_percent[count]<0)); then cpu_percent[count]=0 - elif ((cpu_percent[count]>1000)); then cpu_percent[count]=1000; fi + elif [[ -z $no_core_divide ]] && ((cpu_percent[count]>1000)); then cpu_percent[count]=1000; fi if ((${#cpu_percent[count]}<=3)); then printf -v cpu_percent_string "%01d%s" "${cpu_percent[count]::-1}" ".${cpu_percent[count]:(-1)}" @@ -2965,6 +2970,14 @@ options_() { #? Shows the options overlay " " "Shows totals since system start or" "network adapter reset when Off.") + desc_proc_per_core=("Process usage per core." + " " + "If process cpu usage should be of the core" + "it's running on or usage of the total" + "available cpu power." + "" + "If true and process is multithreaded" + "cpu usage can reach over 100%.") if [[ -n $pause_screen ]]; then from_menu=1; fi @@ -3138,7 +3151,7 @@ options_() { #? Shows the options overlay if ((net[reset]==1)); then net_totals_reset="Off"; net[reset]=0 else net_totals_reset="On"; net[reset]=1; fi ;; - "check_temp"*|"error_logging"*|"background_update"*|"proc_reversed"*|"proc_gradient"*) + "check_temp"*|"error_logging"*|"background_update"*|"proc_reversed"*|"proc_gradient"*|"proc_per_core"*) local -n selected_var=${selected} if [[ ${selected_var} == "true" ]]; then selected_var="false" From 0982f993f6018a9a1c5543f217fab46ba7eed408 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Sun, 3 May 2020 00:58:40 +0200 Subject: [PATCH 03/30] possible fix for stalling read command, added while loop failsafes --- bashtop | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bashtop b/bashtop index 336c9a3..e848cce 100755 --- a/bashtop +++ b/bashtop @@ -1108,6 +1108,8 @@ create_graph() { #? Create a graph from an array of percentage values, usage; #* Create graph by walking through all values for each line, speed up by counting similar values and print once, when difference is met while ((xcur_value)); do + while ((x=cur_value)); do ((++count)) ((++x)) done @@ -1451,7 +1453,7 @@ collect_cpu_temps() { #? Collect cpu temperatures #* Get core temps i=0 - while get_value -v "core_value" -sv "sens_var" -k "Core ${i}:" -mk 1 -r "[^0-9.]" -b -i; do core_array+=("$core_value"); ((++i)) ; done + while get_value -v "core_value" -sv "sens_var" -k "Core ${i}:" -mk 1 -r "[^0-9.]" -b -i && ((i<=threads)); do core_array+=("$core_value"); ((++i)) ; done if [[ -z ${core_array[0]} ]]; then core_array=("${cpu[temp_0]}"); fi @@ -1480,7 +1482,7 @@ collect_cpu_temps() { #? Collect cpu temperatures #* Get ccd module temps i=1 - while get_value -v "ccd_value" -sv "sens_var" -k "Tccd${i}:" -mk 1 -r "[^0-9.]" -b -i; do ccd_array+=("$ccd_value"); ((i++)) ; done + while get_value -v "ccd_value" -sv "sens_var" -k "Tccd${i}:" -mk 1 -r "[^0-9.]" -b -i && ((i<=threads)); do ccd_array+=("$ccd_value"); ((i++)) ; done if [[ -z ${ccd_array[0]} ]]; then ccd_array=("${cpu[temp_0]}"); fi @@ -3351,7 +3353,7 @@ get_key() { #? Get one key from standard input and translate key code to readabl if [[ -z $save && -n ${saved_key[0]} ]]; then key="${saved_key[0]}"; unset 'saved_key[0]'; saved_key=("${saved_key[@]}") else unset key - IFS= read -rsd '' -t ${wait_time:-0.001} -n 1 key >/dev/null 2>&1 ||true + IFS= read -rsd '' -t ${wait_time:-0.001} -n 1 key 2>/dev/null ||true if [[ -z ${key:+s} ]]; then key_out="" @@ -3688,7 +3690,7 @@ else fi #* Set up traps for ctrl-c, soft kill, window resize, ctrl-z and resume from ctrl-z -trap 'quitting=1; time_left=0' SIGINT SIGQUIT SIGTERM +trap 'quitting=1; time_left=0' SIGINT #SIGQUIT SIGTERM trap 'resized=1; time_left=0' SIGWINCH trap 'sleepy=1; time_left=0' SIGTSTP trap 'resume_' SIGCONT From d226b21407ca3bff3bf0746a0a00ee008f6badd3 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Sun, 3 May 2020 01:00:24 +0200 Subject: [PATCH 04/30] v0.8.22 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92f760f..26a446f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## v0.8.22 + +* Added: Sorting option "tree", shows processes in a tree structure +* Added: Option to toggle process cpu usage per core instead of total available cpu power +* Fixed: Possible fix for stalling read command +* Added: Multiple while loop fail safes + ## v0.8.21 * Fixed: iostat flag compatibility for older iostat versions From e77e79a5c11c4dc3d893ff851d2ecd60003ec098 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Sun, 3 May 2020 01:02:32 +0200 Subject: [PATCH 05/30] Updated example config file, Updated TODO's --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ceec6f9..4be9897 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ * [Dependencies](#dependencies) (Updated) * [Screenshots](#screenshots) * [Installation](#installation) (Updated) -* [Configurability](#configurability) +* [Configurability](#configurability) (Updated) * [TODO](#todo) * [License](#license) @@ -202,7 +202,7 @@ Config files stored in "$HOME/.config/bashtop" folder #### bashtop.cfg: (auto generated if not found) ```bash -#? Config file for bashtop v. 0.8.18 +#? Config file for bashtop v. 0.8.22 #* Color theme, looks for a .theme file in "$HOME/.config/bashtop/themes", "Default" for builtin default theme color_theme="Default" @@ -210,7 +210,7 @@ color_theme="Default" #* Update time in milliseconds, increases automatically if set below internal loops processing time, recommended 2000 ms or above for better sample times for graphs update_ms="2500" -#* Processes sorting, "pid" "program" "arguments" "threads" "user" "memory" "cpu lazy" "cpu responsive" +#* Processes sorting, "pid" "program" "arguments" "threads" "user" "memory" "cpu lazy" "cpu responsive" "tree" #* "cpu lazy" updates sorting over time, "cpu responsive" updates sorting directly at a cpu usage cost proc_sorting="cpu lazy" @@ -235,6 +235,9 @@ error_logging="true" #* Show color gradient in process list, "true" or "false" proc_gradient="true" +#* If process cpu usage should be of the core it's running on or usage of the total available cpu power +proc_per_core="false" + #* Optional filter for shown disks, should be names of mountpoints, "root" replaces "/", separate multiple values with space disks_filter="" ``` @@ -253,7 +256,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 for Mac OSX and *BSD: Currently in testing, bashtop-psutil branch. - [x] Add support for showing AMD cpu temperatures. -- [ ] Add option to show tree view of processes. +- [x] Add option to show tree view of processes. - [x] Add option to reset network download/upload totals. - [x] Add option to turn of gradient in processes list. - [ ] Add gpu temp and usage. (If feasible) From d13281ab2a721304f9670dc01833ef1f3830a866 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Sun, 3 May 2020 01:04:23 +0200 Subject: [PATCH 06/30] v0.8.22 New features processes tree view and process per cpu usage --- bashtop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bashtop b/bashtop index e848cce..3db0339 100755 --- a/bashtop +++ b/bashtop @@ -64,7 +64,7 @@ banner=( "██╔══██╗██╔══██║╚════██║██╔══██║ ██║ ██║ ██║██╔═══╝ " "██████╔╝██║ ██║███████║██║ ██║ ██║ ╚██████╔╝██║ " "╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ") -declare version="0.8.21" +declare version="0.8.22" declare banner_width=${#banner[0]} banner_colors=("#E62525" "#CD2121" "#B31D1D" "#9A1919" "#801414") From 89253debe83d546eec93c47787530f5c9b61e62c Mon Sep 17 00:00:00 2001 From: aristocratos Date: Sun, 3 May 2020 14:39:17 +0200 Subject: [PATCH 07/30] Fixed: Decreased chance of read command stalling on lower spec systems. Added: Failover to nproc if lscpu are reporting 0 cpu cores --- bashtop | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bashtop b/bashtop index 3db0339..0dc1671 100755 --- a/bashtop +++ b/bashtop @@ -712,8 +712,13 @@ get_cpu_info() { local lscpu_var param_var lscpu_var="$(lscpu)" if [[ -z ${cpu[threads]} || -z ${cpu[cores]} ]]; then - get_value -v 'cpu[threads]' -sv "lscpu_var" -k "CPU(s):" -i + if ! get_value -v 'cpu[threads]' -sv "lscpu_var" -k "CPU(s):" -i || [[ ${cpu[threads]} == "0" ]]; then + cpu[threads]="$(nproc 2>/dev/null ||true)" + if [[ -z ${cpu[threads]} ]]; then cpu[threads]="1"; fi + cpu[cores]=${cpu[threads]} + else get_value -v 'cpu[cores]' -sv "lscpu_var" -k "Core(s)" -i + fi fi if [[ -z $custom_cpu_name ]]; then if ! get_value -v 'cpu[model]' -sv "lscpu_var" -k "Model name:" -a -b -k "CPU" -mk -1; then @@ -1691,7 +1696,7 @@ collect_processes() { #? Collect process information and calculate accurate cpu else breaking=1; fi fi - if get_key -save && [[ ${#saved_key[@]} -gt 0 ]]; then proc_array=("${saved_proc_array[@]}"); return; fi + #if get_key -save && [[ ${#saved_key[@]} -gt 0 ]]; then proc_array=("${saved_proc_array[@]}"); return; fi work_array=(${readline}) @@ -3365,7 +3370,7 @@ get_key() { #? Get one key from standard input and translate key code to readabl if [[ $key == "${enter_key}" ]]; then key="enter" elif [[ $key == "${backspace}" ]]; then key="backspace" elif [[ $key == "${tab}" ]]; then key="tab" - elif [[ $key == "$esc_character" ]]; then esc=1; read -rsn3 -t 0.001 key >/dev/null 2>&1 || true; fi + elif [[ $key == "$esc_character" ]]; then esc=1; read -rsn3 -t 0.001 key 2>/dev/null || true; fi if [[ -z $key && $esc -eq 1 ]]; then key="escape" elif [[ $esc -eq 1 ]]; then case "${key}" in From d4933fd26aac0313c13b08db213c86abefbe2522 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Sun, 3 May 2020 15:07:35 +0200 Subject: [PATCH 08/30] Added: Support for Raspberry Pi cpu temp reporting --- bashtop | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/bashtop b/bashtop index 0dc1671..f4c92bb 100755 --- a/bashtop +++ b/bashtop @@ -1450,7 +1450,7 @@ collect_cpu_temps() { #? Collect cpu temperatures #* 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 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 ! 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 @@ -1479,7 +1479,7 @@ collect_cpu_temps() { #? Collect cpu temperatures #* Get CPU package temp for amd ryzen cpus 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 - 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 ! 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)) @@ -1500,6 +1500,20 @@ collect_cpu_temps() { #? Collect cpu temperatures z=$((z+i)) 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 else check_temp="false" From 239ec44a2b1476030978dddfcc1d97e073a6e1ba Mon Sep 17 00:00:00 2001 From: aristocratos Date: Sun, 3 May 2020 15:25:59 +0200 Subject: [PATCH 09/30] v0.8.23 Added Raspberry Pi temperature reporting and fix for freezing --- CHANGELOG.md | 7 +++++++ bashtop | 17 +++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26a446f..c17d340 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## v0.8.23 + +* Added: Support for Raspberry Pi cpu temperature reporting +* Fixed: Decreased chance of read command stalling on lower spec systems +* Added: Failover to nproc if lscpu are reporting 0 cpu cores +* Changed: Moved page display for options and help to bottom and changed to Page Up/Down for changing page + ## v0.8.22 * Added: Sorting option "tree", shows processes in a tree structure diff --git a/bashtop b/bashtop index f4c92bb..081235e 100755 --- a/bashtop +++ b/bashtop @@ -64,7 +64,7 @@ banner=( "██╔══██╗██╔══██║╚════██║██╔══██║ ██║ ██║ ██║██╔═══╝ " "██████╔╝██║ ██║███████║██║ ██║ ██║ ╚██████╔╝██║ " "╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ") -declare version="0.8.22" +declare version="0.8.23" declare banner_width=${#banner[0]} banner_colors=("#E62525" "#CD2121" "#B31D1D" "#9A1919" "#801414") @@ -2858,7 +2858,8 @@ help_() { #? Shows the help overlay create_box -v help_out -w 72 -h $((height+3)) -l $((line++)) -c $((col++)) -fill -lc ${theme[div_line]} -title "help" if [[ -n $pages ]]; then - print -v help_out -m $((line-1)) $((col+72-17)) -rs -fg ${theme[div_line]} -t "┤" -fg ${theme[hi_fg]} -b -t "‹" -fg ${theme[title]} -t " page ${page}/${pages} " -fg ${theme[hi_fg]} -t "›" -rs -fg ${theme[div_line]} -t "├" + print -v help_out -m $((line+height+1)) $((col+72-16)) -rs -fg ${theme[div_line]} -t "┤" -fg ${theme[title]} -b -t "pg" -fg ${theme[hi_fg]} -t "↑"\ + -fg ${theme[title]} -t " ${page}/${pages} " -fg ${theme[title]} -t "pg" -fg ${theme[hi_fg]} -t "↓" -rs -fg ${theme[div_line]} -t "├" fi ((++col)) @@ -2884,8 +2885,8 @@ help_() { #? Shows the help overlay if [[ -n $pages ]]; then case $help_key in - right) if ((page1)); then ((page--)); else page=${pages}; fi; redraw=1; unset help_key ;; + down|page_down) if ((page1)); then ((page--)); else page=${pages}; fi; redraw=1; unset help_key ;; esac fi @@ -3025,11 +3026,11 @@ options_() { #? Shows the options overlay draw_banner "$((tty_height/2-11))" options_misc create_box -v options_misc -w 29 -h $((height*2+2)) -l $line -c $((col-1)) -fill -lc ${theme[div_line]} -title "options" if [[ -n $pages ]]; then - print -v options_misc -m $((line)) $((col+29-17)) -rs -fg ${theme[div_line]} -t "┤" -fg ${theme[hi_fg]} -b -t "p" -fg ${theme[title]} -t " page ${page}/${pages} " -fg ${theme[hi_fg]} -t "n" -rs -fg ${theme[div_line]} -t "├" + print -v options_misc -m $((line+height*2+1)) $((col+29-16)) -rs -fg ${theme[div_line]} -t "┤" -fg ${theme[title]} -b -t "pg" -fg ${theme[hi_fg]} -t "↑"\ + -fg ${theme[title]} -t " ${page}/${pages} " -fg ${theme[title]} -t "pg" -fg ${theme[hi_fg]} -t "↓" -rs -fg ${theme[div_line]} -t "├" fi fi - if [[ -n $keypress || -z $options_out ]]; then unset options_out desc_height lr inp valid selected="${options_array[selected_int]}" @@ -3119,8 +3120,8 @@ options_() { #? Shows the options overlay up|shift_tab) if ((selected_int>0)); then ((selected_int--)); else selected_int=$((${#options_array[@]}-1)); fi ;; left|right) if [[ -n $lr && -z $inputting ]]; then valid=1; fi ;; enter) if [[ -n $inp ]]; then valid=1; fi ;; - n) if ((page1)); then ((page--)); else page=${pages}; fi; redraw_misc=1; selected_int=$(( (page-1)*height )) ;; + page_down) if ((page1)); then ((page--)); else page=${pages}; fi; redraw_misc=1; selected_int=$(( (page-1)*height )) ;; esac if (( selected_int<(page-1)*height | selected_int>=page*height )); then page=$(( (selected_int/height)+1 )); redraw_misc=1; fi fi From e4485fc0e2a589c3170e204667d8011da9d26a2e Mon Sep 17 00:00:00 2001 From: aristocratos Date: Sun, 3 May 2020 19:12:35 +0200 Subject: [PATCH 10/30] Added "gruvbox_dark.theme" by BachoSeven --- themes/gruvbox_dark.theme | 89 +++++++++++++++++++++++++++++++++++++++ themes/index.txt | 1 + 2 files changed, 90 insertions(+) create mode 100644 themes/gruvbox_dark.theme diff --git a/themes/gruvbox_dark.theme b/themes/gruvbox_dark.theme new file mode 100644 index 0000000..0399b03 --- /dev/null +++ b/themes/gruvbox_dark.theme @@ -0,0 +1,89 @@ +#Bashtop gruvbox (https://github.com/morhetz/gruvbox) theme +#by BachoSeven + +# Colors should be in 6 or 2 character hexadecimal or single spaced rgb decimal: "#RRGGBB", "#BW" or "0-255 0-255 0-255" +# example for white: "#FFFFFF", "#ff" or "255 255 255". + +# All graphs and meters can be gradients +# For single color graphs leave "mid" and "end" variable empty. +# Use "start" and "end" variables for two color gradient +# Use "start", "mid" and "end" for three color gradient + +# Main background, empty for terminal default, need to be empty if you want transparent background +theme[main_bg]="#1d2021" + +# Main text color +theme[main_fg]="#a89984" + +# Title color for boxes +theme[title]="#ebdbb2" + +# Higlight color for keyboard shortcuts +theme[hi_fg]="#d79921" + +# Background color of selected items +theme[selected_bg]="#282828" + +# Foreground color of selected items +theme[selected_fg]="#fabd2f" + +# Color of inactive/disabled text +theme[inactive_fg]="#282828" + +# Misc colors for processes box including mini cpu graphs, details memory graph and details status text +theme[proc_misc]="#98971a" + +# Cpu box outline color +theme[cpu_box]="#a89984" + +# Memory/disks box outline color +theme[mem_box]="#a89984" + +# Net up/down box outline color +theme[net_box]="#a89984" + +# Processes box outline color +theme[proc_box]="#a89984" + +# Box divider line and small boxes line color +theme[div_line]="#a89984" + +# Temperature graph colors +theme[temp_start]="#458588" +theme[temp_mid]="#d3869b" +theme[temp_end]="#fb4394" + +# CPU graph colors +theme[cpu_start]="#b8bb26" +theme[cpu_mid]="#d79921" +theme[cpu_end]="#fb4934" + +# Mem/Disk free meter +theme[free_start]="#4e5900" +theme[free_mid]="" +theme[free_end]="#98971a" + +# Mem/Disk cached meter +theme[cached_start]="#458588" +theme[cached_mid]="" +theme[cached_end]="#83a598" + +# Mem/Disk available meter +theme[available_start]="#d79921" +theme[available_mid]="" +theme[available_end]="#fabd2f" + +# Mem/Disk used meter +theme[used_start]="#cc241d" +theme[used_mid]="" +theme[used_end]="#fb4934" + +# Download graph colors +theme[download_start]="#3d4070" +theme[download_mid]="#6c71c4" +theme[download_end]="#a3a8f7" + +# Upload graph colors +theme[upload_start]="#701c45" +theme[upload_mid]="#b16286" +theme[upload_end]="#d3869b" diff --git a/themes/index.txt b/themes/index.txt index 728fb2a..8274eb8 100644 --- a/themes/index.txt +++ b/themes/index.txt @@ -2,6 +2,7 @@ default_black.theme flat-remix-light.theme flat-remix.theme greyscale.theme +gruvbox_dark.theme monokai_nobg.theme monokai.theme solarized_dark.theme From 2a543237598eb54400ac19bfcf7cbddf12907984 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Mon, 4 May 2020 12:36:53 +0200 Subject: [PATCH 11/30] Updated Upcoming: Python port --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4be9897..1811969 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ * [Description](#description) * [Features](#features) * [Themes](#themes) -* [Upcoming](#upcoming) (Updated) +* [Upcoming](#upcoming) (Updated, Python port) * [Support and funding](#support-and-funding) * [Compatibility](#compatibility) (Updated) * [Dependencies](#dependencies) (Updated) @@ -63,6 +63,12 @@ This will add python 3 and psutil as dependencies, but will make bashtop cross p This will be integrated in to main version when done and add the possibility to switch between psutil and linux tools for users running linux. +#### Update + +Work on a complete python port will begin this summer. My aim is to keep it compatible with pypy3 for a lot of added efficiency. + +Bash(py)top? + ## Support and funding Bug fixes and updates might be slow during normal workdays since I work full time as an industrial worker and don't have much time or energy left during the week. From 911aadc86aa67144d2d6e273d6cc687d406fc3e1 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Mon, 4 May 2020 19:36:41 +0200 Subject: [PATCH 12/30] v0.8.24 Fix for freezes caused by read errors --- CHANGELOG.md | 4 +++ bashtop | 99 +++++++++++++++++++++++++++++++++------------------- 2 files changed, 67 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c17d340..7104d79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.8.24 + +* Fixed: Input error freezes, by changing from using "read" command to using "dd" for reading keyboard input. + ## v0.8.23 * Added: Support for Raspberry Pi cpu temperature reporting diff --git a/bashtop b/bashtop index 081235e..e18db45 100755 --- a/bashtop +++ b/bashtop @@ -64,7 +64,7 @@ banner=( "██╔══██╗██╔══██║╚════██║██╔══██║ ██║ ██║ ██║██╔═══╝ " "██████╔╝██║ ██║███████║██║ ██║ ██║ ╚██████╔╝██║ " "╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ") -declare version="0.8.23" +declare version="0.8.24" declare banner_width=${#banner[0]} banner_colors=("#E62525" "#CD2121" "#B31D1D" "#9A1919" "#801414") @@ -152,12 +152,13 @@ declare -a sorting=( "pid" "program" "arguments" "threads" "user" "memory" "cpu declare -a pid_history detail_graph detail_history detail_mem_history declare time_left timestamp_start timestamp_end timestamp_input_start timestamp_input_end time_string mem_out proc_misc prev_screen pause_screen filter input_to_filter declare no_epoch proc_det proc_misc2 sleeping=0 detail_mem_graph proc_det2 proc_out curled git_version has_iostat -declare esc_character tab backspace sleepy late_update skip_process_draw winches quitting theme_int notifier +declare esc_character tab backspace sleepy late_update skip_process_draw winches quitting theme_int notifier saved_stty declare -a disks_free disks_total disks_name disks_free_percent disks_io saved_key themes printf -v esc_character "\u1b" printf -v tab "\u09" printf -v backspace "\u7F" -printf -v enter_key "\uA" +#printf -v enter_key "\uA" +printf -v enter_key "\uD" read tty_height tty_width < <(stty size) @@ -213,6 +214,7 @@ fi init_() { #? Collect needed information and set options before startig main loop local i #* Set terminal options, save and clear screen + saved_stty="$(stty -g)" tput smcup stty -echo tput civis @@ -444,6 +446,7 @@ quit_() { #? Clean exit tput rmcup stty echo tput cnorm + stty "${saved_stty}" #* Save any changed values to config file if [[ $config_file != "/dev/null" ]]; then @@ -457,6 +460,7 @@ sleep_() { #? Restore terminal options, stop and send to background if caught SI tput rmcup stty echo tput cnorm + stty "${saved_stty}" kill -s SIGSTOP $$ } @@ -2760,9 +2764,12 @@ menu_() { #? Shows the main menu overlay get_ms timestamp_end time_left=$((timestamp_start+update_ms-timestamp_end)) - if ((time_left>1000)); then wait_string=1; time_left=$((time_left-1000)) - elif ((time_left>1)); then printf -v wait_string ".%03d" "${time_left}"; time_left=0 - else wait_string="0.001"; time_left=0; fi + # if ((time_left>1000)); then wait_string=1; time_left=$((time_left-1000)) + # elif ((time_left>1)); then printf -v wait_string ".%03d" "${time_left}"; time_left=0 + # else wait_string="0.001"; time_left=0; fi + if ((time_left>1000)); then wait_string=10; time_left=$((time_left-1000)) + elif ((time_left>100)); then wait_string=$((time_left/100)); time_left=0 + else wait_string="0"; time_left=0; fi get_key -v keypress -w ${wait_string} if [[ $(stty size) != "$tty_height $tty_width" ]]; then resized; fi @@ -2785,7 +2792,7 @@ menu_() { #? Shows the main menu overlay q|Q) quit_ ;; esac - if ((time_left==0)); then get_ms timestamp_start; collect_and_draw; fi + if ((time_left==0)) && [[ -z $keypress ]]; then get_ms timestamp_start; collect_and_draw; fi if ((resized>=5)); then resized=0; fi done @@ -2877,9 +2884,13 @@ help_() { #? Shows the help overlay get_ms timestamp_end time_left=$((timestamp_start+update_ms-timestamp_end)) - if ((time_left>1000)); then wait_string=1; time_left=$((time_left-1000)) - elif ((time_left>0)); then printf -v wait_string ".%03d" "${time_left}"; time_left=0 - else wait_string="0.001"; time_left=0; fi + # if ((time_left>1000)); then wait_string=1; time_left=$((time_left-1000)) + # elif ((time_left>0)); then printf -v wait_string ".%03d" "${time_left}"; time_left=0 + # else wait_string="0.001"; time_left=0; fi + + if ((time_left>1000)); then wait_string=10; time_left=$((time_left-1000)) + elif ((time_left>100)); then wait_string=$((time_left/100)); time_left=0 + else wait_string="0"; time_left=0; fi get_key -v help_key -w "${wait_string}" @@ -3101,9 +3112,13 @@ options_() { #? Shows the options overlay get_ms timestamp_end if [[ -z $theme_check ]]; then time_left=$((timestamp_start+update_ms-timestamp_end)) else unset theme_check; time_left=0; fi - if ((time_left>500)); then wait_string=0.5 - elif ((time_left>0)); then printf -v wait_string ".%03d" "${time_left}" - else wait_string="0.001"; time_left=0; fi + # if ((time_left>500)); then wait_string=0.5 + # elif ((time_left>0)); then printf -v wait_string ".%03d" "${time_left}" + # else wait_string="0.001"; time_left=0; fi + + if ((time_left>500)); then wait_string=5; time_left=$((time_left-500)) + elif ((time_left>100)); then wait_string=$((time_left/100)); time_left=0 + else wait_string="0"; time_left=0; fi get_key -v keypress -w ${wait_string} @@ -3306,9 +3321,13 @@ killer_() { #? Kill process with selected signal get_ms timestamp_end time_left=$((timestamp_start+update_ms-timestamp_end)) - if ((time_left>1000)); then wait_string=1; time_left=$((time_left-1000)) - elif ((time_left>1)); then printf -v wait_string ".%03d" "${time_left}"; time_left=0 - else wait_string="0.001"; time_left=0; fi + # if ((time_left>1000)); then wait_string=1; time_left=$((time_left-1000)) + # elif ((time_left>1)); then printf -v wait_string ".%03d" "${time_left}"; time_left=0 + # else wait_string="0.001"; time_left=0; fi + + if ((time_left>1000)); then wait_string=10; time_left=$((time_left-1000)) + elif ((time_left>100)); then wait_string=$((time_left/100)); time_left=0 + else wait_string="0"; time_left=0; fi get_key -v keypress -w ${wait_string} if [[ $(stty size) != "$tty_height $tty_width" ]]; then resized; fi @@ -3373,7 +3392,8 @@ get_key() { #? Get one key from standard input and translate key code to readabl if [[ -z $save && -n ${saved_key[0]} ]]; then key="${saved_key[0]}"; unset 'saved_key[0]'; saved_key=("${saved_key[@]}") else unset key - IFS= read -rsd '' -t ${wait_time:-0.001} -n 1 key 2>/dev/null ||true + #IFS= read -rsd '' -t ${wait_time:-0.001} -n 1 key 2>/dev/null ||true + key=$(stty -cooked min 0 time ${wait_time:-0}; dd bs=1 count=1 2>/dev/null) if [[ -z ${key:+s} ]]; then key_out="" @@ -3385,25 +3405,26 @@ get_key() { #? Get one key from standard input and translate key code to readabl if [[ $key == "${enter_key}" ]]; then key="enter" elif [[ $key == "${backspace}" ]]; then key="backspace" elif [[ $key == "${tab}" ]]; then key="tab" - elif [[ $key == "$esc_character" ]]; then esc=1; read -rsn3 -t 0.001 key 2>/dev/null || true; fi + elif [[ $key == "$esc_character" ]]; then + esc=1; key=$(stty -cooked min 0 time 0; dd bs=1 count=3 2>/dev/null); fi # read -rsn3 -t 0.001 key 2>/dev/null || true if [[ -z $key && $esc -eq 1 ]]; then key="escape" elif [[ $esc -eq 1 ]]; then case "${key}" in - '[A') key="up" ;; - '[B') key="down" ;; - '[D') key="left" ;; - '[C') key="right" ;; + '[A'*) key="up" ;; + '[B'*) key="down" ;; + '[D'*) key="left" ;; + '[C'*) key="right" ;; '[2~') key="insert" ;; '[3~') key="delete" ;; - '[H') key="home" ;; - '[F') key="end" ;; + '[H'*) key="home" ;; + '[F'*) key="end" ;; '[5~') key="page_up" ;; '[6~') key="page_down" ;; - '[Z') key="shift_tab" ;; - 'OP') key="f1";; - 'OQ') key="f2";; - 'OR') key="f3";; - 'OS') key="f4";; + '[Z'*) key="shift_tab" ;; + 'OP'*) key="f1";; + 'OQ'*) key="f2";; + 'OR'*) key="f3";; + 'OS'*) key="f4";; '[15') key="f5";; '[17') key="f6";; '[18') key="f7";; @@ -3418,7 +3439,8 @@ get_key() { #? Get one key from standard input and translate key code to readabl fi - read -rst 0.001 -n 1000 2>/dev/null ||true + #read -rst 0.001 -n 1000 2>/dev/null ||true + stty -cooked min 0 time 0; dd bs=512 count=1 >/dev/null 2>&1 if [[ -n $save && -n $key ]]; then saved_key+=("${key}"); return 0; fi @@ -3594,7 +3616,7 @@ collect_and_draw() { #? Run all collect and draw functions elif [[ -z $pause_screen ]]; then input_runs=0 while [[ -n ${saved_key[0]} ]] && ((time_left>0)) && ((++input_runs<=5)); do - process_input 0.001 + process_input unset late_update done fi @@ -3651,17 +3673,22 @@ main_loop() { #? main loop... #* If NOT waiting for input and time left is greater than 500ms, wait 500ms and loop if [[ -z $input_to_filter ]] && ((time_left>=500)); then - wait_string="0.5" + # wait_string="0.5" + wait_string="5" time_left=$((time_left-500)) #* If waiting for input and time left is greater than "50 ms", wait 50ms and loop - elif [[ -n $input_to_filter ]] && ((time_left>=50)); then - wait_string="0.05" - time_left=$((time_left-50)) + # elif [[ -n $input_to_filter ]] && ((time_left>=50)); then + # wait_string="0.05" + # time_left=$((time_left-50)) + elif [[ -n $input_to_filter ]] && ((time_left>=100)); then + wait_string="1" + time_left=$((time_left-100)) #* Else format wait string with padded zeroes if needed and break loop else - printf -v wait_string ".%03d" "${time_left}" + #printf -v wait_string ".%03d" "${time_left}" + if ((time_left>=100)); then wait_string=$((time_left/100)); else wait_string=0; fi time_left=0 fi From ad90df8837f0e25318f23f0846a2f49a579e18f2 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Tue, 5 May 2020 17:29:46 +0200 Subject: [PATCH 13/30] Added install instructions for CentOS and RHEL 8 --- README.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1811969..ca668aa 100644 --- a/README.md +++ b/README.md @@ -187,7 +187,6 @@ Available for Ubuntu from [PPA repository](https://code.launchpad.net/~bashtop-m sudo add-apt-repository ppa:bashtop-monitor/bashtop sudo apt update sudo apt install bashtop - ``` #### Fedora @@ -200,6 +199,28 @@ Available in the Fedora repository. sudo dnf install bashtop ``` +#### CentOS + +>Installation + +``` bash +dnf config-manager --set-enabled PowerTools +dnf install epel-release +dnf install bashtop +``` + +#### RHEL 8 + +>Installation + +``` bash +ARCH=$( /bin/arch ) +subscription-manager repos --enable +"codeready-builder-for-rhel-8-${ARCH}-rpms" +dnf install epel-release +dnf install bashtop +``` + ## Configurability All options changeable from within UI. From a0c0a9965628c8ce2124643f7be0f8f3dd13895c Mon Sep 17 00:00:00 2001 From: aristocratos Date: Tue, 5 May 2020 20:06:03 +0200 Subject: [PATCH 14/30] Fix: backspace not registering --- bashtop | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bashtop b/bashtop index e18db45..8c61422 100755 --- a/bashtop +++ b/bashtop @@ -156,7 +156,8 @@ declare esc_character tab backspace sleepy late_update skip_process_draw winches declare -a disks_free disks_total disks_name disks_free_percent disks_io saved_key themes printf -v esc_character "\u1b" printf -v tab "\u09" -printf -v backspace "\u7F" +printf -v backspace "\u7F" #? Backspace set to DELETE +printf -v backspace_real "\u08" #? Real backspace #printf -v enter_key "\uA" printf -v enter_key "\uD" @@ -3403,7 +3404,7 @@ get_key() { #? Get one key from standard input and translate key code to readabl #* Read 3 more characters if a leading escape character is detected if [[ $key == "${enter_key}" ]]; then key="enter" - elif [[ $key == "${backspace}" ]]; then key="backspace" + elif [[ $key == "${backspace}" || $key == "${backspace_real}" ]]; then key="backspace" elif [[ $key == "${tab}" ]]; then key="tab" elif [[ $key == "$esc_character" ]]; then esc=1; key=$(stty -cooked min 0 time 0; dd bs=1 count=3 2>/dev/null); fi # read -rsn3 -t 0.001 key 2>/dev/null || true From 1692f22fd94d3f0df24309275822c94e5b6c088f Mon Sep 17 00:00:00 2001 From: aristocratos Date: Tue, 5 May 2020 20:56:05 +0200 Subject: [PATCH 15/30] Fixed: Broken cpu temperature graph when is value over cpu high temp --- bashtop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bashtop b/bashtop index 8c61422..28410e1 100755 --- a/bashtop +++ b/bashtop @@ -1247,7 +1247,7 @@ create_mini_graph() { #? Create a one line high graph from an array of percenta #* Round current input_array value divided by 10 to closest whole number org_value=${input_array[offset+x]} if ((org_value<0)); then org_value=0; fi - if ((org_value>=100)); then cur_value=10 + if ((org_value>=100)); then cur_value=10; org_value=100 elif [[ ${#org_value} -gt 1 && ${org_value:(-1)} -ge 5 ]]; then cur_value=$((${org_value::1}+1)) elif [[ ${#org_value} -gt 1 && ${org_value:(-1)} -lt 5 ]]; then cur_value=$((${org_value::1})) elif [[ ${org_value:(-1)} -ge 5 ]]; then cur_value=1 From 576c391575303a7b37c1d8ae411f9e5ae6ce8c15 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Tue, 5 May 2020 21:34:48 +0200 Subject: [PATCH 16/30] Added: Possibilty to run date through background fifo for bash <5 --- bashtop | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/bashtop b/bashtop index 28410e1..785c61c 100755 --- a/bashtop +++ b/bashtop @@ -200,16 +200,36 @@ if [[ -n $EPOCHREALTIME ]]; then ms_out=$((${EPOCHREALTIME/[.,]/}/1000)) } -#* If not, use date command +#* If not, use date command, through fifo if possible else - get_ms() { #? Set given variable to current epoch millisecond with date command - local count - local -n ms_out=$1 - ms_out="" - while [[ -z $ms_out ]] && ((++count<=10)); do + tmpdir="" + if [[ -n $XDG_RUNTIME_DIR && -w "$XDG_RUNTIME_DIR" ]]; then + tmpdir="$XDG_RUNTIME_DIR" + elif [[ -w /dev/shm ]]; then + tmpdir="/dev/shm" + elif [[ -w /tmp ]]; then + tmpdir="/tmp" + fi + + if [[ -n $tmpdir ]] && command -v stdbuf >/dev/null 2>&1; then + mkfifo "${tmpdir}/bashtop_datefifo" + exec 5> >(exec stdbuf -o0 date -f - +%s%3N > "${tmpdir}/bashtop_datefifo" 2>&1) + exec 6< "${tmpdir}/bashtop_datefifo" + rm "${tmpdir}/bashtop_datefifo" + + get_ms() { #? Set given variable to current epoch millisecond with date command through background fifo + local -n ms_out=$1 + echo now >&5 && + read -u 6 ms_out + } + + else + get_ms() { #? Set given variable to current epoch millisecond with forked date command + local -n ms_out=$1 + ms_out="" read ms_out < <(date +%s%3N) - done - } + } + fi fi init_() { #? Collect needed information and set options before startig main loop From 3304dacd246b475492eeff55dfb034fdeacfc497 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Tue, 5 May 2020 21:37:55 +0200 Subject: [PATCH 17/30] v0.8.25 Fixes cpu temp graphs and backspace not registering --- CHANGELOG.md | 6 ++++++ bashtop | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7104d79..eac20bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v0.8.25 + +* Fixed: Backspace not registering when not set to send ascii delete +* Fixed: Broken cpu temperature graph when is value over cpu high temp +* Added: Possibilty to run date through background fifo for bash <5 + ## v0.8.24 * Fixed: Input error freezes, by changing from using "read" command to using "dd" for reading keyboard input. diff --git a/bashtop b/bashtop index 785c61c..e959d7f 100755 --- a/bashtop +++ b/bashtop @@ -64,7 +64,7 @@ banner=( "██╔══██╗██╔══██║╚════██║██╔══██║ ██║ ██║ ██║██╔═══╝ " "██████╔╝██║ ██║███████║██║ ██║ ██║ ╚██████╔╝██║ " "╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ") -declare version="0.8.24" +declare version="0.8.25" declare banner_width=${#banner[0]} banner_colors=("#E62525" "#CD2121" "#B31D1D" "#9A1919" "#801414") From 5eeb9aef4824129bf9d3021094ce3eadbbd135d7 Mon Sep 17 00:00:00 2001 From: Cristian Date: Tue, 5 May 2020 21:56:32 -0300 Subject: [PATCH 18/30] Change PREFIX /usr by /usr/local --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7850e37..7b844ef 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -PREFIX ?= /usr +PREFIX ?= /usr/local DOCDIR ?= $(PREFIX)/share/doc/bashtop all: From f52541ffea9ca1b571b2fc8690e3ea02d3f0a893 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Wed, 6 May 2020 16:49:26 +0200 Subject: [PATCH 19/30] Fixed: Escaped delimter for sed to fix config not saving "/" character --- bashtop | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bashtop b/bashtop index e959d7f..2c8378c 100755 --- a/bashtop +++ b/bashtop @@ -578,6 +578,8 @@ save_config() { #? Saves variables to config file if not same, usage: save_confi if [[ ${tmp_value//\"/} != "${!var}" ]]; then original="${var}=${tmp_value}" new="${var}=\"${!var}\"" + original="${original//'/'/'\/'}" + new="${new//'/'/'\/'}" sed -i "s/${original}/${new}/" "${config_file}" fi else From 7f74cf40917d785d7a0b090f0367beff164479c1 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Wed, 6 May 2020 20:40:08 +0200 Subject: [PATCH 20/30] Fork cleanup and proc fixes --- bashtop | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/bashtop b/bashtop index 2c8378c..c78797f 100755 --- a/bashtop +++ b/bashtop @@ -513,7 +513,7 @@ traperr() { #? Function for reporting error line numbers fi if ((len>100)); then unset 'trace_array[@]'; fi trace_array+=("$err") - echo "$(printf "%(%X)T") ERROR: On line $err $trap_muted" >> "${config_dir}/error.log" + printf "%(%X)T ERROR: On line %s %s\n" -1 "$err" "$trap_muted" >> "${config_dir}/error.log" } @@ -1472,7 +1472,7 @@ collect_cpu_temps() { #? Collect cpu temperatures local -a ccd_array core_array #* Fetch output from "sensors" command to a variable - sens_var="$(sensors)" + read -rd '' sens_var < <(sensors) ||true #* 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 @@ -1529,7 +1529,7 @@ collect_cpu_temps() { #? Collect cpu temperatures #* 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)" + read -r cpu[temp_0] < <(vcgencmd measure_temp 2>/dev/null ||true) ||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 @@ -1568,7 +1568,7 @@ collect_mem() { #? Collect memory information from "/proc/meminfo" local -a mem_array swap_array available=("mem") #* Get memory and swap information from "/proc/meminfo" and calculate percentages - mem_info="$(5)); then proc[detailed_mem_count]=0 @@ -1831,7 +1836,8 @@ collect_processes() { #? Collect process information and calculate accurate cpu elif ((proc[detailed_mem_int]>100)); then proc[detailed_mem_int]=$((proc[detailed_mem_int]/2)) elif ((proc[detailed_mem_int]<50)); then proc[detailed_mem_int]=$((proc[detailed_mem_int]*2)); fi unset 'proc[detailed_mem_string]' - floating_humanizer -v proc[detailed_mem_string] -B -s 1 "$(ps -o rss:1 --no-headers -p ${pid} || true)" + read -r mem_string < <(ps -o rss:1 --no-headers -p ${pid} || true) + floating_humanizer -v proc[detailed_mem_string] -B -s 1 $mem_string if [[ -z ${proc[detailed_mem_string]} ]]; then proc[detailed_mem_string]="? Byte"; fi fi @@ -1888,9 +1894,13 @@ collect_processes() { #? Collect process information and calculate accurate cpu if ((breaking==1)); then if [[ ${proc[detailed]} == "1" && -z ${proc[detailed_cpu]} ]] && ps ${proc[detailed_pid]} >/dev/null 2>&1; then readarray ${options} -O ${#proc_array[@]} proc_array < <(ps -o pid:${proc[pid_len]}=Pid:,comm:${format_cmd}=${tree:-Program:}${format_args},nlwp:3=Tr:,euser:6=User:,pmem=Mem%,pcpu:10=Cpu% --no-headers -p ${proc[detailed_pid]} || true) + ((++breaking)) else break fi + elif ((breaking==2)); then + unset 'proc_array[-1]' + break fi done From 8bc6b00b8de2413b046baefbc6d4786677f1e8e5 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Wed, 6 May 2020 20:47:40 +0200 Subject: [PATCH 21/30] Updated TODO --- README.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ca668aa..a514737 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,12 @@ * [Themes](#themes) * [Upcoming](#upcoming) (Updated, Python port) * [Support and funding](#support-and-funding) -* [Compatibility](#compatibility) (Updated) -* [Dependencies](#dependencies) (Updated) +* [Compatibility](#compatibility) +* [Dependencies](#dependencies) * [Screenshots](#screenshots) * [Installation](#installation) (Updated) -* [Configurability](#configurability) (Updated) -* [TODO](#todo) +* [Configurability](#configurability) +* [TODO](#todo) (Updated) * [License](#license) ## Changelog @@ -281,18 +281,24 @@ USAGE: bashtop 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 for Mac OSX and *BSD: Currently in testing, bashtop-psutil branch. +- [ ] Fix cross platform compatibility for Mac OSX and *BSD: Currently in testing. - [x] Add support for showing AMD cpu temperatures. - [x] Add option to show tree view of processes. - [x] Add option to reset network download/upload totals. - [x] Add option to turn of gradient in processes list. - [ ] Add gpu temp and usage. (If feasible) - [x] Add io stats for disks. +- [ ] Add cpu and mem stats for docker containers. (If feasible) +- [ ] Change process list to line scroll instead of page change. +- [ ] Add option for custom color gradient in process list in theme settings. +- [ ] Add optional window for tailing log files. - [ ] Add options for resizing all boxes. - [ ] Add command line argument parsing. - [ ] Miscellaneous optimizations and code cleanup. - [ ] Add more commenting where it's sparse. +- [ ] Python port. + ## LICENSE [Apache License 2.0](LICENSE) From e68e99b8c0dbc5648e6fe822864ecce7135a2e71 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Wed, 6 May 2020 20:48:48 +0200 Subject: [PATCH 22/30] v0.8.26 Fixes and optimizations --- CHANGELOG.md | 6 ++++++ bashtop | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eac20bb..6abecef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v0.8.26 + +* Fixed: Escaped delimter for sed to fix config not saving "/" character +* Fixed: Detailed process view missing info and slowdown in certain cases +* Optimization: Fork cleanup + ## v0.8.25 * Fixed: Backspace not registering when not set to send ascii delete diff --git a/bashtop b/bashtop index c78797f..ef3cda6 100755 --- a/bashtop +++ b/bashtop @@ -64,7 +64,7 @@ banner=( "██╔══██╗██╔══██║╚════██║██╔══██║ ██║ ██║ ██║██╔═══╝ " "██████╔╝██║ ██║███████║██║ ██║ ██║ ╚██████╔╝██║ " "╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ") -declare version="0.8.25" +declare version="0.8.26" declare banner_width=${#banner[0]} banner_colors=("#E62525" "#CD2121" "#B31D1D" "#9A1919" "#801414") From a236beeb1ee1e8682b937af6ea8bf349b9f429a7 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Thu, 7 May 2020 18:23:17 +0200 Subject: [PATCH 23/30] Added --- .editorconfig | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d83c28c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,7 @@ +[*.{sh,md,cfg,sample}] +indent_style = tab +indent_size = 4 + +[bashtop] +indent_style = tab +indent_size = 4 \ No newline at end of file From fbe585f59a8383f4d9e8310ed466d4ebdcf79b86 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Thu, 7 May 2020 19:45:06 +0200 Subject: [PATCH 24/30] Added --- CODE_OF_CONDUCT.md | 76 ++++++++++++++++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 49 ++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..4ef2c68 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at admin@qvantnet.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..dc16da3 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,49 @@ +# Contributing guidelines + +## When submitting pull requests + +* Explain your thinking in why a change or addition is needed. + * Is it a requested change or feature? + * If not, open a feature request to get feedback before making a pull request. + +* Split up multiple unrelated changes in multiple pull requests. + +* [Shellcheck](https://github.com/koalaman/shellcheck) your work. Current shellsheck exeptions at the beginning of [bashtop](bashtop). + +* Purely cosmetic changes won't be accepted without a very good explanation of its value. + * (Some design choices are for better configurability of syntax highlighting.) + +## Formatting + +### Follow the current syntax design + +* Indent type: Tabs + +* Tab size: 4 + +* Use the longer "if, elif, then, else, fi" statements and indent conditionals, loops etc. + +* Use "[[ ]]", "(( ))" for conditions and "$( ), <( )" for command substitution. + +* Create functions instead of repeating blocks of code. + +* Don't stack unrelated blocks of code, leave blank lines for better readability. + +* Comment new code that isn't very obvious in it's function. + +* Name new variables and functions in lower-case and after what purpose they serve. + * (Exception arithmetic with many variables, make sure to comment what's happening instead.) + +## Optimization + +* Avoid forks if possible. + +* Avoid writing to disk if possible. + +* Make sure variables/arrays are cleaned up if not reused. + +* Compare cpu and memory usage with and without your code and look for alternatives if they cause a noticeable negative impact. + +For questions contact Aristocratos at admin@qvantnet.com + +For proposing changes to this document create a [new issue](https://github.com/aristocratos/bashtop/issues/new/choose). \ No newline at end of file From 7e1ab42cf995780734c6b79a84dbb7e9c627688f Mon Sep 17 00:00:00 2001 From: aristocratos Date: Thu, 7 May 2020 19:46:53 +0200 Subject: [PATCH 25/30] Trim white space and fix non tab indents --- bashtop | 64 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/bashtop b/bashtop index ef3cda6..67ee709 100755 --- a/bashtop +++ b/bashtop @@ -203,11 +203,11 @@ if [[ -n $EPOCHREALTIME ]]; then #* If not, use date command, through fifo if possible else tmpdir="" - if [[ -n $XDG_RUNTIME_DIR && -w "$XDG_RUNTIME_DIR" ]]; then + if [[ -n $XDG_RUNTIME_DIR && -w "$XDG_RUNTIME_DIR" ]]; then tmpdir="$XDG_RUNTIME_DIR" - elif [[ -w /dev/shm ]]; then + elif [[ -w /dev/shm ]]; then tmpdir="/dev/shm" - elif [[ -w /tmp ]]; then + elif [[ -w /tmp ]]; then tmpdir="/tmp" fi @@ -216,11 +216,11 @@ else exec 5> >(exec stdbuf -o0 date -f - +%s%3N > "${tmpdir}/bashtop_datefifo" 2>&1) exec 6< "${tmpdir}/bashtop_datefifo" rm "${tmpdir}/bashtop_datefifo" - + get_ms() { #? Set given variable to current epoch millisecond with date command through background fifo local -n ms_out=$1 - echo now >&5 && - read -u 6 ms_out + echo now >&5 && + read -u 6 ms_out } else @@ -646,15 +646,15 @@ sort_array_int() { #? Copy and sort an array of integers from largest to smalles local array=("${in_arr[@]}") #* Start sorting - for ((start_n=0;start_n<=${#array[@]}-1;++start_n)); do - for ((search_n=start_n+1;search_n<=${#array[@]}-1;++search_n)); do - if ((array[start_n]/dev/null); fi # read -rsn3 -t 0.001 key 2>/dev/null || true if [[ -z $key && $esc -eq 1 ]]; then key="escape" elif [[ $esc -eq 1 ]]; then From 52e34b1da913ea2b6043e35ac40985a3b231ad64 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Thu, 7 May 2020 20:10:47 +0200 Subject: [PATCH 26/30] Fixed: Use value for "Inactive"+"MemFree" if "MemAvailable" is missing in /proc/meminfo --- bashtop | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bashtop b/bashtop index 67ee709..9f2e69f 100755 --- a/bashtop +++ b/bashtop @@ -1571,16 +1571,17 @@ collect_mem() { #? Collect memory information from "/proc/meminfo" read -rd '' mem_info 0)); then From 37fb9ea2ba7e829ee3105c4b77aea4e5358f87c7 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Thu, 7 May 2020 20:21:09 +0200 Subject: [PATCH 27/30] Added: Option to toggle update check at start --- bashtop | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/bashtop b/bashtop index 9f2e69f..15a080a 100755 --- a/bashtop +++ b/bashtop @@ -110,6 +110,9 @@ proc_per_core="false" #* Optional filter for shown disks, should be names of mountpoints, "root" replaces "/", separate multiple values with space disks_filter="" +#* Enable check for new version from github.com/aristocratos/bashtop at start +update_check="true" + aaz_config() { : ; } #! Do not remove this line! #? End default variables--------------------------------------------------------------------------------> @@ -146,7 +149,7 @@ declare -a cpu_usage cpu_graph_a cpu_graph_b color_meter color_temp_graph color_ declare -a mem_history swap_history net_history_download net_history_upload mem_graph swap_graph proc_array download_graph upload_graph trace_array declare resized=1 size_error clock tty_width tty_height hex="16#" cpu_p_box swap_on=1 draw_out esc_character boxes_out last_screen clock_out update_string declare -a options_array=("color_theme" "update_ms" "proc_sorting" "check_temp" "draw_clock" "background_update" "custom_cpu_name" "proc_per_core" - "proc_reversed" "proc_gradient" "disks_filter" "net_totals_reset" "error_logging") + "proc_reversed" "proc_gradient" "disks_filter" "net_totals_reset" "update_check" "error_logging") declare -a save_array=(${options_array[*]/net_totals_reset/}) declare -a sorting=( "pid" "program" "arguments" "threads" "user" "memory" "cpu lazy" "cpu responsive" "tree" ) declare -a pid_history detail_graph detail_history detail_mem_history @@ -287,7 +290,7 @@ init_() { #? Collect needed information and set options before startig main loop collect_net init #* Check if newer version of bashtop is available from https://github.com/aristocratos/bashtop - if [[ -n $curled ]]; then + if [[ -n $curled && $update_check == "true" ]]; then if ! get_value -v git_version -ss "$(curl -m 2 --raw -r 0-3500 https://raw.githubusercontent.com/aristocratos/bashtop/master/bashtop 2>/dev/null)" -k "version=" -r "[^0-9.]"; then unset git_version; fi fi @@ -3045,6 +3048,12 @@ options_() { #? Shows the options overlay "" "If true and process is multithreaded" "cpu usage can reach over 100%.") + desc_update_check=( "Check for updates." + " " + "Enable check for new version from" + "github.com/aristocratos/bashtop at start." + " " + "True or False.") if [[ -n $pause_screen ]]; then from_menu=1; fi @@ -3222,7 +3231,7 @@ options_() { #? Shows the options overlay if ((net[reset]==1)); then net_totals_reset="Off"; net[reset]=0 else net_totals_reset="On"; net[reset]=1; fi ;; - "check_temp"*|"error_logging"*|"background_update"*|"proc_reversed"*|"proc_gradient"*|"proc_per_core"*) + "check_temp"*|"error_logging"*|"background_update"*|"proc_reversed"*|"proc_gradient"*|"proc_per_core"*|"update_check"*) local -n selected_var=${selected} if [[ ${selected_var} == "true" ]]; then selected_var="false" From e75499302e13fc7cf99f879ddcaf14fac77983c7 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Thu, 7 May 2020 20:22:44 +0200 Subject: [PATCH 28/30] v0.8.27 Small fixes --- CHANGELOG.md | 5 +++++ bashtop | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6abecef..13eaae6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## v0.8.27 + +* Fixed: Use value for "Inactive"+"MemFree" if "MemAvailable" is missing in /proc/meminfo +* Added: Option to toggle update check at start + ## v0.8.26 * Fixed: Escaped delimter for sed to fix config not saving "/" character diff --git a/bashtop b/bashtop index 15a080a..abe949e 100755 --- a/bashtop +++ b/bashtop @@ -64,7 +64,7 @@ banner=( "██╔══██╗██╔══██║╚════██║██╔══██║ ██║ ██║ ██║██╔═══╝ " "██████╔╝██║ ██║███████║██║ ██║ ██║ ╚██████╔╝██║ " "╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ") -declare version="0.8.26" +declare version="0.8.27" declare banner_width=${#banner[0]} banner_colors=("#E62525" "#CD2121" "#B31D1D" "#9A1919" "#801414") From 5a36903e673cc6ba3fac418e77c126aa906cdbae Mon Sep 17 00:00:00 2001 From: aristocratos Date: Thu, 7 May 2020 20:31:16 +0200 Subject: [PATCH 29/30] Added #Documents --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a514737..1626fa5 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ ## Index -* [Changelog](#changelog) +* [Documents](#documents) * [Description](#description) * [Features](#features) * [Themes](#themes) @@ -24,10 +24,14 @@ * [TODO](#todo) (Updated) * [License](#license) -## Changelog +## Documents #### [CHANGELOG.md](CHANGELOG.md) +#### [CONTRIBUTING.md](CONTRIBUTING.md) + +#### [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) + ## Description Resource monitor that shows usage and stats for processor, memory, disks, network and processes. From 9a717a1420235b97d6eab5aea9047bdc6777c9b0 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Thu, 7 May 2020 20:35:08 +0200 Subject: [PATCH 30/30] Spelling... --- CHANGELOG.md | 6 +++--- CONTRIBUTING.md | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13eaae6..d353288 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ ## v0.8.26 -* Fixed: Escaped delimter for sed to fix config not saving "/" character +* Fixed: Escaped delimiter for sed to fix config not saving "/" character * Fixed: Detailed process view missing info and slowdown in certain cases * Optimization: Fork cleanup @@ -15,7 +15,7 @@ * Fixed: Backspace not registering when not set to send ascii delete * Fixed: Broken cpu temperature graph when is value over cpu high temp -* Added: Possibilty to run date through background fifo for bash <5 +* Added: Possibility to run date through background fifo for bash <5 ## v0.8.24 @@ -78,7 +78,7 @@ ## v0.8.15 * Added: deb build script by Jukoo -* Fixed: load avarage and uptime not showing +* Fixed: load average and uptime not showing * Fixed: freeze on reverse process order when showing detailed information * Fixed: single quotes on associative arrays diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dc16da3..6f0fe72 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,7 +8,7 @@ * Split up multiple unrelated changes in multiple pull requests. -* [Shellcheck](https://github.com/koalaman/shellcheck) your work. Current shellsheck exeptions at the beginning of [bashtop](bashtop). +* [Shellcheck](https://github.com/koalaman/shellcheck) your work. Current shellsheck exceptions at the beginning of [bashtop](bashtop). * Purely cosmetic changes won't be accepted without a very good explanation of its value. * (Some design choices are for better configurability of syntax highlighting.) @@ -46,4 +46,4 @@ For questions contact Aristocratos at admin@qvantnet.com -For proposing changes to this document create a [new issue](https://github.com/aristocratos/bashtop/issues/new/choose). \ No newline at end of file +For proposing changes to this document create a [new issue](https://github.com/aristocratos/bashtop/issues/new/choose).