jvm 相关工具
官方文档:
https://alibaba.github.io/arthas/
用于查看方法的输入输出,验证环境中的class是否最新扥。
安装参考:
https://alibaba.github.io/arthas/manual-install.html
均部署了arthas 在目录:
/usr/local/arthas
arthas
部署启动查看方法输入输出方式方式
解压后
./install-local.sh
然后使用
sudo su tomcat
进入Tomcat用户下执行
./as.sh
(或者可以直接使用命令:sudo -u tomcat -EH ./as.sh )
注:此步骤出现权限问题提示的话,在root模型下创建对应目录/home/tomcat
然后赋权限: chown -R tomcat /home/tomcat
根据出现的pid 选择需要attached的进程
之后输入对应数字即可
查看方法输入输出方式
watch com.xxx.quartz.xxxQuartz syncRule "{params,returnObj}" -x 4
watch com.xxx.xxController * "{params,returnObj}" -x 2
watch com.xxx.service.UserService save "{params,returnObj}" -x 4
条件过滤
watch com.xxx.redis.CacheTaskRedis spop "{params,returnObj}" 'params[0] == "value-sr"' -x 4
查看当前class的反编译
jad com.xxx.xxController
getstatic 获取静态值
getstatic com.xxx.util.XXXCache retryFlag
getstatic com.xxx.memoryEntity.xxxEntity includeCephMap -x 4
getstatic com.xxx.xxxEntity xxMap 'entrySet().iterator.{? #this.key.equals("values")}'
getstatic com.xxx.Log currentMap "size()"
async-profile 火焰图
官网:
https://github.com/jvm-profiling-tools/async-profiler
下载最新版本:async-profiler-1.7.1-linux-x64.tar.gz
Linux x64 (glibc): async-profiler-1.7.1-linux-x64.tar.gz
使用
解压:
tar xvf async-profiler-1.7.1-linux-x64.tar.gz
执行命令:
./profiler.sh -d 60 -f /tmp/profile.svg 16401
CPU耗时脚本
show-busy-java-threads
官网:
https://github.com/oldratlee/useful-scripts/blob/dev-2.x/docs/java.md#-show-busy-java-threads
打包下载
wget --no-check-certificate https://github.com/oldratlee/useful-scripts/archive/release-2.x.zip
unzip release-2.x.zip
下载单个文件
wget --no-check-certificate https://raw.github.com/oldratlee/useful-scripts/release-2.x/bin/show-busy-java-threads
chmod +x show-busy-java-threads
./show-busy-java-threads
典型使用
/ap/bin/useful-scripts-dev-2.x/bin/show-busy-java-threads -p 42511
耗时操作
grep “java” /tmp/linwz/jstack421 |awk ‘{a[$2]++}END{for (j in a) print j","a[j]}’|sort -t ‘,’ -k 2 -n -r|less -N