文章目录
前言
本来想着等待javamis低代码开发平台完全研发完成后,再按照功能模块的方式一一将功能点详细写出来,但随着javamis平台越研发越大,就会导致前面研发功能模块过程的知识点遗漏记下来,经过仔细思考后,决定还是先不要那么完美,在开发过程遇到哪些功能点就记录哪些,以免知识点再次遗漏,待整个javamis平台研发完,再整理博客的顺序 - 便于小伙伴们的参考,同时,请小伙伴们届时留意我的动态发布内容,欢迎加入QQ技术交流群:327773608 |
这是因为,服务监控模块可以实现实时动态的展示出java 虚拟机(jvm)的动态情况,帮助管理人员对服务器的软件、硬件的维护....,平台采用OSHI免费的跨平台服务器检测来实现。
javamis-parent父工程下,pom.xml文件添加以下依赖
1 <properties> 2 <oshi.version>6.4.5</oshi.version> 3 <jna.version>5.13.0</jna.version> 4 </properties>
1 <dependencyManagement> 2 <dependencies> 3 <!-- 监控服务-获取系统信息 --> 4 <dependency> 5 <groupId>com.github.oshi</groupId> 6 <artifactId>oshi-core</artifactId> 7 <version>${oshi.version}</version> 8 </dependency> 9 <dependency> 10 <groupId>net.java.dev.jna</groupId> 11 <artifactId>jna</artifactId> 12 <version>${jna.version}</version> 13 </dependency> 14 <dependency> 15 <groupId>net.java.dev.jna</groupId> 16 <artifactId>jna-platform</artifactId> 17 <version>${jna.version}</version> 18 </dependency> 19 </dependencies> 20 </dependencyManagement>
javamis-core 子核心工程下,pom.xml文件引用父工程的依赖
1 <dependencies> 2 <!-- 监控服务-获取系统信息 --> 3 <dependency> 4 <groupId>com.github.oshi</groupId> 5 <artifactId>oshi-core</artifactId> 6 </dependency> 7 <dependency> 8 <groupId>net.java.dev.jna</groupId> 9 <artifactId>jna</artifactId> 10 </dependency> 11 <dependency> 12 <groupId>net.java.dev.jna</groupId> 13 <artifactId>jna-platform</artifactId> 14 </dependency> 15 </dependencies>
注1:以上引入oshi和jna包时,请注意:需要先在父工程javamis-parent下引入, 然后再子工程javamis-core下引入使用!
注2: 如果报:“ java.lang.NoClassDefFoundError: com/sun/jna/platform/win32/VersionHelpers”,请检查是否引用了jna和jna-platform!!!
注3:请检查您是否使用了最新版本,这果我使用的版本为:oshi最新版本:6.46;jna和jna-platform最新版本:5.13.0;
2.2. 开发过程
2.2.1. 实体类
Monitor.java
1 /** 2 * Copyright (c) 2016-Now http://www.javamis.com All rights reserved. 3 * No deletion without permission, or be held responsible to law. 4 */ 5 package com.javamis.modular.system.entity; 6 import java.net.UnknownHostException; 7 import java.io.Serializable; 8 import java.lang.management.ManagementFactory; 9 import java.util.LinkedList; 10 import java.util.List; 11 import java.util.Properties; 12 import com.javamis.common.util.DateUtils; 13 import com.javamis.common.util.DoubleUtil; 14 import com.javamis.common.util.IpUtil; 15 16 import lombok.Data; 17 import lombok.EqualsAndHashCode; 18 import lombok.experimental.Accessors; 19 20 import oshi.SystemInfo; 21 import oshi.hardware.CentralProcessor; 22 import oshi.hardware.CentralProcessor.TickType; 23 import oshi.hardware.GlobalMemory; 24 import oshi.hardware.HardwareAbstractionLayer; 25 import oshi.software.os.FileSystem; 26 import oshi.software.os.OSFileStore; 27 import oshi.software.os.OperatingSystem; 28 import oshi.util.Util; 29 /** 30 * @name: 服务监控实体类 31 * @version:1.0.2 32 * @author: HuiJia 33 * @QQ号: 763236277 34 * @QQ群: 327773608 35 * @邮箱: javamis@163.com 36 * @site: http://www.javamis.com 37 */ 38 @Data 39 @EqualsAndHashCode(callSuper = false) 40 @Accessors(chain = true) 41 public class Monitor implements Serializable { 42 private static final long serialVersionUID = 1L; 43 //等待1秒 44 private static final int OSHI_WAIT_TIME = 1000; 45 46 /********************以下是CPU的监控信息******************************/ 47 /** 48 * CPU核心数 49 */ 50 private int cpuKernelNum; 51 52 /** 53 * CPU总的使用率 54 */ 55 private double cpuTotal; 56 57 /** 58 * CPU系统使用率 59 */ 60 private double cpuSys; 61 62 /** 63 * CPU用户使用率 64 */ 65 private double cpuUsed; 66 67 /** 68 * CPU当前等待率 69 */ 70 private double cpuWait; 71 72 /** 73 * CPU当前空闲率 74 */ 75 private double cpuFree; 76 77 /********************以下是JVM虚拟机的监控信息******************************/ 78 /** 79 * 当前JVM占用的内存总数(M) 80 */ 81 private double jvmTotal; 82 83 /** 84 * JVM最大可用内存总数(M) 85 */ 86 private double jvmMax; 87 88 /** 89 * JVM空闲内存(M) 90 */ 91 private double jvmFree; 92 93 /** 94 * JVM使用率 95 */ 96 @SuppressWarnings("unused") 97 private double jvmUsage; 98 99 /** 100 * JDK版本 101 */ 102 private String jvmVersion; 103 104 /** 105 * JDK路径 106 */ 107 private String jvmHome; 108 109 /********************以下是内存的监控信息******************************/ 110 /** 111 * 内存总量 112 */ 113 private double memoryTotal; 114 115 /** 116 * 已用内存 117 */ 118 private double memoryUsed; 119 120 /** 121 * 内存使用率 122 */ 123 @SuppressWarnings("unused") 124 private double memoryUsage; 125 126 /** 127 * 剩余内存 128 */ 129 private double memoryFree; 130 131 /********************以下是服务器的监控信息******************************/ 132 /** 133 * 服务器名称 134 */ 135 private String computerName; 136 137 /** 138 * 服务器Ip 139 */ 140 private String computerIp; 141 142 /** 143 * 服务器内项目路径 144 */ 145 private String computerProjectDir; 146 147 /** 148 * 服务器操作系统 149 */ 150 private String computerOsName; 151 152 /** 153 * 服务器系统架构 154 */ 155 156 /********************以下是磁盘的监控信息******************************/ 157 private List<ComputerDisk> sysFiles = new LinkedList<ComputerDisk>(); 158 159 public Monitor() throws Exception{assignData();} 160 161 public void assignData() throws Exception{ 162 SystemInfo si = new SystemInfo(); 163 HardwareAbstractionLayer hal = si.getHardware(); 164 CentralProcessor centralProcessor = hal.getProcessor(); 165 setCpuInfo(centralProcessor); 166 setMemoryInfo(hal.getMemory()); 167 setComputerInfo(); 168 setJvmInfo(); 169 setComputerDisk(si.getOperatingSystem()); 170 } 171 172 173 174 private String osArch; 175 public double getCpuTotal(){ 176 return DoubleUtil.round(DoubleUtil.mul(cpuTotal, 100), 2); 177 } 178 public double getCpuSys(){ 179 return DoubleUtil.round(DoubleUtil.mul(cpuSys / cpuTotal, 100), 2); 180 } 181 public double getCpuUsed(){ 182 return DoubleUtil.round(DoubleUtil.mul(cpuUsed / cpuTotal, 100), 2); 183 } 184 public double getCpuWait(){ 185 return DoubleUtil.round(DoubleUtil.mul(cpuWait / cpuTotal, 100), 2); 186 } 187 public double getCpuFree(){ 188 return DoubleUtil.round(DoubleUtil.mul(cpuFree / cpuTotal, 100), 2); 189 } 190 191 192 public double getMemoryTotal(){ 193 return DoubleUtil.div(memoryTotal, (1024 * 1024 * 1024), 2); 194 } 195 public double getMemoryUsed(){ 196 return DoubleUtil.div(memoryUsed, (1024 * 1024 * 1024), 2); 197 } 198 public double getMemoryFree(){ 199 return DoubleUtil.div(memoryFree, (1024 * 1024 * 1024), 2); 200 } 201 public double getMemoryUsage(){ 202 return DoubleUtil.mul(DoubleUtil.div(memoryUsed, memoryTotal, 4), 100); 203 } 204 205 206 public double getJvmTotal() 207 { 208 return DoubleUtil.div(jvmTotal, (1024 * 1024), 2); 209 } 210 public double getJvmMax() 211 { 212 return DoubleUtil.div(jvmMax, (1024 * 1024), 2); 213 } 214 public double getJvmFree() 215 { 216 return DoubleUtil.div(jvmFree, (1024 * 1024), 2); 217 } 218 public double getJvmUsed() 219 { 220 return DoubleUtil.div(jvmTotal - jvmFree, (1024 * 1024), 2); 221 } 222 public double getJvmUsage() 223 { 224 return DoubleUtil.mul(DoubleUtil.div(jvmTotal - jvmFree, jvmTotal, 4), 100); 225 } 226 227 /** 228 * 获取JDK名称 229 */ 230 public String getJvmName() 231 { 232 return ManagementFactory.getRuntimeMXBean().getVmName(); 233 } 234 235 public String getJvmVersion() 236 { 237 return jvmVersion; 238 } 239 public String getJvmHome() 240 { 241 return jvmHome; 242 } 243 /** 244 * JDK启动时间 245 */ 246 public String getJvmStartTime() 247 { 248 return DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.getServerStartDate()); 249 } 250 251 /** 252 * JDK运行时间 253 */ 254 public String getJvmRunTime() 255 { 256 return DateUtils.timeDistance(DateUtils.getNowDate(), DateUtils.getServerStartDate()); 257 } 258 259 /** 260 * 运行参数 261 */ 262 public String getJvmInputArgs() 263 { 264 return ManagementFactory.getRuntimeMXBean().getInputArguments().toString(); 265 } 266 /** 267 * 设置CPU信息 268 */ 269 private void setCpuInfo(CentralProcessor processor) 270 { 271 // CPU信息 272 long[] prevTicks = processor.getSystemCpuLoadTicks(); 273 Util.sleep(OSHI_WAIT_TIME); 274 long[] ticks = processor.getSystemCpuLoadTicks(); 275 long nice = ticks[TickType.NICE.getIndex()] - prevTicks[TickType.NICE.getIndex()]; 276 long irq = ticks[TickType.IRQ.getIndex()] - prevTicks[TickType.IRQ.getIndex()]; 277 long softirq = ticks[TickType.SOFTIRQ.getIndex()] - prevTicks[TickType.SOFTIRQ.getIndex()]; 278 long steal = ticks[TickType.STEAL.getIndex()] - prevTicks[TickType.STEAL.getIndex()]; 279 long cSys = ticks[TickType.SYSTEM.getIndex()] - prevTicks[TickType.SYSTEM.getIndex()]; 280 long user = ticks[TickType.USER.getIndex()] - prevTicks[TickType.USER.getIndex()]; 281 long iowait = ticks[TickType.IOWAIT.getIndex()] - prevTicks[TickType.IOWAIT.getIndex()]; 282 long idle = ticks[TickType.IDLE.getIndex()] - prevTicks[TickType.IDLE.getIndex()]; 283 long totalCpu = user + nice + cSys + idle + iowait + irq + softirq + steal; 284 setCpuKernelNum(processor.getLogicalProcessorCount()); 285 setCpuTotal(totalCpu); 286 setCpuSys(cSys); 287 setCpuUsed(user); 288 setCpuWait(iowait); 289 setCpuFree(idle); 290 } 291 292 /** 293 * 设置内存信息 294 */ 295 private void setMemoryInfo(GlobalMemory memory){ 296 setMemoryTotal(memory.getTotal()); 297 setMemoryUsed(memory.getTotal() - memory.getAvailable()); 298 setMemoryFree(memory.getAvailable()); 299 setMemoryUsage(getMemoryUsage()); 300 } 301 302 /** 303 * 设置服务器信息 304 */ 305 private void setComputerInfo(){ 306 Properties props = System.getProperties(); 307 setComputerName(IpUtil.getHostName()); 308 setComputerIp(IpUtil.getHostIp()); 309 setComputerOsName(props.getProperty("os.name")); 310 setOsArch(props.getProperty("os.arch")); 311 setComputerProjectDir(props.getProperty("user.dir")); 312 } 313 314 /** 315 * 设置Java虚拟机 316 */ 317 private void setJvmInfo() throws UnknownHostException{ 318 Properties props = System.getProperties(); 319 setJvmTotal(Runtime.getRuntime().totalMemory()); 320 setJvmMax(Runtime.getRuntime().maxMemory()); 321 setJvmFree(Runtime.getRuntime().freeMemory()); 322 setJvmVersion(props.getProperty("java.version")); 323 setJvmHome(props.getProperty("java.home")); 324 setJvmUsage(getJvmUsage()); 325 } 326 327 /** 328 * 设置磁盘信息 329 */ 330 private void setComputerDisk(OperatingSystem os) 331 { 332 FileSystem fileSystem = os.getFileSystem(); 333 List<OSFileStore> fsArray = fileSystem.getFileStores(); 334 for (OSFileStore fs : fsArray) 335 { 336 long free = fs.getUsableSpace(); 337 long total = fs.getTotalSpace(); 338 long used = total - free; 339 ComputerDisk sysFile = new ComputerDisk(); 340 sysFile.setDiskDir(fs.getMount()); 341 sysFile.setDiskType(fs.getType()); 342 sysFile.setDiskTypeName(fs.getName()); 343 sysFile.setDiskTotal(convertFileSize(total)); 344 sysFile.setDiskFree(convertFileSize(free)); 345 sysFile.setDiskUsed(convertFileSize(used)); 346 sysFile.setDiskUsage(DoubleUtil.mul(DoubleUtil.div(used, total, 4), 100)); 347 sysFiles.add(sysFile); 348 } 349 } 350 351 /** 352 * 字节转换 353 * 354 * @param size 字节大小 355 * @return 转换后值 356 */ 357 public String convertFileSize(long size){ 358 long kb = 1024; 359 long mb = kb * 1024; 360 long gb = mb * 1024; 361 if (size >= gb){ 362 return String.format("%.1f GB", (float) size / gb); 363 } 364 else if (size >= mb){ 365 float f = (float) size / mb; 366 return String.format(f > 100 ? "%.0f MB" : "%.1f MB", f); 367 } 368 else if (size >= kb){ 369 float f = (float) size / kb; 370 return String.format(f > 100 ? "%.0f KB" : "%.1f KB", f); 371 }else{ 372 return String.format("%d B", size); 373 } 374 } 375 376 @Data 377 @EqualsAndHashCode(callSuper = false) 378 @Accessors(chain = true) 379 private class ComputerDisk{ 380 /** 381 * 盘符路径 382 */ 383 private String diskDir; 384 385 /** 386 * 盘符类型 387 */ 388 private String diskType; 389 390 /** 391 * 文件类型 392 */ 393 private String diskTypeName; 394 395 /** 396 * 总大小 397 */ 398 private String diskTotal; 399 400 /** 401 * 剩余大小 402 */ 403 private String diskFree; 404 405 /** 406 * 已经使用量 407 */ 408 private String diskUsed; 409 410 /** 411 * 资源的使用率 412 */ 413 private double diskUsage; 414 } 415 }
2.2.2. 控制层类
MonitorController.java1 package com.javamis.modular.system.controller; 2 3 import org.springframework.stereotype.Controller; 4 import org.springframework.ui.Model; 5 import org.springframework.ui.ModelMap; 6 import org.springframework.web.bind.annotation.GetMapping; 7 import org.springframework.web.bind.annotation.RequestMapping; 8 import org.springframework.web.servlet.ModelAndView; 9 import com.javamis.modular.system.entity.Monitor; 10 11 /** 12 * @name: 用户当前在线会话Controller层 13 * @version:1.0.2 14 * @author: HuiJia 15 * @QQ号: 763236277 16 * @QQ群: 327773608 17 * @邮箱: javamis@163.com 18 * @site: http://www.javamis.com 19 */ 20 @Controller 21 @RequestMapping("/monitor") 22 public class MonitorController { 23 private String prefix = "/system/monitor/computer/"; 24 25 @GetMapping(value="/computer") 26 public String userList(ModelAndView mav,Model model,ModelMap mmap) throws Exception{ 27 Monitor monitor = new Monitor(); 28 model.addAttribute("monitor",monitor); 29 return prefix + "list"; 30 } 31 }
2.2.3. html页面
1 <!DOCTYPE html> 2 <head> 3 <meta charset="UTF-8"> 4 <link rel="stylesheet" href="${ctxPath}/css/font-awesome.min.css" /> 5 <script src="${ctxPath}/js/plugins/jquery/jquery-3.2.1.min.js"></script> 6 <script type="text/javascript" src="${ctxPath}/js/plugins/jquery/jquery-1.0.2.min.js"></script> 7 <link rel="stylesheet" href="${ctxPath}/css/plugins/bootstrap/bootstrap.css"/> 8 <link rel="stylesheet" href="${ctxPath}/css/plugins/bootstrap/bootstrap.min.css"/> 9 <script src="${ctxPath}/js/plugins/bootstrap/bootstrap.js"></script> 10 </head> 11 <style>.gray-bg{background-color:#f3f3f4;color: #676a6c;padding-right: 75px;} .row-top{margin: 23px -73px 0px -47px;} .row-inner{margin-right:0px !important;} .align{margin-left: -52px !important;margin-right: -64px !important} .float-e-margins{margin-bottom: 25px;background-color: #fff;border: 1px solid #ddd;border-radius: 4px;height: 100%;-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .05);} .ibox-title{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;background-color:#fff;border-color:#e7eaec;-webkit-border-image:none;-o-border-image:none;border-image:none;border-style:solid solid none;border-width:0;color:inherit;margin-bottom:0;padding:14px 15px 7px;min-height:40px} .ibox-title h5{display: inline-block;font-size: 14px;margin: 0 0 7px;padding: 0;text-overflow: ellipsis;float: left;font-weight: 600;} .ibox-tools{display: inline-block;float: right;margin-top: 0;position: relative;padding: 0;cursor: pointer;} .ibox-content{background-color: #fff;color: inherit;padding: 15px 20px 20px 20px;border-color: #e7eaec;-webkit-border-image: none;-o-border-image: none;border-image: none;border-style: solid solid none;border-width: 1px 0;} .text-danger{color: #ed5565;}</style> 12 <body class="gray-bg"> 13 <div class="wrapper wrapper-content"> 14 <div class="col-sm-12"> 15 <div class="row row-top"> 16 <div class="col-sm-6"> 17 <div class="ibox float-e-margins" > 18 <div class="ibox-title"> 19 <h5 style=""><i class="fa fa-microchip"></i> CPU</h5> 20 <div class="ibox-tools"> 21 <a class="collapse-link"><i class="fa fa-chevron-up"></i></a> 22 <a class="close-link"><i class="fa fa-times"></i></a> 23 </div> 24 </div> 25 <div class="ibox-content"> 26 <table class="table table-hover no-margins"> 27 <thead> 28 <tr> 29 <th>属性</th> 30 <th>使用情况</th> 31 </tr> 32 </thead> 33 <tbody> 34 <tr> 35 <td>核心数</td> 36 <td>${monitor.cpuKernelNum}个</td> 37 </tr> 38 <tr> 39 <td>用户使用率</td> 40 <%if(monitor.cpuUsed >= 80){%> <td class="text-danger">${monitor.cpuUsed}%</td> <%}else{%> <td>${monitor.cpuUsed}%</td> <%}%> 41 </tr> 42 <tr> 43 <td>系统使用率</td> 44 <%if(monitor.cpuSys >= 80){%> <td class="text-danger">${monitor.cpuSys}%</td> <%}else{%> <td>${monitor.cpuSys}%</td> <%}%> 45 </tr> 46 <tr> 47 <td>当前空闲率</td> 48 <%if(monitor.cpuFree >= 80){%> <td class="text-danger">${monitor.cpuFree}%</td> <%}else{%> <td>${monitor.cpuFree}%</td> <%}%> 49 </tr> 50 </tbody> 51 </table> 52 </div> 53 </div> 54 </div> 55 56 <div class="col-sm-6"> 57 <div class="ibox float-e-margins"> 58 <div class="ibox-title"> 59 <h5><i class="fa fa-ticket"></i> 内存</h5> 60 <div class="ibox-tools"> 61 <a class="collapse-link"><i class="fa fa-chevron-up"></i></a> 62 <a class="close-link"><i class="fa fa-times"></i></a> 63 </div> 64 </div> 65 <div class="ibox-content"> 66 <table class="table table-hover no-margins"> 67 <thead> 68 <tr> 69 <th>属性</th> 70 <th>内存</th> 71 <th>JVM虚拟机使用情况</th> 72 </tr> 73 </thead> 74 <tbody> 75 <tr> 76 <td>总内存</td> 77 <td>${monitor.memoryTotal}GB</td> 78 <td>${monitor.jvmTotal}MB</td> 79 </tr> 80 <tr> 81 <td>已用内存</td> 82 <td>${monitor.memoryUsed}GB</td> 83 <td>${monitor.jvmUsed}MB</td> 84 </tr> 85 <tr> 86 <td>剩余内存</td> 87 <%if(monitor.memoryFree <= 1){%> <td class="text-danger">${monitor.memoryFree}GB</td> <%}else{%> <td>${monitor.memoryFree}GB</td> <%}%> 88 <%if(monitor.jvmFree >= 1000){%> <td class="text-danger">${monitor.jvmFree}MB</td> <%}else{%> <td>${monitor.jvmFree}MB</td> <%}%> 89 </tr> 90 <tr> 91 <td>使用率</td> 92 <% if(monitor.memoryUsage >= 80 ){ %> <td class="text-danger">${monitor.memoryUsage}%</td> <% } else {%> <td>${monitor.memoryUsage}%</td> <% } %> 93 <% if(monitor.jvmUsage >= 80){ %> <td class="text-danger">${monitor.jvmUsage}%</td> <% } else {%> <td>${monitor.jvmUsage}%</td> <% } %> 94 </tr> 95 </tbody> 96 </table> 97 </div> 98 </div> 99 </div> 100 </div> 101 102 <div class="row align"> 103 <div class="col-sm-12"> 104 <div class="ibox float-e-margins"> 105 <div class="ibox-title"> 106 <h5><i class="fa fa-windows"></i> 服务器信息</h5> 107 <div class="ibox-tools"> 108 <a class="collapse-link"> 109 <i class="fa fa-chevron-up"></i> 110 </a> 111 <a class="close-link"> 112 <i class="fa fa-times"></i> 113 </a> 114 </div> 115 </div> 116 <div class="ibox-content"> 117 <div class="row row-inner"> 118 <div class="col-sm-12"> 119 <table class="table table-hover margin bottom"> 120 <tbody> 121 <tr> 122 <td>服务器名称</td> 123 <td>${monitor.computerName}</td> 124 <td>操作系统</td> 125 <td>${monitor.computerOsName}</td> 126 </tr> 127 <tr> 128 <td>服务器IP</td> 129 <td>${monitor.computerIp}</td> 130 <td>系统架构</td> 131 <td>${monitor.osArch}</td> 132 </tr> 133 </tbody> 134 </table> 135 </div> 136 </div> 137 </div> 138 </div> 139 </div> 140 </div> 141 142 <div class="row align"> 143 <div class="col-sm-12"> 144 <div class="ibox float-e-margins"> 145 <div class="ibox-title"> 146 <h5><i class="fa fa-coffee"></i> Java虚拟机信息</h5> 147 <div class="ibox-tools"> 148 <a class="collapse-link"> 149 <i class="fa fa-chevron-up"></i> 150 </a> 151 <a class="close-link"> 152 <i class="fa fa-times"></i> 153 </a> 154 </div> 155 </div> 156 <div class="ibox-content"> 157 <div class="row row-inner"> 158 <div class="col-sm-12"> 159 <table class="table table-hover margin bottom" style="table-layout:fixed;"> 160 <tbody> 161 <tr> 162 <td>Java名称</td> 163 <td>${monitor.jvmName}</td> 164 <td>Java版本</td> 165 <td>${monitor.jvmVersion}</td> 166 </tr> 167 <tr> 168 <td>启动时间</td> 169 <td>${monitor.jvmStartTime}</td> 170 <td>运行时长</td> 171 <td>${monitor.jvmRunTime}</td> 172 </tr> 173 <tr> 174 <td colspan="1">安装路径</td> 175 <td colspan="3">${monitor.jvmHome}</td> 176 </tr> 177 <tr> 178 <td colspan="1">项目路径</td> 179 <td colspan="3">${monitor.computerProjectDir}</td> 180 </tr> 181 <tr> 182 <td colspan="1">运行参数</td> 183 <td colspan="3">${monitor.jvmInputArgs}</td> 184 </tr> 185 </tbody> 186 </table> 187 </div> 188 </div> 189 </div> 190 </div> 191 </div> 192 </div> 193 194 <div class="row align"> 195 <div class="col-sm-12"> 196 <div class="ibox float-e-margins"> 197 <div class="ibox-title"> 198 <h5><i class="fa fa-hdd-o"></i> 磁盘状态</h5> 199 <div class="ibox-tools"> 200 <a class="collapse-link"> 201 <i class="fa fa-chevron-up"></i> 202 </a> 203 <a class="close-link"> 204 <i class="fa fa-times"></i> 205 </a> 206 </div> 207 </div> 208 <div class="ibox-content"> 209 <div class="row row-inner"> 210 <div class="col-sm-12"> 211 <table class="table table-hover margin bottom"> 212 <thead> 213 <tr> 214 <th>盘符路径</th> 215 <th>文件系统</th> 216 <th>盘符类型</th> 217 <th>总大小</th> 218 <th>可用大小</th> 219 <th>已用大小</th> 220 <th>已用百分比</th> 221 </tr> 222 </thead> 223 <tbody> 224 <% for(item in monitor.sysFiles){ %> 225 <tr> 226 <td>${item.diskDir}</td> 227 <td>${item.diskType}</td> 228 <td>${item.diskTypeName}</td> 229 <td>${item.diskTotal}GB</td> 230 <td>${item.diskFree}GB</td> 231 <td>${item.diskUsed}GB</td> 232 <%if(item.diskUsage >= 80){%> <td class="text-danger">${item.diskUsage}%</td> <%}else{%> <td>${item.diskUsage}%</td> <%}%> 233 </tr> 234 <% } %> 235 </tbody> 236 </table> 237 </div> 238 </div> 239 </div> 240 </div> 241 </div> 242 </div> 243 </div> 244 </div> 245 </body> 246 <script> 247 $(".modal").appendTo("body"), $("[data-toggle=popover]").popover(), $(".collapse-link").click(function() { 248 var div_ibox = $(this).closest("div.ibox"), 249 e = $(this).find("i"), 250 i = div_ibox.find("div.ibox-content"); 251 i.slideToggle(200), 252 e.toggleClass("fa-chevron-up").toggleClass("fa-chevron-down"), 253 div_ibox.toggleClass("").toggleClass("border-bottom"), 254 setTimeout(function() { 255 div_ibox.resize(); 256 }, 50); 257 }), $(".close-link").click(function () { 258 var div_ibox = $(this).closest("div.ibox"); 259 div_ibox.remove() 260 }); 261 </script> 262 </html>
下面是【服务监控】开发完成后的效果图:
关于作者
本作者,北京工业大学博士研究生,拥有十五年软件研发经验,曾就职于日企NEC、中国电信研究院、中国联通研究院、中国民航数据中心等国企架构师、技术经理,精通Java/C#/Android/Python等开发语言,善于搭建Nginx高性能服务、负载均衡、Redis等;曾从事某互联网、物联网传感、大数据分析、Gis地图、政府协同办公等行业;
同时,对开源框架有深入研究,推了Javamis快速开发平台(官网: http://www.javamis.com/ 源代码下载:https://gitee.com/javamis/flowable ),自研多个开源项目托管在Gitee和GitHub,欢迎加入QQ 3群交流:327773608
读后有收获可以支付宝请作者喝咖啡: