Script for capturing a series of thread dumps from a Java process using jstack (on Linux and Windows)
APACHE-2.0 License
Bash jstack script for capturing a series of thread dumps from a Java process on Linux.
Just run it like this:
sudo -u java-process-user-id sh jstackSeries.sh pid [[count] delay]
For example:
sudo -u javauser sh jstackSeries.sh 1234 10 3
Note:
Bash jstack script for capturing a series of thread dumps from an Adobe Experience Manager Java process on Linux.
Make these modifications to the script:
Just run it like this:
sudo -u aem-process-user-id sh jstackSeriesAEM.sh [[count] delay]
For example:
sudo -u aemuser sh jstackSeriesAEM.sh 10 3
Note:
NOTE - Makes the assumption that jstack is on the Windows Environmental Variables PATH
Command:
jstackSeries_powershell.ps1 <pid> <num_threads> <time_between_threads_seconds>
Provide the script the location of jstack.exe via one of the following methods:
The "TOP" output is not similar to the Linux top output and there's some things to understand.
Regular expressions to match "long" running threads.
CPUTime \(Sec\) : ([0-9]{2,}\.[0-9]{1,})
CPUTime \(Sec\) : ([0-9]{3,}\.[0-9]{1,})
A TimeSpan that indicates the amount of time that the associated process has spent utilizing the CPU. This value is the sum of the UserProcessorTime and the PrivilegedProcessorTime.
User CPUTime (%)
A TimeSpan that indicates the amount of time that the associated process has spent running code inside the application portion of the process (not inside the operating system core).
System CPUTime (%)
A TimeSpan that indicates the amount of time that the process has spent running code inside the operating system core.