如何使用 jconsole 查看 springboot 程序性能
需求背景: 需要查看自己写的springboot 程序内存 和 cpu 的占用情况,需要在本地使用jconsole去访问
linux 上的springboot 程序
-
因为需要监控远程的springboot 程序, 在springboot 程序启动的时候,需要添加一些参数,通过配置
这些参数,让jconsole 可以在本地进行访问程序
java -Djava.rmi.server.hostname=你程序所在的服务器的ip -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=你暴露给jconsole用来连接springboot程序的端口 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -jar 你需要启动程序的jar包.jar
参数讲解
#配置远程调用主机地址,即jar包运行所在系统的IP地址,不配置则默认使用hosts文件中的值 -Djava.rmi.server.hostname