Rap 原分销系统代码Web
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3f6dd1cab78b95df940d43d00075c70d393d361a.svn-base 8.6KB

5 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <div v-loading="!show" element-loading-text="数据加载中..." :style="!show ? 'height: 500px' : 'height: 100%'" class="app-container">
  3. <div v-if="show">
  4. <el-card class="box-card">
  5. <div style="color: #666;font-size: 13px;">
  6. <svg-icon icon-class="system" style="margin-right: 5px" />
  7. <span>
  8. 系统:{{ data.sys.os }}
  9. </span>
  10. <span>
  11. IP:{{ data.sys.ip }}
  12. </span>
  13. <span>
  14. 项目已不间断运行:{{ data.sys.day }}
  15. </span>
  16. <i class="el-icon-refresh" style="margin-left: 40px" @click="init" />
  17. </div>
  18. </el-card>
  19. <el-card class="box-card">
  20. <div slot="header" class="clearfix">
  21. <span style="font-weight: bold;color: #666;font-size: 15px">状态</span>
  22. </div>
  23. <div>
  24. <el-col :xs="24" :sm="24" :md="6" :lg="6" :xl="6" style="margin-bottom: 10px">
  25. <div class="title">CPU使用率</div>
  26. <el-tooltip placement="top-end">
  27. <div slot="content" style="font-size: 12px;">
  28. <div style="padding: 3px;">
  29. {{ data.cpu.name }}
  30. </div>
  31. <div style="padding: 3px">
  32. {{ data.cpu.package }}
  33. </div>
  34. <div style="padding: 3px">
  35. {{ data.cpu.core }}
  36. </div>
  37. <div style="padding: 3px">
  38. {{ data.cpu.logic }}
  39. </div>
  40. </div>
  41. <div class="content">
  42. <el-progress type="dashboard" :percentage="parseFloat(data.cpu.used)" />
  43. </div>
  44. </el-tooltip>
  45. <div class="footer">{{ data.cpu.coreNumber }} 核心</div>
  46. </el-col>
  47. <el-col :xs="24" :sm="24" :md="6" :lg="6" :xl="6" style="margin-bottom: 10px">
  48. <div class="title">内存使用率</div>
  49. <el-tooltip placement="top-end">
  50. <div slot="content" style="font-size: 12px;">
  51. <div style="padding: 3px;">
  52. 总量:{{ data.memory.total }}
  53. </div>
  54. <div style="padding: 3px">
  55. 已使用:{{ data.memory.used }}
  56. </div>
  57. <div style="padding: 3px">
  58. 空闲:{{ data.memory.available }}
  59. </div>
  60. </div>
  61. <div class="content">
  62. <el-progress type="dashboard" :percentage="parseFloat(data.memory.usageRate)" />
  63. </div>
  64. </el-tooltip>
  65. <div class="footer">{{ data.memory.used }} / {{ data.memory.total }}</div>
  66. </el-col>
  67. <el-col :xs="24" :sm="24" :md="6" :lg="6" :xl="6" style="margin-bottom: 10px">
  68. <div class="title">交换区使用率</div>
  69. <el-tooltip placement="top-end">
  70. <div slot="content" style="font-size: 12px;">
  71. <div style="padding: 3px;">
  72. 总量:{{ data.swap.total }}
  73. </div>
  74. <div style="padding: 3px">
  75. 已使用:{{ data.swap.used }}
  76. </div>
  77. <div style="padding: 3px">
  78. 空闲:{{ data.swap.available }}
  79. </div>
  80. </div>
  81. <div class="content">
  82. <el-progress type="dashboard" :percentage="parseFloat(data.swap.usageRate)" />
  83. </div>
  84. </el-tooltip>
  85. <div class="footer">{{ data.swap.used }} / {{ data.swap.total }}</div>
  86. </el-col>
  87. <el-col :xs="24" :sm="24" :md="6" :lg="6" :xl="6" style="margin-bottom: 10px">
  88. <div class="title">磁盘使用率</div>
  89. <div class="content">
  90. <el-tooltip placement="top-end">
  91. <div slot="content" style="font-size: 12px;">
  92. <div style="padding: 3px">
  93. 总量:{{ data.disk.total }}
  94. </div>
  95. <div style="padding: 3px">
  96. 空闲:{{ data.disk.available }}
  97. </div>
  98. </div>
  99. <div class="content">
  100. <el-progress type="dashboard" :percentage="parseFloat(data.disk.usageRate)" />
  101. </div>
  102. </el-tooltip>
  103. </div>
  104. <div class="footer">{{ data.disk.used }} / {{ data.disk.total }}</div>
  105. </el-col>
  106. </div>
  107. </el-card>
  108. <div>
  109. <el-row :gutter="6">
  110. <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" style="margin-bottom: 10px">
  111. <el-card class="box-card">
  112. <div slot="header" class="clearfix">
  113. <span style="font-weight: bold;color: #666;font-size: 15px">CPU使用率监控</span>
  114. </div>
  115. <div>
  116. <v-chart :options="cpuInfo" />
  117. </div>
  118. </el-card>
  119. </el-col>
  120. <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" style="margin-bottom: 10px">
  121. <el-card class="box-card">
  122. <div slot="header" class="clearfix">
  123. <span style="font-weight: bold;color: #666;font-size: 15px">内存使用率监控</span>
  124. </div>
  125. <div>
  126. <v-chart :options="memoryInfo" />
  127. </div>
  128. </el-card>
  129. </el-col>
  130. </el-row>
  131. </div>
  132. </div>
  133. </div>
  134. </template>
  135. <script>
  136. import ECharts from 'vue-echarts'
  137. import 'echarts/lib/chart/line'
  138. import 'echarts/lib/component/polar'
  139. import { initData } from '@/api/data'
  140. export default {
  141. name: 'ServerMonitor',
  142. components: {
  143. 'v-chart': ECharts
  144. },
  145. data() {
  146. return {
  147. show: false,
  148. monitor: null,
  149. url: 'api/monitor',
  150. data: {},
  151. cpuInfo: {
  152. tooltip: {
  153. trigger: 'axis'
  154. },
  155. xAxis: {
  156. type: 'category',
  157. boundaryGap: false,
  158. data: []
  159. },
  160. yAxis: {
  161. type: 'value',
  162. min: 0,
  163. max: 100,
  164. interval: 20
  165. },
  166. series: [{
  167. data: [],
  168. type: 'line',
  169. areaStyle: {
  170. normal: {
  171. color: 'rgb(32, 160, 255)' // 改变区域颜色
  172. }
  173. },
  174. itemStyle: {
  175. normal: {
  176. color: '#6fbae1',
  177. lineStyle: {
  178. color: '#6fbae1' // 改变折线颜色
  179. }
  180. }
  181. }
  182. }]
  183. },
  184. memoryInfo: {
  185. tooltip: {
  186. trigger: 'axis'
  187. },
  188. xAxis: {
  189. type: 'category',
  190. boundaryGap: false,
  191. data: []
  192. },
  193. yAxis: {
  194. type: 'value',
  195. min: 0,
  196. max: 100,
  197. interval: 20
  198. },
  199. series: [{
  200. data: [],
  201. type: 'line',
  202. areaStyle: {
  203. normal: {
  204. color: 'rgb(32, 160, 255)' // 改变区域颜色
  205. }
  206. },
  207. itemStyle: {
  208. normal: {
  209. color: '#6fbae1',
  210. lineStyle: {
  211. color: '#6fbae1' // 改变折线颜色
  212. }
  213. }
  214. }
  215. }]
  216. }
  217. }
  218. },
  219. created() {
  220. this.init()
  221. this.monitor = window.setInterval(() => {
  222. setTimeout(() => {
  223. this.init()
  224. }, 2)
  225. }, 3500)
  226. },
  227. destroyed() {
  228. clearInterval(this.monitor)
  229. },
  230. methods: {
  231. init() {
  232. initData(this.url, {}).then(data => {
  233. this.data = data
  234. this.show = true
  235. if (this.cpuInfo.xAxis.data.length >= 8) {
  236. this.cpuInfo.xAxis.data.shift()
  237. this.memoryInfo.xAxis.data.shift()
  238. this.cpuInfo.series[0].data.shift()
  239. this.memoryInfo.series[0].data.shift()
  240. }
  241. this.cpuInfo.xAxis.data.push(data.time)
  242. this.memoryInfo.xAxis.data.push(data.time)
  243. this.cpuInfo.series[0].data.push(parseFloat(data.cpu.used))
  244. this.memoryInfo.series[0].data.push(parseFloat(data.memory.usageRate))
  245. })
  246. }
  247. }
  248. }
  249. </script>
  250. <style rel="stylesheet/scss" lang="scss" scoped>
  251. ::v-deep .box-card {
  252. margin-bottom: 5px;
  253. span {
  254. margin-right: 28px;
  255. }
  256. .el-icon-refresh {
  257. margin-right: 10px;
  258. float: right;
  259. cursor:pointer;
  260. }
  261. }
  262. .cpu, .memory, .swap, .disk {
  263. width: 20%;
  264. float: left;
  265. padding-bottom: 20px;
  266. margin-right: 5%;
  267. }
  268. .title {
  269. text-align: center;
  270. font-size: 15px;
  271. font-weight: 500;
  272. color: #999;
  273. margin-bottom: 16px;
  274. }
  275. .footer {
  276. text-align: center;
  277. font-size: 15px;
  278. font-weight: 500;
  279. color: #999;
  280. margin-top: -5px;
  281. margin-bottom: 10px;
  282. }
  283. .content {
  284. text-align: center;
  285. margin-top: 5px;
  286. margin-bottom: 5px;
  287. }
  288. </style>