@@ -139,14 +139,14 @@ usage() {
139139 (( $# > 0 )) && colorPrint 31 " $* $NL " >& " $out "
140140
141141 cat >& " $out " << EOF
142- Usage: ${ PROG} [OPTION]... [delay [count]]
142+ Usage: $PROG [OPTION]... [delay [count]]
143143Find out the highest cpu consumed threads of java processes,
144144and print the stack of these threads.
145145
146146Example:
147- ${ PROG} # show busy java threads info
148- ${ PROG} 1 # update every 1 second, (stop by eg: CTRL+C)
149- ${ PROG} 3 10 # update every 3 seconds, update 10 times
147+ $PROG # show busy java threads info
148+ $PROG 1 # update every 1 second, (stop by eg: CTRL+C)
149+ $PROG 3 10 # update every 3 seconds, update 10 times
150150
151151Output control:
152152 -p, --pid <java pid(s)> find out the highest cpu consumed threads from
@@ -215,7 +215,7 @@ ARGS=$(
215215 usage 1
216216}
217217readonly ARGS
218- eval set -- " ${ ARGS} "
218+ eval set -- " $ARGS "
219219
220220count=5
221221cpu_sample_interval=0.5
@@ -525,20 +525,20 @@ printStackOfThreads() {
525525 [ -f " $jstackFile " ] || {
526526 # shellcheck disable=SC2206
527527 local -a jstack_cmd_line=(" $jstack_path " $force $mix_native_frames $lock_info $pid )
528- if [ " $user " == " $USER " ]; then
528+ if [ " $user " = " $USER " ]; then
529529 # run without sudo, when java process user is current user
530530 logAndRun " ${jstack_cmd_line[@]} " > " $jstackFile "
531- elif [ $ UID == 0 ] ; then
531+ elif (( UID == 0 )) ; then
532532 # if java process user is not current user, must run jstack with sudo
533533 logAndRun sudo -u " $user " " ${jstack_cmd_line[@]} " > " $jstackFile "
534534 else
535535 # current user is not root user, so can not run with sudo; print error message and rerun suggestion
536- redOutput " [$idx ] Fail to jstack busy(${ pcpu} %) thread($threadId /$threadId0x ) stack of java process($pid ) under user($user )."
536+ redOutput " [$idx ] Fail to jstack busy($pcpu %) thread($threadId /$threadId0x ) stack of java process($pid ) under user($user )."
537537 redOutput " User of java process($user ) is not current user($USER ), need sudo to rerun:"
538538 yellowOutput " sudo $( printCallingCommandLine) "
539539 continue
540540 fi || {
541- redOutput " [$idx ] Fail to jstack busy(${ pcpu} %) thread(${ threadId} / ${ threadId0x} ) stack of java process(${ pid} ) under user(${ user} )."
541+ redOutput " [$idx ] Fail to jstack busy($pcpu %) thread($threadId / $ threadId0x ) stack of java process($pid ) under user($user )."
542542 rm " $jstackFile " & > /dev/null
543543 continue
544544 }
@@ -582,7 +582,7 @@ main() {
582582 tee ${append_file: +-a " $append_file " } ${store_dir: +-a " $store_file_prefix$PROG " } > /dev/null
583583 (( update_count != 1 )) && headInfo
584584
585- if [ " $cpu_sample_interval " == 0 ]; then
585+ if [ " $cpu_sample_interval " = 0 ]; then
586586 findBusyJavaThreadsByPs
587587 else
588588 findBusyJavaThreadsByTop
0 commit comments