Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

How do I get a thread dump on Linux

Hi, I wonder how I can get a thread dump on Linux without using a worker. I tried to do kill -QUIT spid but nothing returns. I also tried jstack and it seems to be hanging there and nothing returns either. I can use kill -QUIT to get the thread dump of the other Java applications running on the same Linux box though.

Thanks

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=2620]{quote}

asked 2008-09-25 11:46:14 -0500

jye gravatar image

updated 2013-08-08 09:52:00 -0500

jaissefsfex gravatar image
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

Kill -3 pid Should generate a file with the thread dump.

Shay

answered 2008-09-25 17:47:56 -0500

shay hassidim gravatar image
edit flag offensive delete link more
0

Usually Thread dump is printed to the console by the JVM. So when you are starting the space try to redirect the output to a file. Some thing like this

./gsc.sh > outputfilename &

When u run kill Quit it will print the thread dump to the output file

For easy monitoring here is the script which will automatically take the thread dump when CPU goes over some limit.
More info at
http://www.gigaspaces.com/wiki/display/XAP66/TroubleshootingTools

#!/bin/bash

  1. # This script can be used to monitor the GigaSpaces process taking up high CPU.
  2. If the CPU usage reaches the threshold limit this script triggers a Thread dump
  3. for the process that can prove be useful in identifying the thread(s) causing the
  4. High CPU Usage

CPUUSAGE=$1
TIME=$2
if $# -lt 2 ; then
  echo ""
  echo "USAGE: ./tdump.sh <CPU> <TIME>"
  echo ""
  echo " <CPU> - CPU Utilization in percents (%)"
  echo " <TIME> - Time in seconds"
  echo ""
  echo "Example: ./tdump.sh 70 10 "
  exit
fi

pidList1=`ps -eaf|grep com.gigaspaces.start.SystemBoot|grep -v grep| awk '{line = line " " $2} ; END {print line}'`
pidList2=`ps -eaf|grep com.j_spaces.core.client.SpaceFinder|grep -v grep| awk '{line = line " " $2} ; END {print line}'`
pidList="${pidList1} ${pidList2}"
echo "PID's currently active " $pidList

declare -a chk
for curPid in $pidList; do
    chk$curPid=0
done

cpu=0
while 1
do

for curPid in $pidList; do
      str=`ps --pid $curPid --no-headers -o pcpu,rss,pid,cmd| grep java `
      cpu=`echo $str | awk '{print $1}'|cut -d. -f1`
mem=`echo $str | awk '{print $2}'`

if $cpu -gt $CPUUSAGE ; then
         dt=`date`
         echo "* $dt PID= $curPid CPU= $cpu % MEMORY= $mem K"
         chk$curPid=`expr ${chk$curPid} + 1`
      else
         chk$curPid=0
      fi
      if ${chk[$curPid} -ge $TIME ];then
         dt=`date`
         echo "********************************************************************"
         echo "* $dt PID= $curPid CPU= $cpu % MEMORY= $mem K"
         echo "* CPU Threashold breached triggering Thread dump"
         echo "********************************************************************"
         kill -s SIGQUIT $curPid
         chk$curPid=0
      fi
   done
   sleep 1
done

answered 2008-09-25 13:53:14 -0500

venkatg gravatar image
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2008-09-25 11:46:14 -0500

Seen: 2,073 times

Last updated: Sep 25 '08