index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <div class="app-container">
  3. <el-row>
  4. <el-col :span="12" class="card-box">
  5. <el-card>
  6. <div slot="header"><span>CPU</span></div>
  7. <div class="el-table el-table--enable-row-hover el-table--medium">
  8. <table cellspacing="0" style="width: 100%;">
  9. <thead>
  10. <tr>
  11. <th class="is-leaf"><div class="cell">属性</div></th>
  12. <th class="is-leaf"><div class="cell">值</div></th>
  13. </tr>
  14. </thead>
  15. <tbody>
  16. <tr>
  17. <td><div class="cell">核心数</div></td>
  18. <td><div class="cell" v-if="server.cpu">{{ server.cpu.cpuNum }}</div></td>
  19. </tr>
  20. <tr>
  21. <td><div class="cell">用户使用率</div></td>
  22. <td><div class="cell" v-if="server.cpu">{{ server.cpu.used }}%</div></td>
  23. </tr>
  24. <tr>
  25. <td><div class="cell">系统使用率</div></td>
  26. <td><div class="cell" v-if="server.cpu">{{ server.cpu.sys }}%</div></td>
  27. </tr>
  28. <tr>
  29. <td><div class="cell">当前空闲率</div></td>
  30. <td><div class="cell" v-if="server.cpu">{{ server.cpu.free }}%</div></td>
  31. </tr>
  32. </tbody>
  33. </table>
  34. </div>
  35. </el-card>
  36. </el-col>
  37. <el-col :span="12" class="card-box">
  38. <el-card>
  39. <div slot="header"><span>内存</span></div>
  40. <div class="el-table el-table--enable-row-hover el-table--medium">
  41. <table cellspacing="0" style="width: 100%;">
  42. <thead>
  43. <tr>
  44. <th class="is-leaf"><div class="cell">属性</div></th>
  45. <th class="is-leaf"><div class="cell">内存</div></th>
  46. <th class="is-leaf"><div class="cell">JVM</div></th>
  47. </tr>
  48. </thead>
  49. <tbody>
  50. <tr>
  51. <td><div class="cell">总内存</div></td>
  52. <td><div class="cell" v-if="server.mem">{{ server.mem.total }}G</div></td>
  53. <td><div class="cell" v-if="server.jvm">{{ server.jvm.total }}M</div></td>
  54. </tr>
  55. <tr>
  56. <td><div class="cell">已用内存</div></td>
  57. <td><div class="cell" v-if="server.mem">{{ server.mem.used}}G</div></td>
  58. <td><div class="cell" v-if="server.jvm">{{ server.jvm.used}}M</div></td>
  59. </tr>
  60. <tr>
  61. <td><div class="cell">剩余内存</div></td>
  62. <td><div class="cell" v-if="server.mem">{{ server.mem.free }}G</div></td>
  63. <td><div class="cell" v-if="server.jvm">{{ server.jvm.free }}M</div></td>
  64. </tr>
  65. <tr>
  66. <td><div class="cell">使用率</div></td>
  67. <td><div class="cell" v-if="server.mem" :class="{'text-danger': server.mem.usage > 80}">{{ server.mem.usage }}%</div></td>
  68. <td><div class="cell" v-if="server.jvm" :class="{'text-danger': server.jvm.usage > 80}">{{ server.jvm.usage }}%</div></td>
  69. </tr>
  70. </tbody>
  71. </table>
  72. </div>
  73. </el-card>
  74. </el-col>
  75. <el-col :span="24" class="card-box">
  76. <el-card>
  77. <div slot="header">
  78. <span>服务器信息</span>
  79. </div>
  80. <div class="el-table el-table--enable-row-hover el-table--medium">
  81. <table cellspacing="0" style="width: 100%;">
  82. <tbody>
  83. <tr>
  84. <td><div class="cell">服务器名称</div></td>
  85. <td><div class="cell" v-if="server.sys">{{ server.sys.computerName }}</div></td>
  86. <td><div class="cell">操作系统</div></td>
  87. <td><div class="cell" v-if="server.sys">{{ server.sys.osName }}</div></td>
  88. </tr>
  89. <tr>
  90. <td><div class="cell">服务器IP</div></td>
  91. <td><div class="cell" v-if="server.sys">{{ server.sys.computerIp }}</div></td>
  92. <td><div class="cell">系统架构</div></td>
  93. <td><div class="cell" v-if="server.sys">{{ server.sys.osArch }}</div></td>
  94. </tr>
  95. </tbody>
  96. </table>
  97. </div>
  98. </el-card>
  99. </el-col>
  100. <el-col :span="24" class="card-box">
  101. <el-card>
  102. <div slot="header">
  103. <span>Java虚拟机信息</span>
  104. </div>
  105. <div class="el-table el-table--enable-row-hover el-table--medium">
  106. <table cellspacing="0" style="width: 100%;">
  107. <tbody>
  108. <tr>
  109. <td><div class="cell">Java名称</div></td>
  110. <td><div class="cell" v-if="server.jvm">{{ server.jvm.name }}</div></td>
  111. <td><div class="cell">Java版本</div></td>
  112. <td><div class="cell" v-if="server.jvm">{{ server.jvm.version }}</div></td>
  113. </tr>
  114. <tr>
  115. <td><div class="cell">启动时间</div></td>
  116. <td><div class="cell" v-if="server.jvm">{{ server.jvm.startTime }}</div></td>
  117. <td><div class="cell">运行时长</div></td>
  118. <td><div class="cell" v-if="server.jvm">{{ server.jvm.runTime }}</div></td>
  119. </tr>
  120. <tr>
  121. <td colspan="1"><div class="cell">安装路径</div></td>
  122. <td colspan="3"><div class="cell" v-if="server.jvm">{{ server.jvm.home }}</div></td>
  123. </tr>
  124. <tr>
  125. <td colspan="1"><div class="cell">项目路径</div></td>
  126. <td colspan="3"><div class="cell" v-if="server.sys">{{ server.sys.userDir }}</div></td>
  127. </tr>
  128. </tbody>
  129. </table>
  130. </div>
  131. </el-card>
  132. </el-col>
  133. <el-col :span="24" class="card-box">
  134. <el-card>
  135. <div slot="header">
  136. <span>磁盘状态</span>
  137. </div>
  138. <div class="el-table el-table--enable-row-hover el-table--medium">
  139. <table cellspacing="0" style="width: 100%;">
  140. <thead>
  141. <tr>
  142. <th class="is-leaf"><div class="cell">盘符路径</div></th>
  143. <th class="is-leaf"><div class="cell">文件系统</div></th>
  144. <th class="is-leaf"><div class="cell">盘符类型</div></th>
  145. <th class="is-leaf"><div class="cell">总大小</div></th>
  146. <th class="is-leaf"><div class="cell">可用大小</div></th>
  147. <th class="is-leaf"><div class="cell">已用大小</div></th>
  148. <th class="is-leaf"><div class="cell">已用百分比</div></th>
  149. </tr>
  150. </thead>
  151. <tbody v-if="server.sysFiles">
  152. <tr v-for="sysFile in server.sysFiles">
  153. <td><div class="cell">{{ sysFile.dirName }}</div></td>
  154. <td><div class="cell">{{ sysFile.sysTypeName }}</div></td>
  155. <td><div class="cell">{{ sysFile.typeName }}</div></td>
  156. <td><div class="cell">{{ sysFile.total }}</div></td>
  157. <td><div class="cell">{{ sysFile.free }}</div></td>
  158. <td><div class="cell">{{ sysFile.used }}</div></td>
  159. <td><div class="cell" :class="{'text-danger': sysFile.usage > 80}">{{ sysFile.usage }}%</div></td>
  160. </tr>
  161. </tbody>
  162. </table>
  163. </div>
  164. </el-card>
  165. </el-col>
  166. </el-row>
  167. </div>
  168. </template>
  169. <script>
  170. import { getServer } from "@/api/monitor/server";
  171. export default {
  172. name: "Server",
  173. data() {
  174. return {
  175. // 加载层信息
  176. loading: [],
  177. // 服务器信息
  178. server: []
  179. };
  180. },
  181. created() {
  182. this.getList();
  183. this.openLoading();
  184. },
  185. methods: {
  186. /** 查询服务器信息 */
  187. getList() {
  188. getServer().then(response => {
  189. this.server = response.data;
  190. this.loading.close();
  191. });
  192. },
  193. // 打开加载层
  194. openLoading() {
  195. this.loading = this.$loading({
  196. lock: true,
  197. text: "拼命读取中",
  198. spinner: "el-icon-loading",
  199. background: "rgba(0, 0, 0, 0.7)"
  200. });
  201. }
  202. }
  203. };
  204. </script>