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的配置,需要和其他框架进行整合才能使用。

相关推荐
毕设源码-朱学姐2 小时前
【开题答辩全过程】以 工厂能耗分析平台的设计与实现为例,包含答辩的问题和答案
java·vue.js
Spring AI学习3 小时前
Spring AI深度解析(9/50):可观测性与监控体系实战
java·人工智能·spring
java1234_小锋4 小时前
Spring IoC的实现机制是什么?
java·后端·spring
xqqxqxxq4 小时前
背单词软件技术笔记(V2.0扩展版)
java·笔记·python
消失的旧时光-19435 小时前
深入理解 Java 线程池(二):ThreadPoolExecutor 执行流程 + 运行状态 + ctl 原理全解析
java·开发语言
哈哈老师啊5 小时前
Springboot学生综合测评系统hxtne(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
java·数据库·spring boot
4311媒体网5 小时前
帝国cms调用文章内容 二开基本操作
java·开发语言·php
zwxu_5 小时前
Nginx NIO对比Java NIO
java·nginx·nio
可观测性用观测云6 小时前
Pyroscope Java 接入最佳实践
java
气π7 小时前
【JavaWeb】——(若依 + AI)-基础学习笔记
java·spring boot·笔记·学习·java-ee·mybatis·ruoyi