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

相关推荐
爱吃土豆的马铃薯ㅤㅤㅤㅤㅤㅤㅤㅤㅤ几秒前
mapper.xml sql动态表查询配置
xml·java·sql
YuanlongWang2 分钟前
C# 基础——多态的实现方式
java·c#
小咕聊编程32 分钟前
【含文档+PPT+源码】基于spring boot的固定资产管理系统
java·spring boot·后端
roykingw33 分钟前
【终极面试集锦】如何设计微服务熔断体系?
java·微服务·面试
我命由我1234533 分钟前
Spring Cloud - Spring Cloud 微服务概述 (微服务的产生与特点、微服务的优缺点、微服务设计原则、微服务架构的核心组件)
java·运维·spring·spring cloud·微服务·架构·java-ee
それども36 分钟前
忽略Lombok构建警告
java·开发语言·jvm
用户685453759776943 分钟前
🎮 Java设计模式:从青铜到王者的代码修炼手册
java·后端
马尚道1 小时前
Java高手速成--吃透源码+手写组件+定制开发教程
java
我命由我123451 小时前
Spring Cloud - Spring Cloud 注册中心与服务提供者(Spring Cloud Eureka 概述、微服务快速入门、微服务应用实例)
java·spring boot·spring·spring cloud·微服务·eureka·java-ee
MetaverseMan1 小时前
Java Spring 框架的`@Autowired` 注解 以及依赖注入分析
java·开发语言·spring