How to take Thread Dump from Weblogic


We checked how to collect thread dump in standard way from OS and now we will try to learn how to collect thread dumps from various Application Server’s and their Utility.



Now we will learn how to take thread dump using Oracle Weblogic Server and it’s Utility.


Now we will learn different Method to take thread dumps from Weblogic Server.


Methods


Weblogic Admin Utility: We can collect Thread dump using “weblogic.Admin” utility which is already a deprecated but still works in current versions of server.
Syntax:

java [ SSL Arguments ] weblogic.Admin 

     [ Connection Arguments ] 

     [ User Credentials Arguments ]

     THREAD_DUMP
Example
The following example causes a server instance that is running on a host named ManagedHost to print a thread dump to standard out:

java weblogic.Admin -url ManagedHost:8001 -username weblogic
-password weblogic THREAD_DUMP
If the command succeeds, the command itself returns the following:
Thread Dump is available in the command window that is running the server.

The server instance prints a thread dump to its standard out, which, by default, is the shell (command prompt) within which the server instance is running.
Eg: 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 )


  Weblogic Scripting Tool (WLST):  We can collect Thread dump using WLST script by using threadDump() command  or executing a simple .py file.  We will see both of them.

Syntax

threadDump([writeToFile], [fileName], [serverName])

writeToFile: Optional. Boolean value specifying whether to save the output to a file. This argument defaults to true, indicating that output is saved to a file.

filename: Optional. Name of the file to which the output is written. The filename can be absolute or relative to the directory where WLST is running. This argument defaults to Thread_Dump_serverNamefile, where serverName indicates the name of the server. This argument is valid only if writeToFile is set to true.

serverName:  Optional. Server name for which the thread dump is requested. This argument defaults to the server to which WLST is connected.If we are connected to an Administration Server, you can display a thread dump for the Administration Server and any Managed Server that is running in the domain. If you are connected to a Managed Server, you can only display a thread dump for that Managed Server.

Example

The following example displays the thread dump for the current server and saves the output to the Thread_Dump_serverName file.
wls:/mydomain/serverConfig> threadDump()
The following example displays the thread dump for the server managedServer. The information is not saved to a file.
wls:/mydomain/serverConfig> threadDump(writeToFile='false', serverName='managedServer')

Second way to write a simple WLST script like “ThreadDump.py” and execute the file directly.

Code:


connect(‘weblogic’,'weblogic1',’t3://localhost:7001')
cd(‘Servers’)
cd(‘AdminServer’)
threadDump()
disconnect()
exit()


Now open a command Shell and then run the “setWLSEnv.sh” or Under domain run following shell command "setDomainEnv.sh"
Then run the WLST script like:

java weblogic.WLST ThreadDump.py
or
java weblogic.WLST /opt/WLS/MyScripts/ThreadDump.py


Thread Dump from Window Services: If your Server is running as windows service, then follow the below steps

Open a command prompt and execute the below command

WL_HOME\bin\beasvc -dump -svcname:service-name

Thread Dump through Admin Console: We can also take thread dump through Admin Console.

Directions:

 Login to AdminConsole—>Server —> Monitoring —> Threads

Then click Dump Thread Stack.



Thread from Weblogic Admin Console


Related Links:




Post a Comment

1 Comments

Emoji
(y)
:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
x-)
(k)