Thursday, April 25, 2013

Taking Thread Dump

Different ways to take weblogic thread dumps


To read thread, thread dump concept read my this post - Thread and Thread Dump
Make sure to take multiple thread dumps withing a short period of time, for example at least 4 to 6 times with a 5 to 20 seconds of interval

Method - 1


Window:   


Press control+break on the console window where you server instance is running



Linux/Unix based systems 

First, find out the process id of the your server 

ps -ef|grep -i java 

OR

ps -ef | grep -i <your_server_name>
Identify the process id and kill the process with 

kill -3 <PID>

( make sure to this command at least by 4 to 6 times )
Now you will get the thread dump on yout standard output logs file.
Method - 2 
Using weblogic.Admin utility, it's deprecated but still available for you to use.
To take thread dump of admin server running on port 7001

java weblogic.Admin -url t3://Admin_Server_Host:7001 -username weblogic -password weblogic THREAD_DUMP
To take thread dump of manages server  running on port 7002

java weblogic.Admin -url t3://Managed_Server_Host:7002 -username weblogic -password weblogic THREAD_DUMP


Thread dump will go to the standard out file. you can enable"RedirectStdoutToServerLogEnabled" option if you want to see thread dump on same screen where you are running weblogic.admin utility. or if you want thread dump to go to server log then add -Dweblogic.log.RedirectStdoutToServerLogEnabled=true option in you startup script or from the console ( under server > "server startup" option )


Further, you can use below command to read thread dump from log file

java weblogic.Admin -url t3://Managed_Server_Host:Managed_Server_Port -username weblogic -password weblogic SERVERLOG
Method - 3
Using WLST

Connect with WLST
run setDomainEnv.[sh][cmd]
java weblogic.WLST

At WLST prompt - 
# connect with admin serverconnect(‘weblogic’,'webl0gic’,'t3://localhost:7001′)
cd (”Servers’)
ls()
#go inside particular server for which you want to generate thread dump
cd (‘MS1’)
ls()
threadDump()
Method - 4 
To take it from console

Login to AdminConsole—>Server —> Monitoring —> Threads
Using jrockit mission control

Weblogic Mission Control Diagnostic Command : jrcmd


JRCMD

jrcmd is a command-line tool included with the JRockit JDK that you can use to send diagnostic commands to a running JVM process. jrcmd communicates with the JVM by using the JDK attach mechanism.

jrcmd <jrockit pid> [<command> [<arguments>]] [-l] [-f file] [-p] -h]

  1. <jrockit pid>
  2.  is either the process ID or the name of the Main class that runs the application.
  3. [<command> [<arguments>]] is any diagnostic command and its associated arguments; for example, versionprint_propertiescommand_line.
  4. -l displays the counters exposed by this process.
  5. -f reads and executes commands from the file.
  6. -p lists JRockit JVM processes on the local machine.
  7. -h displays help.
If the PID is 0, commands will be sent to all Jrockit JVM processes. 

If no options are given, the default is -p


List all JRockit JVM processes running on the machine

Run jrcmd or jrcmd -p to list the running JRockit JVMs

Example:

C:\Oracle\Middleware2\jrockit_160_24_D1.1.2-4\bin>jrcmd -p -version

5932 jrockit.tools.jrcmd.JrCmd -p -version
760 weblogic.Server


Print heap diagnostic 

./JROCKIT_HOME/bin/jrcmd PID heap_diagnostics 
 
 
 
Prints out a report on the JVM's native memory allocation on the C-Heap

./JROCKIT_HOME/bin/jrcmd PID heapreport 

( applicable for R27.x release only )


Prints out a comprehensive summary of garbage collection activity so far during the run

./JROCKIT_HOME/bin/jrcmd PID gcreport

( applicable for R27.x release only )


Take thread dumps


./JROCKIT_HOME/bin/jrcmd PID print_threads

 
Keywords : weblogic taking thread dump, thread dumps, how to take thread dumps in weblogic, taking thread dumps weblogic


Print Memory Usage

./JROCKIT_HOME/bin/jrcmd PID print_memusage

 
 

No comments: