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

相关推荐
2401_857297911 小时前
秋招内推--招联金融2025
java·前端·算法·金融·求职招聘
-$_$-2 小时前
【黑马点评】2 商户查询缓存
java·jmeter·缓存·maven
2401_857439692 小时前
春潮涌动:构建“衣依”服装销售平台的Spring Boot之旅
java·spring boot·后端
2401_854391082 小时前
Spring Boot与足球青训后台系统的协同
java·spring boot·后端
杨哥带你写代码3 小时前
美容院管理创新:SpringBoot系统设计与开发
java·spring boot·后端
九离⁢3 小时前
SpirngBoot核心思想之一IOC
java·spring boot
鸽鸽程序猿3 小时前
【JavaSE】反射、枚举、lambda表达式
java
jast_zsh3 小时前
详细介绍:API 和 SPI 的区别
java
学编程的小鬼3 小时前
Object类
java
郑州吴彦祖7723 小时前
java入门基础(一篇搞懂)
java·开发语言