index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <div class="app-container">
  3. <el-row>
  4. <el-col :span="24" class="card-box">
  5. <el-card>
  6. <div slot="header"><span>基本信息</span></div>
  7. <div class="el-table el-table--enable-row-hover el-table--medium">
  8. <table cellspacing="0" style="width: 100%">
  9. <tbody>
  10. <tr>
  11. <td><div class="cell">Redis版本</div></td>
  12. <td><div class="cell" v-if="cache.info">{{ cache.info.redis_version }}</div></td>
  13. <td><div class="cell">运行模式</div></td>
  14. <td><div class="cell" v-if="cache.info">{{ cache.info.redis_mode == "standalone" ? "单机" : "集群" }}</div></td>
  15. <td><div class="cell">端口</div></td>
  16. <td><div class="cell" v-if="cache.info">{{ cache.info.tcp_port }}</div></td>
  17. <td><div class="cell">客户端数</div></td>
  18. <td><div class="cell" v-if="cache.info">{{ cache.info.connected_clients }}</div></td>
  19. </tr>
  20. <tr>
  21. <td><div class="cell">运行时间(天)</div></td>
  22. <td><div class="cell" v-if="cache.info">{{ cache.info.uptime_in_days }}</div></td>
  23. <td><div class="cell">使用内存</div></td>
  24. <td><div class="cell" v-if="cache.info">{{ cache.info.used_memory_human }}</div></td>
  25. <td><div class="cell">使用CPU</div></td>
  26. <td><div class="cell" v-if="cache.info">{{ parseFloat(cache.info.used_cpu_user_children).toFixed(2) }}</div></td>
  27. <td><div class="cell">内存配置</div></td>
  28. <td><div class="cell" v-if="cache.info">{{ cache.info.maxmemory_human }}</div></td>
  29. </tr>
  30. <tr>
  31. <td><div class="cell">AOF是否开启</div></td>
  32. <td><div class="cell" v-if="cache.info">{{ cache.info.aof_enabled == "0" ? "否" : "是" }}</div></td>
  33. <td><div class="cell">RDB是否成功</div></td>
  34. <td><div class="cell" v-if="cache.info">{{ cache.info.rdb_last_bgsave_status }}</div></td>
  35. <td><div class="cell">Key数量</div></td>
  36. <td><div class="cell" v-if="cache.dbSize">{{ cache.dbSize }} </div></td>
  37. <td><div class="cell">网络入口/出口</div></td>
  38. <td><div class="cell" v-if="cache.info">{{ cache.info.instantaneous_input_kbps }}kps/{{cache.info.instantaneous_output_kbps}}kps</div></td>
  39. </tr>
  40. </tbody>
  41. </table>
  42. </div>
  43. </el-card>
  44. </el-col>
  45. <el-col :span="12" class="card-box">
  46. <el-card>
  47. <div slot="header"><span>命令统计</span></div>
  48. <div class="el-table el-table--enable-row-hover el-table--medium">
  49. <div ref="commandstats" style="height: 420px" />
  50. </div>
  51. </el-card>
  52. </el-col>
  53. <el-col :span="12" class="card-box">
  54. <el-card>
  55. <div slot="header">
  56. <span>内存信息</span>
  57. </div>
  58. <div class="el-table el-table--enable-row-hover el-table--medium">
  59. <div ref="usedmemory" style="height: 420px" />
  60. </div>
  61. </el-card>
  62. </el-col>
  63. </el-row>
  64. </div>
  65. </template>
  66. <script>
  67. import { getCache } from "@/api/monitor/cache";
  68. import echarts from "echarts";
  69. export default {
  70. name: "Server",
  71. data() {
  72. return {
  73. // 加载层信息
  74. loading: [],
  75. // 统计命令信息
  76. commandstats: null,
  77. // 使用内存
  78. usedmemory: null,
  79. // cache信息
  80. cache: [],
  81. };
  82. },
  83. created() {
  84. this.getList();
  85. this.openLoading();
  86. },
  87. methods: {
  88. /** 查缓存询信息 */
  89. getList() {
  90. getCache().then((response) => {
  91. this.cache = response.data;
  92. this.loading.close();
  93. this.commandstats = echarts.init(this.$refs.commandstats, "macarons");
  94. this.commandstats.setOption({
  95. tooltip: {
  96. trigger: "item",
  97. formatter: "{a} <br/>{b} : {c} ({d}%)",
  98. },
  99. series: [
  100. {
  101. name: "命令",
  102. type: "pie",
  103. roseType: "radius",
  104. radius: [15, 95],
  105. center: ["50%", "38%"],
  106. data: response.data.commandStats,
  107. animationEasing: "cubicInOut",
  108. animationDuration: 1000,
  109. },
  110. ],
  111. });
  112. this.usedmemory = echarts.init(this.$refs.usedmemory, "macarons");
  113. this.usedmemory.setOption({
  114. tooltip: {
  115. formatter: "{b} <br/>{a} : {c}M",
  116. },
  117. series: [
  118. {
  119. name: "峰值",
  120. type: "gauge",
  121. detail: {
  122. formatter: "{value}M",
  123. },
  124. data: [
  125. {
  126. value: parseFloat(this.cache.info.used_memory_human),
  127. name: "内存消耗",
  128. },
  129. ],
  130. },
  131. ],
  132. });
  133. });
  134. },
  135. // 打开加载层
  136. openLoading() {
  137. this.loading = this.$loading({
  138. lock: true,
  139. text: "拼命读取中",
  140. spinner: "el-icon-loading",
  141. background: "rgba(0, 0, 0, 0.7)",
  142. });
  143. },
  144. },
  145. };
  146. </script>