Skip to content

Commit

Permalink
support: set count 0 to show all threads
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed Jan 12, 2020
1 parent 943689c commit 273fb91
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bin/show-busy-java-threads
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Output control:
the specified java process.
default from all java process.
-c, --count <num> set the thread count to show, default is 5.
set count 0 to show all threads.
-a, --append-file <file> specifies the file to append output as log.
-S, --store-dir <dir> specifies the directory for storing
the intermediate files, and keep files.
Expand Down Expand Up @@ -306,7 +307,11 @@ findBusyJavaThreadsByPs() {
echo "$ps_out" | logAndCat "${ps_cmd_line[@]}" > "${store_file_prefix}$(( i + 1 ))_ps"
fi

echo "$ps_out" | head -n "${count}"
if (( count > 0 )); then
echo "$ps_out" | head -n "${count}"
else
echo "$ps_out"
fi
}

# top with output field: thread id, %cpu
Expand Down Expand Up @@ -355,7 +360,7 @@ __complete_pid_user_by_ps() {

local idx=0 threadId pcpu
while read threadId pcpu ; do
(( idx < count )) || break
(( count <= 0 || idx < count )) || break

# output field: pid, threadId, pcpu, user
local output_fields="$( echo "$ps_out" |
Expand Down
1 change: 1 addition & 0 deletions docs/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ Output control:
the specified java process.
default from all java process.
-c, --count <num> set the thread count to show, default is 5.
set count 0 to show all threads.
-a, --append-file <file> specifies the file to append output as log.
-S, --store-dir <dir> specifies the directory for storing
the intermediate files, and keep files.
Expand Down

0 comments on commit 273fb91

Please sign in to comment.