aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/helper/Log.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-22 07:22:14 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-22 07:22:14 -0700
commitcc9eca495f93b8ffaee0fe5b10b62f1f3dfbf945 (patch)
tree397de1f1bb572138cf6f60f2c618c6a71e71c95d /src/main/java/org/traccar/helper/Log.java
parentf5a9207393463879cfe85e94259ee70d6d5b9980 (diff)
downloadtrackermap-server-cc9eca495f93b8ffaee0fe5b10b62f1f3dfbf945.tar.gz
trackermap-server-cc9eca495f93b8ffaee0fe5b10b62f1f3dfbf945.tar.bz2
trackermap-server-cc9eca495f93b8ffaee0fe5b10b62f1f3dfbf945.zip
Return storage info
Diffstat (limited to 'src/main/java/org/traccar/helper/Log.java')
-rw-r--r--src/main/java/org/traccar/helper/Log.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/helper/Log.java b/src/main/java/org/traccar/helper/Log.java
index 8c67f9ddc..e1b201f9f 100644
--- a/src/main/java/org/traccar/helper/Log.java
+++ b/src/main/java/org/traccar/helper/Log.java
@@ -28,6 +28,10 @@ import java.io.StringWriter;
import java.io.Writer;
import java.net.URL;
import java.nio.charset.StandardCharsets;
+import java.nio.file.FileStore;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.ConsoleHandler;
@@ -269,4 +273,18 @@ public final class Log {
return s.toString();
}
+ public static long[] getStorageSpace() {
+ long usable = 0;
+ long total = 0;
+ for (Path root : FileSystems.getDefault().getRootDirectories()) {
+ try {
+ FileStore store = Files.getFileStore(root);
+ usable += store.getUsableSpace();
+ total += store.getTotalSpace();
+ } catch (IOException ignored) {
+ }
+ }
+ return new long[]{usable, total};
+ }
+
}