Friday Jan 25, 2008

Capture java thread dump from truss

I've been working with a daemon java process lately and sometimes I don't have a console where the process will write its thread dump when I send a QUIT signal.  Here's a little perl I used to get a readable thread dump from truss..

alias jdump 'kill -QUIT \!* ; truss -wall -p \!* | & perl -ne '\''next unless s|^/\d+:\t  ||;chomp;while($_){print (substr($_,0,1) eq "\\" ? substr($_,1,1) eq "n" ? "\n" : "\t" : substr($_,1,1));$_=substr($_,2)}'\'

jdump {pid} 

Comments:

Nice I will try this , useful!

Posted by 124.125.225.124 on January 25, 2008 at 03:45 PM PST #

Post a Comment:
  • HTML Syntax: NOT allowed