Mapping Java Thread ID to the hex id of a stacktrace

java Add comments

So you generated a stacktrace and also identified the thread which is causing you so much pain but don’t know how to map one to the other? Do it like this:

Find the PID of the java process:

host:/service/activemq/log/main# ps -ef|grep activemq
activemq 24380 20411  0 Mar25 ?        00:02:56 /usr/bin/java -Xmx512M -Dorg.apache.activemq.UseDedicatedTaskRunner=true -Dcom.sun.management.jmxremote -Dactivemq.classpath=/usr/local/activemq/conf; -Dactivemq.home=/usr/local/activemq -Dactivemq.base=/usr/local/activemq -jar /usr/local/activemq/bin/run.jar start

Sort the java threads by consumed CPU time:

host:/service/activemq/log/main# ps -T -p 24380 -o pid,tid,pri,time | grep -v '00:00:00'
PID   TID PRI     TIME
24380 24380  15 00:00:05
24380 24389 24 00:02:37
24380 24407  24 00:00:01

Convert the Thread ID to hex format:

host:/service/activemq/log/main# printf "%X\n" 24389
5F45

Search for the Thread ID (in hex format) in your log:

host:/service/activemq/log/main# grep 5f45 current
@4000000049ceb85c022cfbe4 "VM Thread" prio=1 tid=0x0809b778 nid=0x5f45 runnable

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in