|
@@ -238,7 +238,33 @@ public class PinpointServiceImpl implements IPinpointService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 通过应用名称获取agent列表
|
|
|
+ * 删除agent
|
|
|
+ *
|
|
|
+ * @param applicationName 应用名称
|
|
|
+ * @param agentId 应用ID
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void removeAgent(String applicationName, String agentId) {
|
|
|
+ String uri = baseUri() + "/admin/removeAgentId.pinpoint";
|
|
|
+ Map<String, Object> map = new HashMap<>(16);
|
|
|
+ map.put("applicationName", applicationName);
|
|
|
+ map.put("agentId", agentId);
|
|
|
+ map.put("password", "admin");
|
|
|
+ HttpRequest request = HttpUtil.createGet(uri);
|
|
|
+ request.setMethod(Method.GET);
|
|
|
+ request.form(map);
|
|
|
+ request.setConnectionTimeout(2000);
|
|
|
+ try (HttpResponse execute = request.execute()) {
|
|
|
+ if (!execute.isOk()) {
|
|
|
+ throw new RuntimeException("status:" + execute.getStatus() + "\tres:" + execute.body());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过应用名称获取agent列表,带时间
|
|
|
*
|
|
|
* @param applicationName 应用名称
|
|
|
* @param st 开始时间
|
|
@@ -282,4 +308,43 @@ public class PinpointServiceImpl implements IPinpointService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 通过应用名称获取agent列表,不带时间
|
|
|
+ *
|
|
|
+ * @param applicationName 应用名称
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<AgentVO> agentList(String applicationName) {
|
|
|
+ List<AgentVO> result = new ArrayList<>();
|
|
|
+ String uri = baseUri() + "/getAgentList.pinpoint";
|
|
|
+ Map<String, Object> map = new HashMap<>(16);
|
|
|
+ map.put("application", applicationName);
|
|
|
+ HttpRequest request = HttpUtil.createGet(uri);
|
|
|
+ request.setMethod(Method.GET);
|
|
|
+ request.form(map);
|
|
|
+ request.setConnectionTimeout(2000);
|
|
|
+ try (HttpResponse execute = request.execute()) {
|
|
|
+ if (execute.isOk()) {
|
|
|
+ String res = new String(execute.body().getBytes(), StandardCharsets.UTF_8);
|
|
|
+ cn.hutool.json.JSONObject object = JSONUtil.parseObj(res, true);
|
|
|
+ for (String key : object.keySet()) {
|
|
|
+ cn.hutool.json.JSONArray arr = object.getJSONArray(key);
|
|
|
+ for (int i = 0; i < arr.size(); i++) {
|
|
|
+ AgentVO vo = new AgentVO();
|
|
|
+ cn.hutool.json.JSONObject obj = arr.getJSONObject(i);
|
|
|
+ Integer code = obj.getByPath("status.state.code", Integer.class);
|
|
|
+ String agentId = obj.getByPath("status.agentId", String.class);
|
|
|
+ vo.setCode(code);
|
|
|
+ vo.setAgentId(agentId);
|
|
|
+ result.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
}
|