session command support print agent id/tunnel server. #835

This commit is contained in:
hengyunabc
2019-08-30 02:25:55 +08:00
parent 79b41b44b5
commit fe8c8d2ebc
2 changed files with 15 additions and 0 deletions
@@ -1,5 +1,6 @@
package com.taobao.arthas.core.command.basic1000;
import com.taobao.arthas.core.server.ArthasBootstrap;
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.shell.session.Session;
@@ -12,6 +13,8 @@ import com.taobao.text.util.RenderUtil;
import static com.taobao.text.ui.Element.label;
import com.alibaba.arthas.tunnel.client.TunnelClient;
/**
* 查看会话状态命令
*
@@ -32,6 +35,14 @@ public class SessionCommand extends AnnotatedCommand {
TableElement table = new TableElement().leftCellPadding(1).rightCellPadding(1);
table.row(true, label("Name").style(Decoration.bold.bold()), label("Value").style(Decoration.bold.bold()));
table.row("JAVA_PID", "" + session.getPid()).row("SESSION_ID", "" + session.getSessionId());
TunnelClient tunnelClient = ArthasBootstrap.getInstance().getTunnelClient();
if (tunnelClient != null) {
String id = tunnelClient.getId();
if (id != null) {
table.row("AGENT_ID", "" + id);
}
table.row("TUNNEL_SERVER", "" + tunnelClient.getTunnelServerUrl());
}
return table;
}
}
@@ -232,4 +232,8 @@ public class ArthasBootstrap {
logger.error(null, "Spy destroy failed: ", e);
}
}
public TunnelClient getTunnelClient() {
return tunnelClient;
}
}