CPU爆表排查脚本

!/bin/bash

JAR=uzone-indonesia-service-api-1.0.0-SNAPSHOT.jar

获取应用进程号

pid=ps -ef | grep $JAR | grep -v grep | awk '{print $2}'
echo pid ]
then
echo "PID is NULL"
exit 1
fi

找到该进程中占用较高的前30个线程号

DATE=date +%Y%m%d%H%M%S
ps -mp {DATE}_mytmp.out

获取线程信息

while read line
do
tid=echo $line | awk '{print $8}'
echo {tid}" = "-" ]
then
echo "this is '-'"
else
echo "TID is :"{DATE}_busy_thread.log
sixteenth=printf "%x" $tid
echo "Transform to 0xxxx is :"{DATE}_busy_thread.log
jstack sixteenth -A 30 >>{DATE}_mytmp.out

echo "Finished!"

你可能感兴趣的:(CPU爆表排查脚本)