采用JavaMelody监控Tomcat服务——安装手册
#1.获取安装包
wget https://psi-probe.googlecode.com/files/probe-2.3.3.zip
#2.解压安装包
unzip probe-2.3.3.zip
mv probe.war <tomcat dir>/webapps
mv probe.war <tomcat dir>/webapps
#3.设置tomcat用户信息
vi <tomcat dir>/conf/tomcat-users.xml
--------------------------------------------------------------------------------
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="manager"/>
<role rolename="standard"/>
<role rolename="tomcat"/>
<role rolename="admin"/>
<role rolename="role1"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="probe" password="probe" roles="admin,manager"/>
<user username="role1" password="tomcat" roles="role1"/>
</tomcat-users>
<tomcat-users>
<role rolename="manager"/>
<role rolename="standard"/>
<role rolename="tomcat"/>
<role rolename="admin"/>
<role rolename="role1"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="probe" password="probe" roles="admin,manager"/>
<user username="role1" password="tomcat" roles="role1"/>
</tomcat-users>
--------------------------------------------------------------------------------
#注:直接用此内容替换tomcat-users.xml文件内容
#修改后用户名密码均为tomcat
#4.设置环境变量,获取服务器状态
# vi /etc/profile
JAVA_OPTS=-Dcom.sun.management.jmxremote
export JAVA_OPTS
JAVA_OPTS=-Dcom.sun.management.jmxremote
export JAVA_OPTS
#5.javamelody和web应用集成时web.xml配置
<listener>
<listener-class>net.bull.javamelody.SessionListener</listener-class>
</listener>
<filter>
<filter-name>monitoring</filter-name>
<filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>monitoring</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener-class>net.bull.javamelody.SessionListener</listener-class>
</listener>
<filter>
<filter-name>monitoring</filter-name>
<filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>monitoring</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
#6.效果图
浮生潦草闲愁广,一听啤酒一口尽