From 273fb9131ce9f6a543892fae761d31b427f2ff7f Mon Sep 17 00:00:00 2001 From: Jerry Lee Date: Sun, 12 Jan 2020 19:37:13 +0800 Subject: [PATCH] support: set count 0 to show all threads --- bin/show-busy-java-threads | 9 +++++++-- docs/java.md | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/show-busy-java-threads b/bin/show-busy-java-threads index ffc2394c..6b204989 100755 --- a/bin/show-busy-java-threads +++ b/bin/show-busy-java-threads @@ -102,6 +102,7 @@ Output control: the specified java process. default from all java process. -c, --count set the thread count to show, default is 5. + set count 0 to show all threads. -a, --append-file specifies the file to append output as log. -S, --store-dir specifies the directory for storing the intermediate files, and keep files. @@ -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 @@ -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" | diff --git a/docs/java.md b/docs/java.md index 359dcedf..0676f2bc 100644 --- a/docs/java.md +++ b/docs/java.md @@ -124,6 +124,7 @@ Output control: the specified java process. default from all java process. -c, --count set the thread count to show, default is 5. + set count 0 to show all threads. -a, --append-file specifies the file to append output as log. -S, --store-dir specifies the directory for storing the intermediate files, and keep files.