From 796b44ea813a1133beae4f3a67f1c0263510c0c7 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期日, 17 十一月 2024 09:45:07 +0800 Subject: [PATCH] 1 --- src/main/java/com/moon/server/service/all/ScheduleService.java | 42 +----------------------------------------- 1 files changed, 1 insertions(+), 41 deletions(-) diff --git a/src/main/java/com/moon/server/service/all/ScheduleService.java b/src/main/java/com/moon/server/service/all/ScheduleService.java index 4703e28..819b365 100644 --- a/src/main/java/com/moon/server/service/all/ScheduleService.java +++ b/src/main/java/com/moon/server/service/all/ScheduleService.java @@ -31,11 +31,8 @@ import oshi.hardware.CentralProcessor; import oshi.hardware.GlobalMemory; -/** - * 鏃ョ▼鏈嶅姟绫� - * @author WWW - */ @Service +@SuppressWarnings("ALL") public class ScheduleService { @Autowired private ResService resService; @@ -51,9 +48,6 @@ private static final Log log = LogFactory.getLog(ScheduleService.class); - /** - * 鏌ヨ鏈嶅姟鍣ㄧ姸鎬� - */ public JSONObject selectServerStatus() throws InterruptedException { JSONObject json = new JSONObject(); json.put("cpuInfo", selectCpuInfo()); @@ -62,15 +56,11 @@ return json; } - /** - * 鏌ヨCpu淇℃伅 - */ public JSONObject selectCpuInfo() throws InterruptedException { SystemInfo systemInfo = new SystemInfo(); CentralProcessor processor = systemInfo.getHardware().getProcessor(); long[] prevTicks = processor.getSystemCpuLoadTicks(); - // 鐫$湢1s TimeUnit.SECONDS.sleep(1); long[] ticks = processor.getSystemCpuLoadTicks(); long nice = ticks[CentralProcessor.TickType.NICE.getIndex()] - prevTicks[CentralProcessor.TickType.NICE.getIndex()]; @@ -93,18 +83,13 @@ return map; } - /** - * 鏌ヨ鍐呭瓨淇℃伅 - */ public JSONObject selectMemInfo() { JSONObject map = new JSONObject(); SystemInfo systemInfo = new SystemInfo(); GlobalMemory memory = systemInfo.getHardware().getMemory(); - // 鎬诲唴瀛� long totalByte = memory.getTotal(); - // 鍓╀綑 long surplusByte = memory.getAvailable(); map.put("totalMem", FileHelper.formatByte(totalByte)); map.put("use", FileHelper.formatByte(totalByte - surplusByte)); @@ -114,9 +99,6 @@ return map; } - /** - * 鏌ヨ鍦ㄧ嚎鐢ㄦ埛 - */ public List<JSONObject> selectOnlineUsers() { List<JSONObject> list = new ArrayList<JSONObject>(); @@ -138,27 +120,18 @@ return list; } - /** - * 缁熻鍦ㄧ嚎鐢ㄦ埛鏁� - */ public int countOnlineUsers() { Set<String> keys = redisTemplate.keys(RedisCacheKey.signUserKey("*")); return null == keys ? 0 : keys.size(); } - /** - * 鏌ヨ鏈嶅姟璧勬簮鐘舵�� - */ public List<ResEntity> selectResStatus() { List<ResEntity> resList = resService.selectAll(); return testResStatus(resList); } - /** - * 娴嬭瘯璧勬簮鐘舵�� - */ private List<ResEntity> testResStatus(List<ResEntity> resList) { List<ResEntity> list = new ArrayList<>(); for (ResEntity re : resList) { @@ -172,7 +145,6 @@ URI uri = new URI(re.getUrl()); SocketAddress add = new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()); - // Ping閫氬湴鍧� socket.connect(add, 2000); } catch (Exception e) { // log.error(e.getMessage()) @@ -189,26 +161,17 @@ return list; } - /** - * 缁熻鏈嶅姟璧勬簮鐘舵�� - */ public JSONObject countResStatus() { List<ResEntity> resList = resService.selectAll(); List<ResEntity> unableList = testResStatus(resList); JSONObject jsonObject = new JSONObject(); - - // 璧勬簮鍙敤 jsonObject.put("resAbleCount", resList.size() - unableList.size()); - // 璧勬簮涓嶅彲鐢� jsonObject.put("resUnableCount", unableList.size()); return jsonObject; } - /** - * 璧勬簮鎿嶄綔鐘舵�� - */ public JSONObject operateCount() { List<OperateEntity> list = operateService.operateCount(); JSONObject jsonObject = new JSONObject(); @@ -227,9 +190,6 @@ } } - /** - * 鐢ㄦ埛鐧诲綍鐘舵�� - */ public JSONObject userLoginCount() { List<LoginEntity> list = loginService.selectLoginCounts(); if (list == null || list.isEmpty()) { -- Gitblit v1.9.3