监控Tomcat状态!
Posted cxm123123form
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了监控Tomcat状态!相关的知识,希望对你有一定的参考价值。
方法一:开发JAVA监控页面
[root@localhost ~]# mkdir /usr/local/tomcat8/webapps/memtest/
[root@localhost ~]# cd /usr/local/tomcat8/webapps/
[root@localhost webapps]# ls
docs examples host-manager jpress-web-newest jpress-web-newest.war manager meminfo meminfo.war memtest ROOT
[root@localhost webapps]# cd memtest/
[root@localhost memtest]# cd
[root@localhost ~]# vim /usr/local/tomcat8/webapps/memtest/meminfo.jsp
<% Runtime rtm = Runtime.getRuntime(); long mm = rtm.maxMemory()/1024/1024; long tm = rtm.totalMemory()/1024/1024; long fm = rtm.freeMemory()/1024/1024; out.println("JVM memory detail info:<br>"); out.println("MAX memory:"+mm+MB"+<br>"); out.println("JVM memory:"+tm+MB"+<br>"); out.println("JVM memory :"+fm+MB"+<br>"); out.println("Available memory can be used is :"+(mm+tm+fm)+"MB"+"<br>"); %>
方法二:使用jps命令进行监控
[root@localhost ~]# vim /etc/profile
在末尾添加如下两行
JAVA_HOME=/usr/local/java
PATH=$PATH:$JAVA_HOME/bin
[root@localhost ~]# jps -lvm
8353 org.apache.catalina.startup.Bootstrap start -Djava.util.logging.config.file=/usr/local/tomcat8/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -Dcatalina.base=/usr/local/tomcat8 -Dcatalina.home=/usr/local/tomcat8 -Djava.io.tmpdir=/usr/local/tomcat8/temp
10123 sun.tools.jps.Jps -lvm -Dapplication.home=/usr/local/java -Xms8m
方法三:Tomcat远程监控功能
修改配置文件,开启远程监控
[root@localhost ~]# vim /usr/local/tomcat8/bin/catalina.sh
在开头添加如下命令
#!/bin/sh CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=192.168.200.119"
[root@localhost ~]# /usr/local/tomcat8/bin/shutdown.sh
[root@localhost ~]# /usr/local/tomcat8/bin/startup.sh
[root@localhost ~]# netstat -lnpt
tcp6 0 0 :::12345 :::* LISTEN 10832/java
以上是关于监控Tomcat状态!的主要内容,如果未能解决你的问题,请参考以下文章