在CentOS上监控Tomcat可通过以下方式:
JMX监控
catalina.sh(或setenv.sh),添加JMX配置:CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"。localhost:9090查看线程、内存等指标。Tomcat自带管理工具
conf/tomcat-users.xml中的manager-gui角色,通过浏览器访问http://服务器IP:端口/manager/html查看状态。第三方工具
脚本与命令行
ps -ef | grep tomcat查看进程,tail -f catalina.out监控日志。系统工具
top/htop:实时查看Tomcat进程的资源占用。jstat:监控JVM垃圾回收和内存使用(如jstat -gcutil <pid> 1000)。根据需求选择合适方案,生产环境建议结合Prometheus+Grafana实现全面监控。