未验证 提交 a093f8a6 编写于 作者: A affe 提交者: GitHub

[ISSUE #2067] Add logs when collecting disk space usage

上级 915424c2
...@@ -200,14 +200,20 @@ public class UtilAll { ...@@ -200,14 +200,20 @@ public class UtilAll {
} }
public static double getDiskPartitionSpaceUsedPercent(final String path) { public static double getDiskPartitionSpaceUsedPercent(final String path) {
if (null == path || path.isEmpty()) if (null == path || path.isEmpty()) {
log.error("Error when measuring disk space usage, path is null or empty, path : {}", path);
return -1; return -1;
}
try { try {
File file = new File(path); File file = new File(path);
if (!file.exists()) if (!file.exists()) {
log.error("Error when measuring disk space usage, file doesn't exist on this path: {}", path);
return -1; return -1;
}
long totalSpace = file.getTotalSpace(); long totalSpace = file.getTotalSpace();
...@@ -218,6 +224,7 @@ public class UtilAll { ...@@ -218,6 +224,7 @@ public class UtilAll {
return usedSpace / (double) totalSpace; return usedSpace / (double) totalSpace;
} }
} catch (Exception e) { } catch (Exception e) {
log.error("Error when measuring disk space usage, got exception: :", e);
return -1; return -1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册