java进程占用CPU资源过高分析脚本

 #!/bin/bash

 #输入占用CPU较高的进程号
pid=$
if [ -z $pid ]
then
echo "PID is NULL"
exit
fi #找到该进程中占用较高的前30个线程号
ps -mp ${pid} -o THREAD,tid,time | sort -rn |head - >mytmp.out #获取线程信息
while read line
do
tid=`echo $line | awk '{print $8}'`
echo $tid
if [ "${tid}" = "-" ]
then
echo "this is '-'"
else
echo "TID is :"$tid>>${pid}_busy_thread.log
sixteenth=`printf "%x" $tid`
echo "Transform to 0xxxx is :"$sixteenth >>${pid}_busy_thread.log
/home/service/jdk1..0_29/bin/jstack ${pid} | grep $sixteenth -A >>${pid}_busy_thread.log
fi
done <mytmp.out echo "Finished!"
上一篇:brew 安装 yarn 时候失败


下一篇:pip安装icu失败:Command "python setup.py egg_info" failed with error code 1 in