diff --git a/pom.xml b/pom.xml index eac2790..0386973 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ 2.0.0 1.3.2 1.2.5 - 1.2.47 + 1.2.58 1.1.10 2.5 1.3.3 diff --git a/src/main/java/com/luckyframe/project/monitor/job/task/RunAutomationTestTask.java b/src/main/java/com/luckyframe/project/monitor/job/task/RunAutomationTestTask.java index d065dc0..c484b2c 100644 --- a/src/main/java/com/luckyframe/project/monitor/job/task/RunAutomationTestTask.java +++ b/src/main/java/com/luckyframe/project/monitor/job/task/RunAutomationTestTask.java @@ -77,7 +77,6 @@ public class RunAutomationTestTask log.error("测试任务执行,远程链接客户端出现异常..."); taskExecute.setTaskStatus(4); taskExecuteService.updateTaskExecute(taskExecute); - throw new ConnectException(); } catch (KeyManagementException e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/src/main/java/com/luckyframe/project/monitor/server/domain/set/SetCpu.java b/src/main/java/com/luckyframe/project/monitor/server/domain/set/SetCpu.java new file mode 100644 index 0000000..f49c442 --- /dev/null +++ b/src/main/java/com/luckyframe/project/monitor/server/domain/set/SetCpu.java @@ -0,0 +1,101 @@ +package com.luckyframe.project.monitor.server.domain.set; + +import java.math.BigDecimal; + +/** + * CPU相关信息 + * + * @author ruoyi + */ +public class SetCpu +{ + /** + * 核心数 + */ + private int cpuNum; + + /** + * CPU总的使用率 + */ + private BigDecimal total; + + /** + * CPU系统使用率 + */ + private BigDecimal sys; + + /** + * CPU用户使用率 + */ + private BigDecimal used; + + /** + * CPU当前等待率 + */ + private BigDecimal wait; + + /** + * CPU当前空闲率 + */ + private BigDecimal free; + + public int getCpuNum() + { + return cpuNum; + } + + public void setCpuNum(int cpuNum) + { + this.cpuNum = cpuNum; + } + + public BigDecimal getTotal() + { + return total; + } + + public void setTotal(BigDecimal total) + { + this.total = total; + } + + public BigDecimal getSys() + { + return sys; + } + + public void setSys(BigDecimal sys) + { + this.sys = sys; + } + + public BigDecimal getUsed() + { + return used; + } + + public void setUsed(BigDecimal used) + { + this.used = used; + } + + public BigDecimal getWait() + { + return wait; + } + + public void setWait(BigDecimal wait) + { + this.wait = wait; + } + + public BigDecimal getFree() + { + return free; + } + + public void setFree(BigDecimal free) + { + this.free = free; + } +} diff --git a/src/main/java/com/luckyframe/project/monitor/server/domain/set/SetJvm.java b/src/main/java/com/luckyframe/project/monitor/server/domain/set/SetJvm.java new file mode 100644 index 0000000..4e3dea8 --- /dev/null +++ b/src/main/java/com/luckyframe/project/monitor/server/domain/set/SetJvm.java @@ -0,0 +1,133 @@ +package com.luckyframe.project.monitor.server.domain.set; + +import java.lang.management.ManagementFactory; +import java.math.BigDecimal; + +import com.luckyframe.common.utils.DateUtils; + +/** + * JVM相关信息 + * + * @author ruoyi + */ +public class SetJvm +{ + /** + * 当前JVM占用的内存总数(M) + */ + private BigDecimal total; + + /** + * JVM最大可用内存总数(M) + */ + private BigDecimal max; + + /** + * JVM空闲内存(M) + */ + private BigDecimal free; + + /** + * JDK版本 + */ + private String version; + + /** + * JDK路径 + */ + private String home; + + private BigDecimal used; + + private BigDecimal usage; + + public BigDecimal getTotal() + { + return total; + } + + public void setTotal(BigDecimal total) + { + this.total = total; + } + + public BigDecimal getMax() + { + return max; + } + + public void setMax(BigDecimal max) + { + this.max = max; + } + + public BigDecimal getFree() + { + return free; + } + + public void setFree(BigDecimal free) + { + this.free = free; + } + + public BigDecimal getUsed() { + return used; + } + + public void setUsed(BigDecimal used) { + this.used = used; + } + + public BigDecimal getUsage() { + return usage; + } + + public void setUsage(BigDecimal usage) { + this.usage = usage; + } + + /** + * 获取JDK名称 + */ + public String getName() + { + return ManagementFactory.getRuntimeMXBean().getVmName(); + } + + public String getVersion() + { + return version; + } + + public void setVersion(String version) + { + this.version = version; + } + + public String getHome() + { + return home; + } + + public void setHome(String home) + { + this.home = home; + } + + /** + * JDK启动时间 + */ + public String getStartTime() + { + return DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.getServerStartDate()); + } + + /** + * JDK运行时间 + */ + public String getRunTime() + { + return DateUtils.getDatePoor(DateUtils.getNowDate(), DateUtils.getServerStartDate()); + } +} diff --git a/src/main/java/com/luckyframe/project/monitor/server/domain/set/SetMem.java b/src/main/java/com/luckyframe/project/monitor/server/domain/set/SetMem.java new file mode 100644 index 0000000..6b330c8 --- /dev/null +++ b/src/main/java/com/luckyframe/project/monitor/server/domain/set/SetMem.java @@ -0,0 +1,67 @@ +package com.luckyframe.project.monitor.server.domain.set; + +import java.math.BigDecimal; + +/** + * 內存相关信息 + * + * @author ruoyi + */ +public class SetMem +{ + /** + * 内存总量 + */ + private BigDecimal total; + + /** + * 已用内存 + */ + private BigDecimal used; + + /** + * 剩余内存 + */ + private BigDecimal free; + + private BigDecimal usage; + + public BigDecimal getTotal() + { + return total; + } + + public void setTotal(BigDecimal total) + { + this.total = total; + } + + public BigDecimal getUsed() + { + return used; + } + + public void setUsed(BigDecimal used) + { + this.used = used; + } + + public BigDecimal getFree() + { + return free; + } + + public void setFree(BigDecimal free) + { + this.free = free; + } + + public BigDecimal getUsage() { + return usage; + } + + public void setUsage(BigDecimal usage) { + this.usage = usage; + } + +} diff --git a/src/main/java/com/luckyframe/project/monitor/server/domain/set/SetServer.java b/src/main/java/com/luckyframe/project/monitor/server/domain/set/SetServer.java new file mode 100644 index 0000000..ea69c76 --- /dev/null +++ b/src/main/java/com/luckyframe/project/monitor/server/domain/set/SetServer.java @@ -0,0 +1,88 @@ +package com.luckyframe.project.monitor.server.domain.set; + +import java.util.LinkedList; +import java.util.List; + +/** + * 服务器相关信息 + * + * @author ruoyi + */ +public class SetServer +{ + /** + * CPU相关信息 + */ + private SetCpu cpu = new SetCpu(); + + /** + * 內存相关信息 + */ + private SetMem mem = new SetMem(); + + /** + * JVM相关信息 + */ + private SetJvm jvm = new SetJvm(); + + /** + * 服务器相关信息 + */ + private SetSys sys = new SetSys(); + + /** + * 磁盘相关信息 + */ + private List sysFiles = new LinkedList(); + + public SetCpu getCpu() + { + return cpu; + } + + public void setCpu(SetCpu cpu) + { + this.cpu = cpu; + } + + public SetMem getMem() + { + return mem; + } + + public void setMem(SetMem mem) + { + this.mem = mem; + } + + public SetJvm getJvm() + { + return jvm; + } + + public void setJvm(SetJvm jvm) + { + this.jvm = jvm; + } + + public SetSys getSys() + { + return sys; + } + + public void setSys(SetSys sys) + { + this.sys = sys; + } + + public List getSysFiles() + { + return sysFiles; + } + + public void setSysFiles(List sysFiles) + { + this.sysFiles = sysFiles; + } + +} diff --git a/src/main/java/com/luckyframe/project/monitor/server/domain/set/SetSys.java b/src/main/java/com/luckyframe/project/monitor/server/domain/set/SetSys.java new file mode 100644 index 0000000..7fa6f27 --- /dev/null +++ b/src/main/java/com/luckyframe/project/monitor/server/domain/set/SetSys.java @@ -0,0 +1,84 @@ +package com.luckyframe.project.monitor.server.domain.set; + +/** + * 系统相关信息 + * + * @author ruoyi + */ +public class SetSys +{ + /** + * 服务器名称 + */ + private String computerName; + + /** + * 服务器Ip + */ + private String computerIp; + + /** + * 项目路径 + */ + private String userDir; + + /** + * 操作系统 + */ + private String osName; + + /** + * 系统架构 + */ + private String osArch; + + public String getComputerName() + { + return computerName; + } + + public void setComputerName(String computerName) + { + this.computerName = computerName; + } + + public String getComputerIp() + { + return computerIp; + } + + public void setComputerIp(String computerIp) + { + this.computerIp = computerIp; + } + + public String getUserDir() + { + return userDir; + } + + public void setUserDir(String userDir) + { + this.userDir = userDir; + } + + public String getOsName() + { + return osName; + } + + public void setOsName(String osName) + { + this.osName = osName; + } + + public String getOsArch() + { + return osArch; + } + + public void setOsArch(String osArch) + { + this.osArch = osArch; + } +} diff --git a/src/main/java/com/luckyframe/project/monitor/server/domain/set/SetSysFile.java b/src/main/java/com/luckyframe/project/monitor/server/domain/set/SetSysFile.java new file mode 100644 index 0000000..9e84fe4 --- /dev/null +++ b/src/main/java/com/luckyframe/project/monitor/server/domain/set/SetSysFile.java @@ -0,0 +1,116 @@ +package com.luckyframe.project.monitor.server.domain.set; + +import java.math.BigDecimal; + +/** + * 系统文件相关信息 + * + * @author ruoyi + */ +public class SetSysFile +{ + /** + * 盘符路径 + */ + private String dirName; + + /** + * 盘符类型 + */ + private String sysTypeName; + + /** + * 文件类型 + */ + private String typeName; + + /** + * 总大小 + */ + private String total; + + /** + * 剩余大小 + */ + private String free; + + /** + * 已经使用量 + */ + private String used; + + /** + * 资源的使用率 + */ + private BigDecimal usage; + + public String getDirName() + { + return dirName; + } + + public void setDirName(String dirName) + { + this.dirName = dirName; + } + + public String getSysTypeName() + { + return sysTypeName; + } + + public void setSysTypeName(String sysTypeName) + { + this.sysTypeName = sysTypeName; + } + + public String getTypeName() + { + return typeName; + } + + public void setTypeName(String typeName) + { + this.typeName = typeName; + } + + public String getTotal() + { + return total; + } + + public void setTotal(String total) + { + this.total = total; + } + + public String getFree() + { + return free; + } + + public void setFree(String free) + { + this.free = free; + } + + public String getUsed() + { + return used; + } + + public void setUsed(String used) + { + this.used = used; + } + + public BigDecimal getUsage() + { + return usage; + } + + public void setUsage(BigDecimal usage) + { + this.usage = usage; + } +} diff --git a/src/main/java/com/luckyframe/project/system/client/controller/ClientController.java b/src/main/java/com/luckyframe/project/system/client/controller/ClientController.java index b8a0a86..a1b79ec 100644 --- a/src/main/java/com/luckyframe/project/system/client/controller/ClientController.java +++ b/src/main/java/com/luckyframe/project/system/client/controller/ClientController.java @@ -1,5 +1,6 @@ package com.luckyframe.project.system.client.controller; +import java.util.HashMap; import java.util.List; import org.apache.shiro.authz.annotation.RequiresPermissions; @@ -15,9 +16,12 @@ import org.springframework.web.bind.annotation.ResponseBody; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.luckyframe.common.constant.ClientConstants; import com.luckyframe.common.constant.JobConstants; import com.luckyframe.common.constant.ScheduleConstants; import com.luckyframe.common.exception.BusinessException; +import com.luckyframe.common.utils.client.HttpRequest; import com.luckyframe.common.utils.poi.ExcelUtil; import com.luckyframe.common.utils.security.PermissionUtils; import com.luckyframe.framework.aspectj.lang.annotation.Log; @@ -27,6 +31,7 @@ import com.luckyframe.framework.web.domain.AjaxResult; import com.luckyframe.framework.web.page.TableDataInfo; import com.luckyframe.project.monitor.job.domain.Job; import com.luckyframe.project.monitor.job.service.IJobService; +import com.luckyframe.project.monitor.server.domain.set.SetServer; import com.luckyframe.project.system.client.domain.Client; import com.luckyframe.project.system.client.service.IClientService; import com.luckyframe.project.system.project.service.IProjectService; @@ -72,6 +77,23 @@ public class ClientController extends BaseController return getDataTable(list); } + @RequiresPermissions("system:client:view") + @GetMapping("/showMonitor/{clientId}") + public String showMonitor(@PathVariable("clientId") Integer clientId, ModelMap mmap) throws Exception + { + Client client = clientService.selectClientById(clientId); + String result = HttpRequest.httpClientGet( + "http://" + client.getClientIp() + ":" + ClientConstants.CLIENT_MONITOR_PORT + "/getClientMonitorData", + new HashMap(0)); + System.out.println(result); + JSONObject jSONObject = JSONObject.parseObject(result); + System.out.println(jSONObject.toJSONString()); + + SetServer server = JSONObject.parseObject(jSONObject.toJSONString(),SetServer.class); + System.out.println(JSONObject.toJSONString(server)); + mmap.put("server", server); + return prefix + "/showMonitor"; + } /** * 导出客户端管理列表 diff --git a/src/main/resources/static/ajax/libs/validate/jquery.validate.extend.js b/src/main/resources/static/ajax/libs/validate/jquery.validate.extend.js index 298d989..70f5258 100644 --- a/src/main/resources/static/ajax/libs/validate/jquery.validate.extend.js +++ b/src/main/resources/static/ajax/libs/validate/jquery.validate.extend.js @@ -18,7 +18,7 @@ $(document).ready(function(){ },"请填写正确的座机号码"); // IP地址验证 jQuery.validator.addMethod("isIp", function(value, element) { - return this.optional(element) || /^(([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.)(([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.){2}([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))$/.test(value); + return this.optional(element) || /^(([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.)(([0-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.){2}([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))$/.test(value); }, "请填写正确的IP地址。"); //姓名校验 jQuery.validator.addMethod("isName",function(value,element){ diff --git a/src/main/resources/templates/main.html b/src/main/resources/templates/main.html index 12d16a1..36bd375 100644 --- a/src/main/resources/templates/main.html +++ b/src/main/resources/templates/main.html @@ -140,7 +140,7 @@
-
扫一扫加入QQ交流群
+
扫一扫加入QQ群
diff --git a/src/main/resources/templates/system/client/client.html b/src/main/resources/templates/system/client/client.html index fc04bde..ccef421 100644 --- a/src/main/resources/templates/system/client/client.html +++ b/src/main/resources/templates/system/client/client.html @@ -38,6 +38,9 @@ 修改 + + 监控资源 + 删除 @@ -60,6 +63,7 @@ updateUrl: prefix + "/edit/{id}", removeUrl: prefix + "/remove", exportUrl: prefix + "/export", + customUrl: prefix + "/showMonitor/{id}", modalName: "客户端", search: false, showExport: true, @@ -81,7 +85,7 @@ }, { field : 'status', - title : '客户端超时', + title : '客户端状态', formatter : function(value, row, index) { if(value==0){ @@ -122,6 +126,23 @@ }; $.table.init(options); }); + + function showMonitor() { + var row= $.map($('#bootstrap-table').bootstrapTable('getSelections'), function (row) { + return row; + }); + + if(0!=row[0].status){ + $.modal.msgWarning("客户端非正常状态,不能查询"); + return true; + } + + var url = "/404.html"; + if ($.common.isNotEmpty(row)) { + url = $.table._option.customUrl.replace("{id}", row[0].clientId); + } + $.modal.openViewFull("客户端资源监控 "+row[0].clientName+" ["+row[0].clientIp+"]", url, null, null); + } \ No newline at end of file diff --git a/src/main/resources/templates/system/client/showMonitor.html b/src/main/resources/templates/system/client/showMonitor.html new file mode 100644 index 0000000..05736db --- /dev/null +++ b/src/main/resources/templates/system/client/showMonitor.html @@ -0,0 +1,254 @@ + + + + + +
+
+
+
+
+
+
CPU
+
+ + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
属性
核心数0个
用户使用率0%
系统使用率0%
当前空闲率0%
+
+
+
+ +
+
+
+
内存
+
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
属性内存JVM
总内存0GB0MB
已用内存0GB0MB
剩余内存0GB0MB
使用率[[${server.mem.usage}]]%[[${server.jvm.usage}]]%
+
+
+
+
+ +
+
+
+
+
服务器信息
+ +
+
+
+
+ + + + + + + + + + + + + + + +
服务器名称RuoYi操作系统Linux
服务器IP127.0.0.1系统架构amd64
+
+
+
+
+
+
+ +
+
+
+
+
Java虚拟机信息
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Java名称JavaJava版本1.8.0
启动时间2018-12-31 00:00:00运行时长0天0时0分0秒
安装路径
项目路径
+
+
+
+
+
+
+ +
+
+
+
+
磁盘状态
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
盘符路径文件系统盘符类型总大小可用大小已用大小已用百分比
C:\NTFSlocal0GB0GB0GB[[${sysFile.usage}]]%
+
+
+
+
+
+
+
+
+ +
+ +