Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed Mar 8, 2014
1 parent 61f9e0c commit eac7403
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions show-busy-java-threads.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@ printStackOfThread() {
done
}

[ -z "${pid}" ] && {
ps -Leo pid,lwp,user,comm,pcpu --no-headers | awk '$4=="java"{print $0}' |
sort -k5 -r -n | head --lines "${count}" | printStackOfThread
} || {
ps -Leo pid,lwp,user,comm,pcpu --no-headers | awk -v "pid=${pid}" '$1==pid,$4=="java"{print $0}' |
sort -k5 -r -n | head --lines "${count}" | printStackOfThread
}
ps -Leo pid,lwp,user,comm,pcpu --no-headers | {
[ -z "${pid}" ] &&
awk '$4=="java"{print $0}' ||
awk -v "pid=${pid}" '$1==pid,$4=="java"{print $0}'
} | sort -k5 -r -n | head --lines "${count}" | printStackOfThread

0 comments on commit eac7403

Please sign in to comment.