linux查询java进程 jstack 等信息
Posted 老周21
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux查询java进程 jstack 等信息相关的知识,希望对你有一定的参考价值。
事情背景:weblogic那总是有报什么线程独占之类的,所以搞个定时的探测出来,定时 jstack 一下,抓抓独占产生时候的信息
话不多说,直接上脚本了,拷上去测试就好了
#!/bin/bash
etime=$(date "+%Y%m%d%H%M%S")
JSTACK="/u01/soft/jdk1.6.0_45/bin/jstack"
JSTAT="/u01/soft/jdk1.6.0_45/bin/jstat"
#pid=`ps -ef|grep weblogic|grep -v grep|awk \'{print $2}\'`
pid_9801=`ps -ef | grep weblogic | grep wsbsfwt | grep 9801 |grep jdk |awk \'{print $2}\'`
pid_9801_count=`ps -ef | grep weblogic | grep wsbsfwt | grep 9801 |grep jdk |awk \'{print $2}\' |wc -l`
pid_9804=`ps -ef | grep weblogic | grep wsbsfwt | grep 9804 |grep jdk |awk \'{print $2}\'`
pid_9804_count=`ps -ef | grep weblogic | grep wsbsfwt | grep 9804 |grep jdk |awk \'{print $2}\' |wc -l`
pid_9805=`ps -ef | grep weblogic | grep wsbsfwt | grep 9805 |grep jdk |awk \'{print $2}\'`
pid_9805_count=`ps -ef | grep weblogic | grep wsbsfwt | grep 9805 |grep jdk |awk \'{print $2}\' |wc -l`
pid_9806=`ps -ef | grep weblogic | grep wsbsfwt | grep 9806 |grep jdk |awk \'{print $2}\'`
pid_9806_count=`ps -ef | grep weblogic | grep wsbsfwt | grep 9806 |grep jdk |awk \'{print $2}\' |wc -l`
echo $pid_9801
echo $pid_9804
if [ $pid_9801_count -eq 1 ];then
$JSTACK $pid_9801 > /tmp/tmp_duzhan/logs/9801_jstack_${etime}.log
$JSTAT -gcutil $pid_9801 > /tmp/tmp_duzhan/logs/9801_jstat_${etime}.log
else
echo "bucunzai"
fi
if [ $pid_9804_count -eq 1 ];then
$JSTACK $pid_9804 > /tmp/tmp_duzhan/logs/9804_jstack_${etime}.log
$JSTAT -gcutil $pid_9804 > /tmp/tmp_duzhan/logs/9804_jstat_${etime}.log
else
echo "bucunzai"
fi
if [ $pid_9805_count -eq 1 ];then
$JSTACK $pid_9805 > /tmp/tmp_duzhan/logs/9805_jstack_${etime}.log
$JSTAT -gcutil $pid_9805 > /tmp/tmp_duzhan/logs/9805_jstat_${etime}.log
else
echo "bucunzai"
fi
if [ $pid_9806_count -eq 1 ];then
$JSTACK $pid_9806 > /tmp/tmp_duzhan/logs/9806_jstack_${etime}.log
$JSTAT -gcutil $pid_9806 > /tmp/tmp_duzhan/logs/9806_jstat_${etime}.log
else
echo "bucunzai"
fi
find /tmp/tmp_duzhan/logs/ -name "*.log" -mtime +2|xargs rm -f
还有一个是清理2天内的信息
以上是关于linux查询java进程 jstack 等信息的主要内容,如果未能解决你的问题,请参考以下文章