- Arthas 版本: 3.5.4
- 操作系统版本: Centos7 & Mac 10.15.2
- 目标进程的JVM版本: jdk8
本人使用arthas tunnel形式,在Spring项目中初始化连接,使用Tomcat8进行项目部署,根据官方文档说明进行连接。 连接代码如下:
public ArthasAgent arthasAgent() {
if (arthasProperties.isEmpty()) {
throw new ArthasPortException("500", "fail to assign arthas ports, please check code");
}
Map<String, String> arthasConfigMap = arthasProperties.getArthasConfigMap();
arthasConfigMap = StringUtils.removeDashKey(arthasConfigMap);
if (arthasConfigMap.get(ArthasProperties.ARTHAS_APPNAME) == null) {
Properties properties = loadProperties(SYSTEM_PROPERTY_FILE);
if (Objects.nonNull(properties) && properties.containsKey(SystemProperties.SYSTEM_APP_NAME)) {
arthasConfigMap.put(ArthasProperties.ARTHAS_APPNAME, properties.getProperty(SystemProperties.SYSTEM_APP_NAME, SystemProperties.DEFAULT_SYSTEM_APP_NAME));
}
}
refreshPortAndAgentId(arthasConfigMap);
ArthasAgent arthasAgent = new ArthasAgent(arthasConfigMap, arthasProperties.getHome(), arthasProperties.isSlientInit(), (Instrumentation) null);
arthasAgent.init();
logger.info("[ArthasConfiguration]Arthas agent start success.");
return arthasAgent;
}
以上代码能够正常启动tunnel,并且连接远程server进行在线诊断 但是发现在没有配置的情况下,tomcat的temp目录下,每次启动都会新建arthas-{时间戳}-0的临时目录,存放arthas的lib信息 结果temp目录下多次重启tomcat,就新建了多个arthas目录,内部为arthas的lib数据
:~/tomcat8/temp$ ls -l
total 0
12 16 17:14 arthas-1639646089432-0
12 16 19:54 arthas-1639655680317-0
12 16 20:05 arthas-1639656305555-0
12 16 20:09 arthas-1639656554801-0
12 16 20:11 arthas-1639656695960-0
12 16 20:13 arthas-1639656814094-0
12 16 20:15 arthas-1639656928423-0
12 16 20:22 arthas-1639657343520-0
12 16 20:23 arthas-1639657420267-0
12 17 08:38 arthas-1639701498487-0
12 17 14:14 arthas-1639721654300-0
12 17 14:15 arthas-1639721716584-0
12 17 14:18 arthas-1639721920503-0
12 17 14:22 arthas-1639722158984-0
11 10 21:14 safeToDelete.tmp
文件内部
:~/tomcat8/temp/arthas-1639655680317-0$ ls -l
total 26992
8456 12 16 19:54 arthas-agent.jar
141893 12 16 19:54 arthas-boot.jar
431012 12 16 19:54 arthas-client.jar
13151752 12 16 19:54 arthas-core.jar
5444 12 16 19:54 arthas-spy.jar
531 12 16 19:54 arthas.properties
7744 12 16 19:54 as-service.bat
3113 12 16 19:54 as.bat
33257 12 16 19:54 as.sh
192 12 16 19:54 async-profiler
635 12 16 19:54 install-local.sh
160 12 16 19:54 lib
2020 12 16 19:54 logback.xml
4493 12 16 19:54 math-game.jar
重现问题的步骤
- 正常发布应用至tomcat
- 启动tomcat服务
- tomcat temp目录下存在arthas新建的目录
- 终止tomcat后未清除相应arthas lib目录
每次启动新建的lib目录是否可以公用,是否可以填写相关配置指定固定目录,是否是我项目配置中参数缺失导致以上结果?
实际运行的结果本人使用arthas tunnel形式,在Spring项目中初始化连接,使用Tomcat8进行项目部署,根据官方文档说明进行连接。 连接代码如下:
public ArthasAgent arthasAgent() {
if (arthasProperties.isEmpty()) {
throw new ArthasPortException("500", "fail to assign arthas ports, please check code");
}
Map<String, String> arthasConfigMap = arthasProperties.getArthasConfigMap();
arthasConfigMap = StringUtils.removeDashKey(arthasConfigMap);
if (arthasConfigMap.get(ArthasProperties.ARTHAS_APPNAME) == null) {
Properties properties = loadProperties(SYSTEM_PROPERTY_FILE);
if (Objects.nonNull(properties) && properties.containsKey(SystemProperties.SYSTEM_APP_NAME)) {
arthasConfigMap.put(ArthasProperties.ARTHAS_APPNAME, properties.getProperty(SystemProperties.SYSTEM_APP_NAME, SystemProperties.DEFAULT_SYSTEM_APP_NAME));
}
}
refreshPortAndAgentId(arthasConfigMap);
ArthasAgent arthasAgent = new ArthasAgent(arthasConfigMap, arthasProperties.getHome(), arthasProperties.isSlientInit(), (Instrumentation) null);
arthasAgent.init();
logger.info("[ArthasConfiguration]Arthas agent start success.");
return arthasAgent;
}
以上代码能够正常启动柜tunnel,并且连接远程server进行在线诊断 但是发现在没有配置的情况下,tomcat的temp目录下,每次启动都会新建arthas-{时间戳}-0的临时目录,存放arthas的lib信息 结果temp目录下多次重启tomcat,就新建了多个arthas目录,内部为arthas的lib数据
:~/tomcat8/temp$ ls -l
total 0
12 16 17:14 arthas-1639646089432-0
12 16 19:54 arthas-1639655680317-0
12 16 20:05 arthas-1639656305555-0
12 16 20:09 arthas-1639656554801-0
12 16 20:11 arthas-1639656695960-0
12 16 20:13 arthas-1639656814094-0
12 16 20:15 arthas-1639656928423-0
12 16 20:22 arthas-1639657343520-0
12 16 20:23 arthas-1639657420267-0
12 17 08:38 arthas-1639701498487-0
12 17 14:14 arthas-1639721654300-0
12 17 14:15 arthas-1639721716584-0
12 17 14:18 arthas-1639721920503-0
12 17 14:22 arthas-1639722158984-0
11 10 21:14 safeToDelete.tmp
文件内部
:~/tomcat8/temp/arthas-1639655680317-0$ ls -l
total 26992
8456 12 16 19:54 arthas-agent.jar
141893 12 16 19:54 arthas-boot.jar
431012 12 16 19:54 arthas-client.jar
13151752 12 16 19:54 arthas-core.jar
5444 12 16 19:54 arthas-spy.jar
531 12 16 19:54 arthas.properties
7744 12 16 19:54 as-service.bat
3113 12 16 19:54 as.bat
33257 12 16 19:54 as.sh
192 12 16 19:54 async-profiler
635 12 16 19:54 install-local.sh
160 12 16 19:54 lib
2020 12 16 19:54 logback.xml
4493 12 16 19:54 math-game.jar