Menu

Saturday, 15 May 2021

Scripts for ThreadDump Generation On JBoss & Tomcat

 ###To Capture 6 ThreadDump with 20seconds interval + 6 High CPU Threads output with 20seconds interval.

Step 1: create a file  & write below codes.


#script code "high_cpu_linux_jstack.sh"
************************************************************

#!/bin/sh

JAVA_HOME=/u01/jdk1.8.0_121

# Number of times to collect data.

LOOP=6

# Interval in seconds between data points.

INTERVAL=20

 

for ((i=1; i <= $LOOP; i++))

do

   _now=$(date)

   echo "${_now}" >>high-cpu.out

   top -b -n 1 -H -p $1 >>high-cpu.out

   echo "${_now}" >>high-cpu-tdump.out

  $JAVA_HOME/bin/jstack -l $1 >>high-cpu-tdump.out

   echo "thread dump #" $i

   if [ $i -lt $LOOP ]; then

      echo "Sleeping..."

      sleep $INTERVAL

   fi

done

************************************************************

How to Run the "high_cpu_linux_jstack.sh" script.

./ high_cpu_linux_jstack.sh JVM_PID


Analysis of high_cpu_linux_jstack.sh can be easily done from REDHAT LABS:

Step 1 : GO to Address: https://access.redhat.com/labs/jvmpeg/

 Step 2: DROP your output files for HIGH CPU easy analysis with modifying CPU Threshold.

Snap:-

Thanks :-)


No comments:

Post a Comment