Commit 5d9e899f5d8d559272f4bf6f7fe490b27e36883d
1 parent
5e97f62f
接口文档维护;
系统运行时间(uptime)module添加;
Showing
2 changed files
with
24 additions
and
5 deletions
Linux服务器监听运维功能.md
@@ -731,10 +731,10 @@ | @@ -731,10 +731,10 @@ | ||
731 | 731 | ||
732 | ## 3.4 获取module对应的内容 | 732 | ## 3.4 获取module对应的内容 |
733 | 733 | ||
734 | -| 调用方式 | 接口地址 | | ||
735 | -| ------------ | :---------------------------------------------- | | ||
736 | -| POST | http://ip:port/background/removeWorkingListener | | ||
737 | -| Content-Type | application/json;charset=UTF-8 | | 734 | +| 调用方式 | 接口地址 | |
735 | +| ------------ | :-------------------------------------- | | ||
736 | +| POST | http://ip:port/background/getModuleInfo | | ||
737 | +| Content-Type | application/json;charset=UTF-8 | | ||
738 | 738 | ||
739 | | 请求参数 | | | | | | 739 | | 请求参数 | | | | | |
740 | | --------- | -------- | ------ | ---- | ---------- | | 740 | | --------- | -------- | ------ | ---- | ---------- | |
src/main/java/com/objecteye/service/impl/OccupationOfBasicResourcesServiceImpl.java
@@ -31,7 +31,26 @@ public class OccupationOfBasicResourcesServiceImpl implements IOccupationOfBasic | @@ -31,7 +31,26 @@ public class OccupationOfBasicResourcesServiceImpl implements IOccupationOfBasic | ||
31 | */ | 31 | */ |
32 | @Override | 32 | @Override |
33 | public JSONArray getInfoByModule(Map<String, Object> requestMap) { | 33 | public JSONArray getInfoByModule(Map<String, Object> requestMap) { |
34 | - return getInfoByModule((String) requestMap.get("module")); | 34 | + String module = (String) requestMap.get("module"); |
35 | + if ("uptime".equals(module)) { | ||
36 | + String cmd = "uptime"; | ||
37 | + List<String> outList = new ArrayList<>(); | ||
38 | + LinuxUtils.executeLinuxCmd(cmd, outList); | ||
39 | + String outStr = String.join(",", outList); | ||
40 | + String[] outArr = outStr.split(","); | ||
41 | + String uptimeStr = outArr[0].substring(outArr[0].indexOf("up") + 2).trim() + "," + outArr[1]; | ||
42 | + uptimeStr = uptimeStr.replaceAll("days", "天"); | ||
43 | + if (!uptimeStr.contains("min")) { | ||
44 | + uptimeStr = uptimeStr.replaceAll(":", "h") + "min"; | ||
45 | + } | ||
46 | + JSONObject resultObj = new JSONObject(); | ||
47 | + resultObj.put("result", uptimeStr); | ||
48 | + JSONArray resultArr = new JSONArray(); | ||
49 | + resultArr.add(resultObj); | ||
50 | + return resultArr; | ||
51 | + } else { | ||
52 | + return getInfoByModule((String) requestMap.get("module")); | ||
53 | + } | ||
35 | } | 54 | } |
36 | 55 | ||
37 | /** | 56 | /** |