mirror of
https://gitee.com/arthas/arthas.git
synced 2024-11-29 18:58:37 +08:00
UserStat support agentId (#2501)
This commit is contained in:
parent
243ffacf88
commit
fa1d2bd30a
@ -456,6 +456,7 @@ public class ArthasBootstrap {
|
|||||||
logger().info("arthas stat url: {}", configure.getStatUrl());
|
logger().info("arthas stat url: {}", configure.getStatUrl());
|
||||||
}
|
}
|
||||||
UserStatUtil.setStatUrl(configure.getStatUrl());
|
UserStatUtil.setStatUrl(configure.getStatUrl());
|
||||||
|
UserStatUtil.setAgentId(configure.getAgentId());
|
||||||
UserStatUtil.arthasStart();
|
UserStatUtil.arthasStart();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -35,6 +35,8 @@ public class UserStatUtil {
|
|||||||
|
|
||||||
private static volatile String statUrl = null;
|
private static volatile String statUrl = null;
|
||||||
|
|
||||||
|
private static volatile String agentId = null;
|
||||||
|
|
||||||
public static String getStatUrl() {
|
public static String getStatUrl() {
|
||||||
return statUrl;
|
return statUrl;
|
||||||
}
|
}
|
||||||
@ -43,10 +45,21 @@ public class UserStatUtil {
|
|||||||
statUrl = url;
|
statUrl = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getAgentId() {
|
||||||
|
return agentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setAgentId(String id) {
|
||||||
|
agentId = id;
|
||||||
|
}
|
||||||
|
|
||||||
public static void arthasStart() {
|
public static void arthasStart() {
|
||||||
RemoteJob job = new RemoteJob();
|
RemoteJob job = new RemoteJob();
|
||||||
job.appendQueryData("ip", ip);
|
job.appendQueryData("ip", ip);
|
||||||
job.appendQueryData("version", version);
|
job.appendQueryData("version", version);
|
||||||
|
if (agentId != null) {
|
||||||
|
job.appendQueryData("agentId", agentId);
|
||||||
|
}
|
||||||
job.appendQueryData("command", "start");
|
job.appendQueryData("command", "start");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -60,6 +73,9 @@ public class UserStatUtil {
|
|||||||
RemoteJob job = new RemoteJob();
|
RemoteJob job = new RemoteJob();
|
||||||
job.appendQueryData("ip", ip);
|
job.appendQueryData("ip", ip);
|
||||||
job.appendQueryData("version", version);
|
job.appendQueryData("version", version);
|
||||||
|
if (agentId != null) {
|
||||||
|
job.appendQueryData("agentId", agentId);
|
||||||
|
}
|
||||||
job.appendQueryData("command", URLEncoder.encode(cmd));
|
job.appendQueryData("command", URLEncoder.encode(cmd));
|
||||||
if (detail != null) {
|
if (detail != null) {
|
||||||
job.appendQueryData("arguments", URLEncoder.encode(detail));
|
job.appendQueryData("arguments", URLEncoder.encode(detail));
|
||||||
|
@ -23,10 +23,11 @@ public class StatController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Map<String, Object> execute(@RequestParam(value = "ip", required = true) String ip,
|
public Map<String, Object> execute(@RequestParam(value = "ip", required = true) String ip,
|
||||||
@RequestParam(value = "version", required = true) String version,
|
@RequestParam(value = "version", required = true) String version,
|
||||||
|
@RequestParam(value = "agentId", required = false) String agentId,
|
||||||
@RequestParam(value = "command", required = true) String command,
|
@RequestParam(value = "command", required = true) String command,
|
||||||
@RequestParam(value = "arguments", required = false, defaultValue = "") String arguments) {
|
@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<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user