From cfeb24806751fc05d2406c08eab2c5dc8804c741 Mon Sep 17 00:00:00 2001 From: fakeyanss Date: Sun, 22 Nov 2020 17:08:34 +0800 Subject: [PATCH] =?UTF-8?q?[Fix]=20=E7=A3=81=E7=9B=98=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=8E=87=E8=AE=A1=E7=AE=97bug,=20=E6=9C=BA=E5=99=A8=E6=8C=82?= =?UTF-8?q?=E8=BD=BD=E5=A4=9A=E7=9B=98=E6=97=B6=E5=8F=AA=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E4=BA=86=E6=9C=80=E5=90=8E=E4=B8=80=E5=9D=97=E7=9B=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/MonitorServiceImpl.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MonitorServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MonitorServiceImpl.java index 99aaef88..26809879 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MonitorServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MonitorServiceImpl.java @@ -73,15 +73,18 @@ public class MonitorServiceImpl implements MonitorService { Map diskInfo = new LinkedHashMap<>(); FileSystem fileSystem = os.getFileSystem(); List fsArray = fileSystem.getFileStores(); - for (OSFileStore fs : fsArray){ - long available = fs.getUsableSpace(); - long total = fs.getTotalSpace(); - long used = total - available; - diskInfo.put("total", total > 0 ? FileUtil.getSize(total) : "?"); - diskInfo.put("available", FileUtil.getSize(available)); - diskInfo.put("used", FileUtil.getSize(used)); - diskInfo.put("usageRate", df.format(used/(double)fs.getTotalSpace() * 100)); + long available = 0L; + long total = 0L; + long used = 0L; + for (OSFileStore fs : fsArray) { + available += fs.getUsableSpace(); + total += fs.getTotalSpace(); } + used += total - available; + diskInfo.put("total", total > 0 ? FileUtil.getSize(total) : "?"); + diskInfo.put("available", FileUtil.getSize(available)); + diskInfo.put("used", FileUtil.getSize(used)); + diskInfo.put("usageRate", df.format(used/(double)total * 100)); return diskInfo; }