Skip to content

Commit 0438470

Browse files
committed
Fixed process graph creation for process below 0.5%
1 parent b7f13c4 commit 0438470

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

bashtop

+8-8
Original file line numberDiff line numberDiff line change
@@ -2679,7 +2679,7 @@ collect_processes_psutil() {
26792679

26802680
pid_history[${pid}]="1"
26812681

2682-
#* Create small graphs for all visible processes using more than 1% cpu time
2682+
#* Create small graphs for all visible processes using more than 1% rounded cpu time
26832683
pid_graph="pid_${pid}_graph"
26842684
if ! local -n pid_count="pid_${pid}_count" 2>/dev/null; then continue; fi
26852685

@@ -2691,8 +2691,10 @@ collect_processes_psutil() {
26912691
elif [[ ${pid_count} -gt 0 ]]; then
26922692
if [[ ${cpu_int} -gt 9 ]]; then
26932693
create_mini_graph -nc -add-value "pid_${pid}_graph" "$((cpu_int+15))"
2694-
else
2694+
elif [[ ${cpu_int} -gt 0 ]]; then
26952695
create_mini_graph -nc -add-value "pid_${pid}_graph" "$((cpu_int+9))"
2696+
else
2697+
create_mini_graph -nc -add-value "pid_${pid}_graph" "0"
26962698
fi
26972699
pid_count=$((${pid_count}-1))
26982700
elif [[ ${pid_count} == "0" ]]; then
@@ -2766,16 +2768,14 @@ collect_processes_psutil() {
27662768

27672769

27682770

2769-
#* Clear up memory by removing variables and graphs of no longer running processes
2771+
#* Clear up memory
27702772
((++proc[general_counter]))
27712773
if ((proc[general_counter]>100)); then
27722774
proc[general_counter]=0
27732775
for pids in ${!pid_history[@]}; do
2774-
if [[ ! -e /proc/${pids} ]]; then
2775-
unset "pid_${pids}_graph" "pid_${pids}_graph_even" "pid_${pids}_graph_odd" "pid_${pids}_graph_last_type" "pid_${pids}_graph_last_val"
2776-
unset "pid_${pids}_count"
2777-
unset "pid_history[${pids}]"
2778-
fi
2776+
unset "pid_${pids}_graph" "pid_${pids}_graph_even" "pid_${pids}_graph_odd" "pid_${pids}_graph_last_type" "pid_${pids}_graph_last_val"
2777+
unset "pid_${pids}_count"
2778+
unset "pid_history[${pids}]"
27792779
done
27802780
fi
27812781

0 commit comments

Comments
 (0)