Tomcat监控与调优:比Tomcat Manager更加强大的Psi-Probe

这是一款 Tomcat 管理和监控工具,前身是 Lambda Probe。由于 Lambda Probe 2006不再更新,所以 PSI Probe 算是对其的一个 Fork 版本并一直更新至今。

Probe

psi-probe是在相同的开源许可证(GPLV2)下分发的社区驱动的 Lambda Probe ,psi-probe的前身是 Lambda Probe,由于Lambda Probe 2006之后不再更新,所以psi-probe算是对其的一个 Fork版本并一直更新至今。它的目的是替换和扩展 Tomcat 管理器,使得管理和监视 Apache Tomcat 的实例更容易。与许多其他服务器监控工具不同,psi-probe不需要对现有应用程序进行任何更改。它通过一个Web可访问的接口提供它的所有特性,只需将它部署到服务器即可。

使用psi-probe监控的步骤如下:

安装probe

目前我们一般都是安装psi-probe的版本,将下载的安装包解压缩,放进webapps目录。

通过网盘分享的文件:probe.war 链接:

https://pan.baidu.com/s/1ZpMyjH6D-tj2gBLRJIe-dQ?pwd=4hc2 提取码: 4hc2

配置用户与角色

使用probe监控工具时,会提醒输入登录的用户信息,该登录的用户信息角色必须为manage-gui。在tomcat-users.xml文件中配置即可。具体的代码如下:

xml 复制代码
<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<tomcat-users>
<!--
  NOTE:  By default, no user is included in the "manager-gui" role required
  to operate the "/manager/html" web application.  If you wish to use this app,
  you must define such a user - the username and password are arbitrary.
-->
<!--
  NOTE:  The sample user and role entries below are wrapped in a comment
  and thus are ignored when reading this file. Do not forget to remove
  <!.. ..> that surrounds them.
-->
  <role rolename="tomcat" />
  <role rolename="manager" />
  <role rolename="admin-gui" />
  <role rolename="manager-gui" />
  

  <user username="yongjie" password="abc123" roles="tomcat,manager,admin-gui,manager-gui,probeuser,poweruserplus,poweruser" />
  

</tomcat-users>

配置conf/catalina.bat或catalina.sh文件。

bash 复制代码
export JAVA_OPTS=$JAVA_OPTS" -Dcom.sun.management.jmxremote" 

重启Tomcat服务器

bash 复制代码
tomcat停止
 /bin/shutdown.sh
tomcat启动
 /bin/startup.sh

进入监控界面

bash 复制代码
http://ip:port/probe

例如
http://192.168.40.133:8080/probe/

监控界面的信息如图所示。

bash 复制代码
Requests:在单个应用程序的基础上, 实时监控流量。
Sessions:浏览/搜索属性,查看最后的IP,过期,估计大小。
jsp:浏览,查看源代码,编译。
Data Sources:查看池使用情况,执行查询。
Logs:查看内容,下载,在运行时更改级别。
Threads:查看执行堆栈,杀死。
Connectors:状态,使用图表。
Certificates:系统信任存储和连接器密钥存储/信任存储
Cluster:状态,使用图表。
JVM:内存使用图表,建议GC
Java Service Wrapper:重启JVM。
System:CPU使用,内存使用,交换文件使用。

除上面那功能,部分个人觉得实用功能如下:

管理端支持国际化

可在线查看或下载Log日志

可监控内存每个区域的使用情况

在线查看Tomcat配置信息,jdk信息、操作系统信息等

在线发布项目

支持集群监控、线程监控

在线查看servlet、过滤器、web.xml、content.xml、jsp等具体配置

为什么不使用jdk自带的工具(jstack、jmap...)进行监控?

jdk自带的监控工具基本都需要进入服务器内部,通过命令去查看分析,没有可视化界面更加直观,还有就是这些工具功能比较单一,命令比较多,难记住,主要这些工具主要是监控JVM相关的信息,对于web容器中请求、session、并发数都没有监控到。

可以通过工具-在本地通过jdk自带的jvisualvm和jconsole远程监控Tomcat的JVM运行这种方式来监控唉,这种方式虽然有可视化界面了,但还是存在监控到的信息有限,并且通过跨服务器jmx远程监控这种方式还受限于网络影响。

其他监控工具:

Javamelody,该工具高度与应用系统耦合,需要应用依赖于对应的jar包和web.xml filter的配置,需要和其他框架进行整合才能使用。

相关推荐
代码的余温18 分钟前
Maven引入第三方JAR包实战指南
java·maven·jar
pianmian14 小时前
类(JavaBean类)和对象
java
我叫小白菜4 小时前
【Java_EE】单例模式、阻塞队列、线程池、定时器
java·开发语言
Albert Edison5 小时前
【最新版】IntelliJ IDEA 2025 创建 SpringBoot 项目
java·spring boot·intellij-idea
超级小忍5 小时前
JVM 中的垃圾回收算法及垃圾回收器详解
java·jvm
weixin_446122465 小时前
JAVA内存区域划分
java·开发语言·redis
勤奋的小王同学~6 小时前
(javaEE初阶)计算机是如何组成的:CPU基本工作流程 CPU介绍 CPU执行指令的流程 寄存器 程序 进程 进程控制块 线程 线程的执行
java·java-ee
TT哇6 小时前
JavaEE==网站开发
java·redis·java-ee
2401_826097626 小时前
JavaEE-Linux环境部署
java·linux·java-ee
缘来是庄6 小时前
设计模式之访问者模式
java·设计模式·访问者模式