How to start sampling and tracing?

Questions about YourKit Java Profiler
Post Reply
lujhuang
Posts: 5
Joined: Tue May 17, 2005 11:29 pm

How to start sampling and tracing?

Post by lujhuang »

Hi,

I installed yjp 4.0.11 on a Linux server and tried to profile the jboss 4.0.2 server. But after the 'Tools'--'Integrate with a J2EE server', which (only) generated a server startup script, I looked at the generated script, it only added lines that setup LD_LIBRARY_PATH and JAVA_TOOL_OPTIONS. But how do I start sampling or tracing? What are the next steps? Please help.
lujhuang
Posts: 5
Joined: Tue May 17, 2005 11:29 pm

run_with_yjp.sh- added LD_LIBRARY_PATH and JAVA_TOOL_OPTIONS

Post by lujhuang »

#!/bin/sh
### ====================================================================== ###
## ##
## JBoss Bootstrap Script ##
## ##
### ====================================================================== ###
# Generated with YourKit Java Profiler 4.0.11

LD_LIBRARY_PATH="/root/PACKAGES/yjp-4.0.11/bin/linux:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH
JAVA_TOOL_OPTIONS="-agentlib:yjpagent=sessionname=JBoss $JAVA_TOOL_OPTIONS"
export JAVA_TOOL_OPTIONS

### $Id: run.sh,v 1.19.4.2 2004/12/15 16:54:03 starksm Exp $ ###

DIRNAME=`dirname $0`
PROGNAME=`basename $0`
GREP="grep"

# Use the maximum available, or set MAX_FD != -1 to use that
MAX_FD="maximum"

#
# Helper to complain.
#
warn() {
echo "${PROGNAME}: $*"
}

#
# Helper to puke.
#
die() {
warn $*
exit 1
}

# OS specific support (must be 'true' or 'false').
cygwin=false;
darwin=false;
case "`uname`" in
CYGWIN*)
cygwin=true
;;

Darwin*)
darwin=true
;;
esac

# Read an optional running configuration file
if [ "x$RUN_CONF" = "x" ]; then
RUN_CONF="$DIRNAME/run.conf"
fi
if [ -r "$RUN_CONF" ]; then
. "$RUN_CONF"
fi

# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$JBOSS_HOME" ] &&
JBOSS_HOME=`cygpath --unix "$JBOSS_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$JAVAC_JAR" ] &&
JAVAC_JAR=`cygpath --unix "$JAVAC_JAR"`
fi

# Setup JBOSS_HOME
if [ "x$JBOSS_HOME" = "x" ]; then
# get the full path (without any relative bits)
JBOSS_HOME=`cd $DIRNAME/..; pwd`
fi
export JBOSS_HOME

# Increase the maximum file descriptors if we can
if [ "$cygwin" = "false" ]; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ]; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then
# use the system max
MAX_FD="$MAX_FD_LIMIT"
fi

ulimit -n $MAX_FD
if [ $? -ne 0 ]; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query system maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi

# Setup the JVM
if [ "x$JAVA" = "x" ]; then
if [ "x$JAVA_HOME" != "x" ]; then
JAVA="$JAVA_HOME/bin/java"
else
JAVA="java"
fi
fi

# Setup the classpath
runjar="$JBOSS_HOME/bin/run.jar"
if [ ! -f "$runjar" ]; then
die "Missing required file: $runjar"
fi
JBOSS_BOOT_CLASSPATH="$runjar"

# Include the JDK javac compiler for JSP pages. The default is for a Sun JDK
# compatible distribution which JAVA_HOME points to
if [ "x$JAVAC_JAR" = "x" ]; then
JAVAC_JAR="$JAVA_HOME/lib/tools.jar"




# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
JBOSS_HOME=`cygpath --path --windows "$JBOSS_HOME"`
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
JBOSS_CLASSPATH=`cygpath --path --windows "$JBOSS_CLASSPATH"`
JBOSS_ENDORSED_DIRS=`cygpath --path --windows "$JBOSS_ENDORSED_DIRS"`
fi

# Display our environment
echo "========================================================================="
echo ""
echo " JBoss Bootstrap Environment"
echo ""
echo " JBOSS_HOME: $JBOSS_HOME"
echo ""
echo " JAVA: $JAVA"
echo ""
echo " JAVA_OPTS: $JAVA_OPTS"
echo ""
echo " CLASSPATH: $JBOSS_CLASSPATH"
echo ""
echo "========================================================================="
echo ""

STATUS=10
while [ $STATUS -eq 10 ]
do
# Execute the JVM
"$JAVA" $JAVA_OPTS \
-Djava.endorsed.dirs="$JBOSS_ENDORSED_DIRS" \
-classpath "$JBOSS_CLASSPATH" \
org.jboss.Main "$@"
STATUS=$?
# if it doesn't work, you may want to take a look at this:
# http://developer.java.sun.com/developer ... 65334.html
done
Vladimir Kondratyev
Posts: 1625
Joined: Tue Aug 10, 2004 7:52 pm

Post by Vladimir Kondratyev »

You need to run JBoss server with modified startup script and connect to the running server from profiler UI.
lujhuang
Posts: 5
Joined: Tue May 17, 2005 11:29 pm

Post by lujhuang »

Only the following env variables were set in the run_with_yjp.sh, how does the Jboss server started with JAVA_TOOL_OPTIONS?

LD_LIBRARY_PATH="/root/PACKAGES/yjp-4.0.11/bin/linux:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH
JAVA_TOOL_OPTIONS="-agentlib:yjpagent=sessionname=JBoss $JAVA_TOOL_OPTIONS"
export JAVA_TOOL_OPTIONS

Also, what port number should I use to connect to a remote Jboss server for sampling and tracing?

Thanks.
Vladimir Kondratyev
Posts: 1625
Joined: Tue Aug 10, 2004 7:52 pm

Post by Vladimir Kondratyev »

how does the Jboss server started with JAVA_TOOL_OPTIONS?
These options aren't for JBoss, they ar e for JVM
Also, what port number should I use to connect to a remote Jboss server for sampling and tracing?
Check JBoss log files, and find a message from profiler. The message contains port number. Also you can specify exact port number as "port" option of agent. To learn more how to configure profiling in Java applications, please read bundled help.[/code]
lujhuang
Posts: 5
Joined: Tue May 17, 2005 11:29 pm

Post by lujhuang »

There is no port number from the jboss logs that I can see. Can you give some example? The bundled help doc is very brief on setup. Which specific section are you referring to?
Vladimir Kondratyev
Posts: 1625
Joined: Tue Aug 10, 2004 7:52 pm

Post by Vladimir Kondratyev »

The bundled help doc is very brief on setup. Which specific section are you referring to?
Please take a look at "Enabling profiling manually" topic.

Can you give some example?
At the same topic in Help you'll find several examples.
Post Reply