diff --git a/core/src/main/java/com/taobao/arthas/core/server/ArthasBootstrap.java b/core/src/main/java/com/taobao/arthas/core/server/ArthasBootstrap.java index 6b6ef7c1..4bc7c30b 100644 --- a/core/src/main/java/com/taobao/arthas/core/server/ArthasBootstrap.java +++ b/core/src/main/java/com/taobao/arthas/core/server/ArthasBootstrap.java @@ -456,6 +456,7 @@ public class ArthasBootstrap { logger().info("arthas stat url: {}", configure.getStatUrl()); } UserStatUtil.setStatUrl(configure.getStatUrl()); + UserStatUtil.setAgentId(configure.getAgentId()); UserStatUtil.arthasStart(); try { diff --git a/core/src/main/java/com/taobao/arthas/core/util/UserStatUtil.java b/core/src/main/java/com/taobao/arthas/core/util/UserStatUtil.java index cc112d85..01b9896f 100644 --- a/core/src/main/java/com/taobao/arthas/core/util/UserStatUtil.java +++ b/core/src/main/java/com/taobao/arthas/core/util/UserStatUtil.java @@ -35,6 +35,8 @@ public class UserStatUtil { private static volatile String statUrl = null; + private static volatile String agentId = null; + public static String getStatUrl() { return statUrl; } @@ -43,10 +45,21 @@ public class UserStatUtil { statUrl = url; } + public static String getAgentId() { + return agentId; + } + + public static void setAgentId(String id) { + agentId = id; + } + public static void arthasStart() { RemoteJob job = new RemoteJob(); job.appendQueryData("ip", ip); job.appendQueryData("version", version); + if (agentId != null) { + job.appendQueryData("agentId", agentId); + } job.appendQueryData("command", "start"); try { @@ -60,6 +73,9 @@ public class UserStatUtil { RemoteJob job = new RemoteJob(); job.appendQueryData("ip", ip); job.appendQueryData("version", version); + if (agentId != null) { + job.appendQueryData("agentId", agentId); + } job.appendQueryData("command", URLEncoder.encode(cmd)); if (detail != null) { job.appendQueryData("arguments", URLEncoder.encode(detail)); diff --git a/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/app/web/StatController.java b/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/app/web/StatController.java index 409ef1a2..9a46fd1c 100644 --- a/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/app/web/StatController.java +++ b/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/app/web/StatController.java @@ -23,10 +23,11 @@ public class StatController { @ResponseBody public Map execute(@RequestParam(value = "ip", required = true) String ip, @RequestParam(value = "version", required = true) String version, + @RequestParam(value = "agentId", required = false) String agentId, @RequestParam(value = "command", required = true) String command, @RequestParam(value = "arguments", required = false, defaultValue = "") String arguments) { - logger.info("arthas stat, ip: {}, version: {}, command: {}, arguments: {}", ip, version, command, arguments); + logger.info("arthas stat, ip: {}, version: {}, agentId: {}, command: {}, arguments: {}", ip, version, agentId, command, arguments); Map result = new HashMap<>();