Skip to content

Commit

Permalink
improve jstack check message
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed Mar 8, 2014
1 parent 18d6380 commit 61f9e0c
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions show-busy-java-threads.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,21 @@ redEcho() {
} || echo "$@"
}

## Check the existence of jstack command!
# Check the existence of jstack command!
if ! which jstack &> /dev/null; then
[ -n "$JAVA_HOME" ] && [ -f "$JAVA_HOME/bin/jstack" ] && [ -x "$JAVA_HOME/bin/jstack" ] && {
export PATH="$JAVA_HOME/bin:$PATH"
} || {
redEcho "Error: jstack not found on PATH and JAVA_HOME!"
[ -z "$JAVA_HOME" ] && {
redEcho "Error: jstack not found on PATH!"
exit 1
}
! [ -f "$JAVA_HOME/bin/jstack" ] && {
redEcho "Error: jstack not found on PATH and $JAVA_HOME/bin/jstack file does NOT exists!"
exit 1
}
! [ -x "$JAVA_HOME/bin/jstack" ] && {
redEcho "Error: jstack not found on PATH and $JAVA_HOME/bin/jstack is NOT executalbe!"
exit 1
}
export PATH="$JAVA_HOME/bin:$PATH"
fi

uuid=`date +%s`_${RANDOM}_$$
Expand Down

0 comments on commit 61f9e0c

Please sign in to comment.