docker容器jvm监控

1
2
3
4
5
6
7
8
9
10
11
ENV JAVA_OPTS="\
-Dcom.sun.management.jmxremote.rmi.port=9090 \
-Dcom.sun.management.jmxremote=true \
-Dcom.sun.management.jmxremote.port=9090 \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.local.only=false \
-Djava.rmi.server.hostname=192.168.99.100"
EXPOSE 8080
EXPOSE 9090
ENTRYPOINT java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar /app.jar

其中ava.rmi.server.hostname为docker的地址

jvisualvm

本地命令行敲入jvisualvm打开

  • 添加远程机器
    192.168.99.100
  • 添加jmx连接
    192.168.99.100:9090

不要求SSL连接

https://www.jamasoftware.com/blog/monitoring-java-applications/

docker arthas使用

https://arthas.aliyun.com/doc/docker.html

1
2
3
docker container ls

docker exec -it ${containerId} /bin/bash -c "wget https://arthas.aliyun.com/arthas-boot.jar && java -jar arthas-boot.jar"

输入dashboard,按回车/enter,会展示当前进程的信息,按ctrl+c可以中断执行

输入thread,这个命令会显示所有线程的信息,并且把CPU使用率高的线程排在前面

命令打印出CPU占比最高的前三个线程

1
thread -n 10
1
tt -t com.google.common.collect.HashBiMap seekByKey -n 100

对类进行反编译

1
jad javax.servlet.Servlet
-------------本文结束-------------
0%