Can the Thread Dump feature be run from the CA APM Command Line Workstation (CLW)

Document ID : KB000048663
Last Modified Date : 20/07/2018
Show Technical Document Details
Introduction:

The Command Line Workstation (CLW) threaddump option was originally available when thread dump creation was added in version 9.1.x but at that time it was not formally documented because it was unsupported. Although it is now fully supported and documented in the latest this KB remains published as an additional source of this information.

Question:

Can the Thread Dump feature be run from the CA APM Command Line Workstation?

Environment:
APM 9.x, 10.x
Answer:

There are 2 options when running the command to collect a new threaddump file for the agent:

  • get ThreadDump for the agent matching [REGULAR EXPRESSION] for performance
  • get ThreadDump for the agent matching [REGULAR EXPRESSION] for functional
    If the user does not want the text format thread dump to be sent back to the CLW client then the "for performance" option should be used (lesser overhead to EM). Otherwise use the "for functional" option should be used. For both cases the thread dump is persisted on the EM. The [REGULAR EXPRESSION] in this command must match the Agent Name. 
In the example below a Tomcat agent with metric name "*SuperDomain*|HostName|Tomcat|Tomcat Agent" is used:

java -Xmx128M -Duser=admin -Dpassword= -Dhost=EM_host -Dport=EM_port -jar "EM_HOME/lib/CLWorkstation.jar" get ThreadDump for the agent matching ".*HostName\|Tomcat\|Tomcat Agent.*" for functional > clw_threaddump.out 2>&1

If the thread dump creation has been successful the file clw_threaddump.out will show this type of output:
.*HostName\|Tomcat\|Tomcat Agent.*emConnection=available
TD enable on EM = true
TD enable onTomcat Agent = true
SUCCEESS
"main" Id=1 RUNNABLE (in native)
    at java.net.DualStackPlainSocketImpl.accept0(Native Method)
...


NOTE:
If only the first line is visible then a match to the specified regex for the agent name has not been successful i.e.
.*HostName\|Tomcat\|Tomcat Agent.*emConnection=available
Additional Information:
Documentation page for latest APM 10.7 version:
https://docops.ca.com/ca-apm/10-7/en/implementing-agents/java-agent/configure-java-monitoring/configure-thread-dumps

1. By default the thread dump file will be created in the folder <EM_HOME>/threaddumps, where EM_HOME is the home directory of the Collector for the relevant agent.

2. The text format thread dump returned to the CLW client will have the stack truncated if there are more than 10 elements (this is non-configurable) and this is the same result as when saving the thread dump from the Workstation Investigator UI using option "Save as Text button"

3. To see the full thread dump stack requires loading it into the Workstation Investigator UI and viewing with any other external thread analysis tool will likely result in errors.

4. To retrieve the list of already collected threaddump file names use the command: 
get List of ThreadDump filenames for the agent matching [REGULAR EXPRESSION]
For example:  
java -Xmx128M -Duser=admin -Dpassword= -Dhost=EM_host -Dport=EM_port -jar "EM_HOME/lib/CLWorkstation.jar" get List of ThreadDump filenames for the agent matching ".*HostName\|Tomcat\|Tomcat Agent.*"
The output will show:
.*HostName\|Tomcat\|Tomcat Agent.*emConnection=available
TD enable on EM = true
TD enable onTomcat Agent = true
HostName_Tomcat_Tomcat_Agent_TD_1531962786959

5. Per the usual CLW usage the command can also be included as part of shell\batch file and subsequently invoked via Shell Command Action for any required alert.