mirror of https://github.com/fengyuhetao/shell.git
commit
86e5e637ae
|
@ -1,3 +1,2 @@
|
||||||
# shell
|
# shell
|
||||||
2016-05-12 ~ 2016-05-22
|
大部分所有案例均出自《Linux命令行与shell脚本编程大全案例》一书,方便各位小伙伴学习,欢迎各位同学共同扩充shell脚本库哦!!!!
|
||||||
所有案例均出自《Linux命令行与shell脚本编程大全案例》一书,作为学习shell的一个见证
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# 来源: https://blog.csdn.net/qianghaohao/article/details/80379118
|
||||||
|
# 服务器线程数达到 2500 以上时 dump 线程数最多的 java 进程的线程及内存
|
||||||
|
#
|
||||||
|
source ~/.bashrc
|
||||||
|
cur_thread_num=`ps -efL | wc -l`
|
||||||
|
if [ $cur_thread_num -le 2500 ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
cur_date=`date +"%Y-%m-%d_%H-%M-%S"`
|
||||||
|
cd ./dumpfile
|
||||||
|
# 服务器当前线程 dump 到文件:按照线程数由大到小排序显示
|
||||||
|
ps -efL --sort -nlwp > server_thread_dump_$cur_date
|
||||||
|
# dump 线程数最多的 jvm 的线程及内存
|
||||||
|
most_thread_num_pid=`cat server_thread_dump_$cur_date | sed -n '2p' | awk '{print $2}'`
|
||||||
|
nohup jstack -l $most_thread_num_pid > java_app_thread_dump_${cur_date}_pid_${most_thread_num_pid} &
|
||||||
|
nohup jmap -dump:format=b,file=java_app_mem_dump_${cur_date}_pid_${most_thread_num_pid} $most_thread_num_pid &
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue