How to write parsed stream dump format

I create a global exception handling that collects some information before closing in some cases. One of this data is the current dump of the stream. I am doing this with the following code:

ManagementFactory.getThreadMXBean().dumpAllThreads(true, true); 

The problem is to write information to the analyzed format for TDA. Is there a β€œsimple” way to format information, and not to record the format?

EDIT: I would like to have a full thread dump to find the problem flows. The above method provides an array of ThreadInfo-Objects, so I have data. My problem is that the recorded output is not in a format that TDA recognizes as a stream dump.

+4
source share
3 answers

If you do not want to copy the TDA code (after all, this is the LGPL), you can also use the Attach API to retrieve data in a standard format. As far as I know, the only built-in JVM code for dumping is Attach's own agent code.

 String selfName = ManagementFactory.getRuntimeMXBean().getName(); final int selfPid = Integer.valueOf(selfName.substring(0, selfName.indexOf('@'))); HotSpotVirtualMachine vm = (HotSpotVirtualMachine) VirtualMachine.attach(Integer.toString(selfPid)); InputStream sDump = vm.remoteDataDump(new Object[]{"-l"}); // lowercase L for lock dump 

A data dump will return a dump to the character data stream.

+3
source

Just use the code that TDA uses itself to dump JMX data: MBeanDumper.java

+1
source

If you are in windows, then bwithers describes how to pass the JVM to a dump stream.

There is also a pure java approach , but I'm not sure if the output is in a standard format.

0
source

Source: https://habr.com/ru/post/1304237/


All Articles