mirror of https://github.com/aristocratos/bashtop
Added: Reset network totals in options menu
parent
b80162c026
commit
efbc20baff
25
bashtop
25
bashtop
|
@ -143,7 +143,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 -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 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_reversed" "proc_gradient" "disks_filter" "error_logging")
|
"proc_reversed" "proc_gradient" "disks_filter" "net_totals_reset" "error_logging")
|
||||||
declare -a save_array=("${options_array[@]}" "proc_reversed")
|
declare -a save_array=("${options_array[@]}" "proc_reversed")
|
||||||
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" )
|
||||||
declare -a pid_history detail_graph detail_history detail_mem_history
|
declare -a pid_history detail_graph detail_history detail_mem_history
|
||||||
|
@ -1361,7 +1361,7 @@ collect_cpu() { #? Collects cpu stats from /proc/stat and compares with previous
|
||||||
cpu[new_${thread}]=$((stat_array[1]+stat_array[2]+stat_array[3]+stat_array[4]))
|
cpu[new_${thread}]=$((stat_array[1]+stat_array[2]+stat_array[3]+stat_array[4]))
|
||||||
cpu[idle_new_${thread}]=${stat_array[4]}
|
cpu[idle_new_${thread}]=${stat_array[4]}
|
||||||
if [[ -n ${cpu[old_${thread}]} && -n ${cpu[idle_new_${thread}]} && ${cpu[old_${thread}]} -ne ${cpu[new_${thread}]} ]]; then
|
if [[ -n ${cpu[old_${thread}]} && -n ${cpu[idle_new_${thread}]} && ${cpu[old_${thread}]} -ne ${cpu[new_${thread}]} ]]; then
|
||||||
cpu_usage[${thread}]=$(( ( 100*(${cpu[old_${thread}]}-${cpu[new_${thread}]}-${cpu[idle_old_${thread}]}+${cpu[idle_new_${thread}]}) ) / (${cpu[old_${thread}]}-${cpu[new_${thread}]}) ))
|
cpu_usage[${thread}]="$(( ( 100*(${cpu[old_${thread}]}-${cpu[new_${thread}]}-${cpu[idle_old_${thread}]}+${cpu[idle_new_${thread}]}) ) / (${cpu[old_${thread}]}-${cpu[new_${thread}]}) ))"
|
||||||
fi
|
fi
|
||||||
cpu[old_${thread}]=${cpu[new_${thread}]}
|
cpu[old_${thread}]=${cpu[new_${thread}]}
|
||||||
cpu[idle_old_${thread}]=${cpu[idle_new_${thread}]}
|
cpu[idle_old_${thread}]=${cpu[idle_new_${thread}]}
|
||||||
|
@ -1843,7 +1843,10 @@ collect_net() { #? Collect information from "/proc/net/dev"
|
||||||
|
|
||||||
if [[ -n ${net[old_${direction}]} ]]; then
|
if [[ -n ${net[old_${direction}]} ]]; then
|
||||||
#* Get total, convert to floating point and format string to best fitting unit in Bytes
|
#* Get total, convert to floating point and format string to best fitting unit in Bytes
|
||||||
floating_humanizer -Byte -v net[total_${direction}] ${net[new_${direction}]}
|
if ((net[reset]==1)) && [[ -z ${net[total_offset_${direction}]} ]]; then net[total_offset_${direction}]=${net[new_${direction}]}
|
||||||
|
elif ((net[reset]==0)) && [[ -n ${net[total_offset_${direction}]} ]]; then unset "net[total_offset_${direction}]"; fi
|
||||||
|
|
||||||
|
floating_humanizer -Byte -v net[total_${direction}] $((${net[new_${direction}]}-${net[total_offset_${direction}]:-0}))
|
||||||
|
|
||||||
#* Calculate current speeds: ("New value" - "Old value") * 1000(for ms to seconds) / ("new_timestamp" - "old_timestamp")
|
#* Calculate current speeds: ("New value" - "Old value") * 1000(for ms to seconds) / ("new_timestamp" - "old_timestamp")
|
||||||
net[speed_${direction}]=$(( (${net[new_${direction}]}-${net[old_${direction}]})*1000/(net[new_timestamp]-net[old_timestamp]) ))
|
net[speed_${direction}]=$(( (${net[new_${direction}]}-${net[old_${direction}]})*1000/(net[new_timestamp]-net[old_timestamp]) ))
|
||||||
|
@ -2810,7 +2813,9 @@ help_() { #? Shows the help overlay
|
||||||
|
|
||||||
options_() { #? Shows the options overlay
|
options_() { #? Shows the options overlay
|
||||||
local keypress from_menu col line y=1 i=1 options_out selected_int=0 ypos option_string options_misc option_value bg fg skipped start_t end_t left_t changed_cpu_name theme_int=0 page=1 pages height
|
local keypress from_menu col line y=1 i=1 options_out selected_int=0 ypos option_string options_misc option_value bg fg skipped start_t end_t left_t changed_cpu_name theme_int=0 page=1 pages height
|
||||||
local desc_col right left enter lr inp valid updated_ms local_rez redraw_misc=1 desc_pos desc_height options_pause updated_proc inputting inputting_value inputting_key file theme_check
|
local desc_col right left enter lr inp valid updated_ms local_rez redraw_misc=1 desc_pos desc_height options_pause updated_proc inputting inputting_value inputting_key file theme_check net_totals_reset
|
||||||
|
|
||||||
|
if ((net[reset]==1)); then net_totals_reset="On"; else net_totals_reset="Off"; fi
|
||||||
|
|
||||||
#* Check theme folder for theme files
|
#* Check theme folder for theme files
|
||||||
get_themes
|
get_themes
|
||||||
|
@ -2885,6 +2890,11 @@ options_() { #? Shows the options overlay
|
||||||
" "
|
" "
|
||||||
"Separate multiple values with space."
|
"Separate multiple values with space."
|
||||||
"Example: \"root home external\"")
|
"Example: \"root home external\"")
|
||||||
|
desc_net_totals_reset=("Press ENTER to toggle network upload"
|
||||||
|
"and download totals reset."
|
||||||
|
" "
|
||||||
|
"Shows totals since system start or"
|
||||||
|
"network adapter reset when Off.")
|
||||||
|
|
||||||
if [[ -n $pause_screen ]]; then from_menu=1; fi
|
if [[ -n $pause_screen ]]; then from_menu=1; fi
|
||||||
|
|
||||||
|
@ -3053,7 +3063,11 @@ options_() { #? Shows the options overlay
|
||||||
"disks_filter enter")
|
"disks_filter enter")
|
||||||
if [[ -z $inputting ]]; then inputting=1; inputting_value="${disks_filter}"
|
if [[ -z $inputting ]]; then inputting=1; inputting_value="${disks_filter}"
|
||||||
else disks_filter="${inputting_value}"; mem[counter]=10; resized=1; unset inputting inputting_value; fi
|
else disks_filter="${inputting_value}"; mem[counter]=10; resized=1; unset inputting inputting_value; fi
|
||||||
;;
|
;;
|
||||||
|
"net_totals_reset enter")
|
||||||
|
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"*)
|
||||||
local -n selected_var=${selected}
|
local -n selected_var=${selected}
|
||||||
if [[ ${selected_var} == "true" ]]; then
|
if [[ ${selected_var} == "true" ]]; then
|
||||||
|
@ -3099,6 +3113,7 @@ options_() { #? Shows the options overlay
|
||||||
"draw_clock"*|"custom_cpu_name"*|"disks_filter"*)
|
"draw_clock"*|"custom_cpu_name"*|"disks_filter"*)
|
||||||
inputting_value+="${keypress//[\\\$\"\']/}"
|
inputting_value+="${keypress//[\\\$\"\']/}"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue