From 2f195440cfe2942d89ce441bb348eb7f1fa858fe Mon Sep 17 00:00:00 2001 From: heavyrain2012 Date: Fri, 13 Aug 2021 15:06:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=81=A5=E5=BA=B7=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../loServer/action/admin/HealthAction.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/broker/src/main/java/com/xiaoleilu/loServer/action/admin/HealthAction.java b/broker/src/main/java/com/xiaoleilu/loServer/action/admin/HealthAction.java index 97c632a3..fd11ee49 100755 --- a/broker/src/main/java/com/xiaoleilu/loServer/action/admin/HealthAction.java +++ b/broker/src/main/java/com/xiaoleilu/loServer/action/admin/HealthAction.java @@ -36,12 +36,15 @@ public class HealthAction extends AdminAction { public boolean action(Request request, Response response) { if (request.getNettyRequest() instanceof FullHttpRequest) { JSONObject jsonObject = new JSONObject(); + JSONObject cpuObject = new JSONObject(); jsonObject.put("cpu", cpuObject); JSONObject memoryObject = new JSONObject(); jsonObject.put("memory", memoryObject); + JSONObject fileObject = new JSONObject(); + jsonObject.put("disk", fileObject); if (getOperatingSystemMXBean() instanceof OperatingSystemMXBean) { double load = getOperatingSystemMXBean().getSystemLoadAverage(); @@ -53,16 +56,11 @@ public class HealthAction extends AdminAction { memoryObject.put("max", Runtime.getRuntime().maxMemory()); memoryObject.put("avail", Runtime.getRuntime().totalMemory()); - - JSONArray jsonArray = new JSONArray(); - jsonObject.put("file", jsonArray); - for (File root : File.listRoots()) { - JSONObject fObj = new JSONObject(); - fObj.put("path", root.getPath()); - fObj.put("space", root.getTotalSpace()); - fObj.put("free", root.getFreeSpace()); - fObj.put("usable", root.getUsableSpace()); - } + File root = new File("/"); + fileObject.put("space", root.getTotalSpace()); + fileObject.put("free", root.getFreeSpace()); + fileObject.put("usable", root.getUsableSpace()); + JSONObject out = new JSONObject(); out.put("node1", jsonObject); RestResult result = RestResult.ok(out);