How to get thread dump for WebLogic server? - weblogic

Hi
How do I get thread dump for WebLogic server?
I have cases of thread locking up happening a number of times.

There are many ways to do that.
Send a SIGQUIT, either via CTRL + \ (CTRL + Break on Windows) or with a kill -3 <pid>
Use jstack <pid> (or jstack -F <pid> if the process is hung)
Use VisualVM
Use WLST and threadDump()
The first option has usually my preference. If you need to script some kind of monitoring tool, WLST is extremely powerful.

For IBM Java VM:
Set environment variable 'IBM_HEAPDUMP=true' and restart managed web server ..next time when generate the Thread dump (kill -3) , the heap dump will be also generated.

Related

How to test throughput of application using rabbitmq?

I have application that uses rabbitmq to queue messages for other parts of ecosystem. I would like to do some performance testing and tuning, but just on my part (the program). So I guess I would like to somehow "mock" away the rabbitmq server, but without changes to my application.
Is there something like dummy rabbitmq server that just accepts all messages and throws them away immediately? Or can I configure actual rabbitmq in that way?
I was using local docker image for the performance test. You can run it with the command:
docker run -d -p 8081:15672 rabbitmq:3-management
You can access management gui on localhost:8081, default username and password is guest/guest
After you are done running a performance test you can purge queue. You do that in Queues>your queue>Purge
PS: Port can be anything you want, just change 8081 in the docker command :)

Error generating thread dump from console in weblogic

I am trying to generate thread dump from weblogic console(Server-> -> Monitoring -> Threads -> Dump Thread Stacks.
I am getting below message: Server must be running before thread stacks can be displayed.
But, when I try to generate thread dump using kill -3 <PID>, it gets generated.
OS: Centos
Weblogic: WebLogic Server Version: 10.3.6.0
Can anyone please help me in understanding, why thread dump does not get generated from console and Why I am getting the message saying server must be running.
NOTE: Server is in running state.
As you are executing the Thread Dump command from Console, there might be an issue with AdminServer and managed server communication.
Console uses WLST to capture Thread Dumps and before generating thread dumps it will check Managed Server status. May be Admin Server unable to get current state of Managed Server hence you're seeing the error.
Recommended way to take Thread Dumps is OS command (kill -3 ) and from JDK tools, jstack for hostpot and jrcmd for JRockit. Thread Dumps taken from Console might not have lock related information and it might get truncated if thread dump is too long
I guess you was using JDK 7. It is a kind of bug in WLS 10.3.6.0 when using JDK 7. You can either downgrade the JDK to JDK 6 or patch the weblogic.

trying to view stack of unresponsive JVM : both jvisualvm and jconsole fail to connect

I have a Java program on my local machine that becomes unresponsive after sometime and appears to freeze without making further progress. I guess it blocks somewhere (it is accessing remote resources over both HTTP and JDBC so a blocking situation is likely). I am trying to connect to it to see a view of the main thread's stack so as to understand where the block occurred. Both jvisualvm and jconsole list the JVM in question (among others running in my system) but both fail to connect.
jconsole balks with "connection failed" (even when I try the insecure option).
jvisualvm appears to connect but when I hit the 'sampler' tab to see the stack it complains with the screenshot below:
The thing is I am using the same utilities (jconsole and jvisualvm) to connect to other JVMs in my system which I have invoked without using any of the JMX options mentioned in this answer and I don't have any issues. How can I get the stack of this unresponsive JVM to see where it blocks?
I faced a similar issue today with a JVM that was completely stuck and I was unable to properly attach jconsole/jvisualvm to it. Also kill -3 <PID> was unsuccessful (no Thread dump).
I was able to trigger a coredump of the JVM using kill -11 <PID> and feed that into jstack as follows: jstack /path/to/java /path/to/core.file. From the jstack output I was able to extract some useful stack information.
You could just collect a thread dump with kill -3 <PID>.
This will show you all the threads and where they are blocked.

Remotely start stop jboss server

I have a requirement to write a java program to remotely start stop a jboss server on request. Can anyone please suggest how could it be done? One option could be invoke start/stop script but this java program(may be servlet or jsp) exists on different machine. We are using jboss server 7.
A simple method to start and stopping Jboss remotely can be done with the run.sh and shutdown.sh script, by pointing to the right host and port. If you are on Linux you can run:
rsh user#host /path/to/jboss/bin/run.sh
rsh user#host /path/to/jboss/bin/shutdown.sh
You can also execute a Shell command with Java, you can use Runtime exec mewthod:
Runtime.getRuntime().exec("shell command here");
See this complete answer for more details on Java exec method.
A better alternative I would suggest, is to use JMX-console programmatically, you can stop/restart a Jboss intance by invoking the shutdown method on the Server MBean. JMX approach is more powerful because you can monitor and manage every aspect of the Jboss runinng instanace (like logging, memory or cpu). See this to start.
I've created a snippet to ease your start, see this working solution http://snipt.org/Ahhjh4
Remember:
create a Jboss user on the Jboss instance using add-user.sh (JBOSS_HOME/bin)
include the jboss-client.jar in your client class-path (the jar is in JBOSS_HOME/bin/client)
Good luck!

How to start process over ssh that doesn't terminate when session ends?

Is there a way to start a process using ssh that doesn't terminate when the ssh session terminates? I want the job to keep running on the computer I'm ssh-ing into without me having to keep the connection open.
you can use nohup (assuming you are SSHing into *nix server)
You could use the screen utility.
An alternative to screen is dtach. dtach is smaller and more lightweight - in fact it is just the detach part of the screen utility.