taking weblogic thread dumps prstat and pstack weblogic@sureshsvn.com

AdminZone

Home| Blog |

Taking weblogic thread dumps

small logo

Thread Dump will be printed to the servers standard out (by default, the shell in which the server is running)

On Windows machine:

cltr + break

On Unix Machine:

get pid using ps -ef grep java
kill -3 (process id)

When weblogic is running as windows service

For Out file add in JAVA_OPTIONS:
-Dweblogic.Stdout=

Using beasvc :

beasvc –dump – svcname:”bea Admin_server”

Using Weblogic Admin utility

C:\bea\user_projects\domains\rDomain>java weblogic.Admin -url t3://localhost:7001
-username weblogic -password weblogic THREAD_DUMP

Collecting thread dumps from the console:

Server > Monitoring > Threads > Dump Thread Stacks

Using WLST:

java weblogic.WLST
connect("weblogic","weblogic","t3:\\localhost:7001")
threadDump()


Script to take thread dump prstat and pstack.

#
# Takes an argument (PID of the WLS process) and loops three times.
# This will append the prstat information to a file called dump_high_cpu.txt.
# The thread dump information will either be in file where stdout was redirected or printed on the screen.
#
 
if test $# -eq 0
then
    echo "usage: $0 <processID>";
else
 
                for loopnum in 1 2 3
                do
                        echo `date`
                        CURDATIME=`date '+%y%m%d_%H%M%S'`
                        echo $CURDATIME
                   prstat -L -p $1 1 1 >> ~/export/home/username/`hostname`_${CURDATIME}_$1.out
                   pstack $1  >> ~/export/home/username/`hostname`_${CURDATIME}_$1.out
                   kill -3  $1
                   echo "prstat, pstack, and thread dump done. #" $loopnum
                   sleep 1
                   echo "Done sleeping."
                done
fi
 

Thread states are R - Runnable, S - Suspended, CW- Conditional Wait, MW - Monitor wait.

 

Tools to analyze thread dumps (downloads)

1. Samurai

2. Thread dump analyzer.

We need to look into quite a few parameters from the collected dump information. From prstat output we can get the LWP numbes and the corresponding cpu utilization of all of them.

We can convert the LWP number from prstat to nid (hexadecimal value by using nawk or something similar)

From the thread dump we can see the nid and look into the stack trace.

In pstack output we can see the native stack of the lwp (from prstat output) or search for the tid from the thread dump. From the corresponding stack, look for the program counter number and map it to pmap output.

 

For questions or comments mail svn@sureshsvn.com