diff --git a/src/main/java/im/zhaojun/zfile/controller/admin/MonitorController.java b/src/main/java/im/zhaojun/zfile/controller/admin/MonitorController.java deleted file mode 100644 index a188736..0000000 --- a/src/main/java/im/zhaojun/zfile/controller/admin/MonitorController.java +++ /dev/null @@ -1,26 +0,0 @@ -package im.zhaojun.zfile.controller.admin; - -import im.zhaojun.zfile.model.support.ResultBean; -import im.zhaojun.zfile.model.support.SystemMonitorInfo; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * 系统监控 Controller - * @author zhaojun - */ -@RestController -@RequestMapping("/admin") -public class MonitorController { - - - /** - * 获取系统监控信息 - */ - @GetMapping("monitor") - public ResultBean monitor() { - return ResultBean.success(new SystemMonitorInfo()); - } - -} \ No newline at end of file diff --git a/src/main/java/im/zhaojun/zfile/model/support/Jvm.java b/src/main/java/im/zhaojun/zfile/model/support/Jvm.java deleted file mode 100644 index 674d3f1..0000000 --- a/src/main/java/im/zhaojun/zfile/model/support/Jvm.java +++ /dev/null @@ -1,39 +0,0 @@ -package im.zhaojun.zfile.model.support; - -import lombok.Data; - -/** - * @author zhaojun - */ -@Data -public class Jvm { - - /** - * 当前 JVM 占用的内存总数 (M) - */ - private double total; - - /** - * JVM 最大可用内存总数 (M) - */ - private double max; - - /** - * JVM 空闲内存 (M) - */ - private double free; - - /** - * JDK 版本 - */ - private String version; - - public Jvm() { - Runtime runtime = Runtime.getRuntime(); - this.total = runtime.totalMemory(); - this.free = runtime.freeMemory(); - this.max = runtime.maxMemory(); - this.version = System.getProperty("java.version"); - } - -} diff --git a/src/main/java/im/zhaojun/zfile/model/support/Mem.java b/src/main/java/im/zhaojun/zfile/model/support/Mem.java deleted file mode 100644 index 9d4d2cc..0000000 --- a/src/main/java/im/zhaojun/zfile/model/support/Mem.java +++ /dev/null @@ -1,41 +0,0 @@ -package im.zhaojun.zfile.model.support; - -import com.sun.management.OperatingSystemMXBean; -import lombok.Data; - -import java.lang.management.ManagementFactory; - -/** - * @author zhaojun - */ -@Data -public class Mem { - - /** - * 内存总量 - */ - private double total; - - /** - * 已用内存 - */ - private double used; - - /** - * 剩余内存 - */ - private double free; - - public Mem() { - OperatingSystemMXBean osb = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); - // 总的物理内存+虚拟内存 - long totalVirtualMemory = osb.getTotalSwapSpaceSize(); - // 剩余的物理内存 - long freePhysicalMemorySize = osb.getFreePhysicalMemorySize(); - this.total = totalVirtualMemory; - this.free = freePhysicalMemorySize; - this.used = totalVirtualMemory - freePhysicalMemorySize; - } - - -} diff --git a/src/main/java/im/zhaojun/zfile/model/support/Sys.java b/src/main/java/im/zhaojun/zfile/model/support/Sys.java deleted file mode 100644 index 0ae4de7..0000000 --- a/src/main/java/im/zhaojun/zfile/model/support/Sys.java +++ /dev/null @@ -1,58 +0,0 @@ -package im.zhaojun.zfile.model.support; - -import cn.hutool.core.date.BetweenFormater; -import cn.hutool.core.date.DateUtil; -import lombok.Data; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; - -import java.io.IOException; -import java.lang.management.ManagementFactory; - -/** - * @author zhaojun - */ -@Data -public class Sys { - - /** - * 项目路径 - */ - private String projectDir; - - /** - * 操作系统 - */ - private String osName; - - /** - * 系统架构 - */ - private String osArch; - - /** - * 系统版本 - */ - private String osVersion; - - /** - * 启动时间 - */ - private String upTime; - - public Sys() { - this.osName = System.getProperty("os.name"); - this.osArch = System.getProperty("os.arch"); - this.osVersion = System.getProperty("os.version"); - Resource resource = new ClassPathResource(""); - try { - this.projectDir = resource.getFile().getAbsolutePath(); - } catch (IOException e) { - e.printStackTrace(); - } - - long uptime = ManagementFactory.getRuntimeMXBean().getUptime(); - this.upTime = DateUtil.formatBetween(uptime, BetweenFormater.Level.SECOND); - } - -} diff --git a/src/main/java/im/zhaojun/zfile/model/support/SystemMonitorInfo.java b/src/main/java/im/zhaojun/zfile/model/support/SystemMonitorInfo.java deleted file mode 100644 index 3adb3ab..0000000 --- a/src/main/java/im/zhaojun/zfile/model/support/SystemMonitorInfo.java +++ /dev/null @@ -1,34 +0,0 @@ -package im.zhaojun.zfile.model.support; - -import lombok.Data; - -import java.io.Serializable; - -/** - * @author zhaojun - */ -@Data -public class SystemMonitorInfo implements Serializable { - - /** - * 服务器基本信息 - */ - private Sys sys; - - /** - * JVM 信息 - */ - private Jvm jvm; - - /** - * 系统内存 - */ - private Mem mem; - - public SystemMonitorInfo() { - this.jvm = new Jvm(); - this.sys = new Sys(); - this.mem = new Mem(); - } - -}