From 20d7c90515d03979fd4e921c64d76651c696829c Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期二, 24 十一月 2020 10:03:59 +0800 Subject: [PATCH] Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue --- ruoyi-ui/src/views/monitor/cache/index.vue | 151 ++++++++++++++++++++++++++++++ ruoyi-ui/src/api/monitor/cache.js | 9 + ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java | 53 ++++++++++ ruoyi-ui/src/assets/icons/svg/redis.svg | 1 sql/ry_20201123.sql | 20 ++- ruoyi-ui/src/views/system/user/profile/userAvatar.vue | 28 +++++ ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/ServerController.java | 3 7 files changed, 252 insertions(+), 13 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java new file mode 100644 index 0000000..fa9c623 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java @@ -0,0 +1,53 @@ +package com.ruoyi.web.controller.monitor; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisCallback; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.StringUtils; + +/** + * 缂撳瓨鐩戞帶 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/monitor/cache") +public class CacheController +{ + @Autowired + private RedisTemplate<String, String> redisTemplate; + + @PreAuthorize("@ss.hasPermi('monitor:cache:list')") + @GetMapping() + public AjaxResult getInfo() throws Exception + { + Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info()); + Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats")); + Object dbSize = redisTemplate.execute((RedisCallback<Object>) connection -> connection.dbSize()); + + Map<String, Object> result = new HashMap<>(3); + result.put("info", info); + result.put("dbSize", dbSize); + + List<Map<String, String>> pieList = new ArrayList<>(); + commandStats.stringPropertyNames().forEach(key -> { + Map<String, String> data = new HashMap<>(2); + String property = commandStats.getProperty(key); + data.put("name", StringUtils.removeStart(key, "cmdstat_")); + data.put("value", StringUtils.substringBetween(property, "calls=", ",usec")); + pieList.add(data); + }); + result.put("commandStats", pieList); + return AjaxResult.success(result); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/ServerController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/ServerController.java index e784e19..cc805ad 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/ServerController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/ServerController.java @@ -4,7 +4,6 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.framework.web.domain.Server; @@ -15,7 +14,7 @@ */ @RestController @RequestMapping("/monitor/server") -public class ServerController extends BaseController +public class ServerController { @PreAuthorize("@ss.hasPermi('monitor:server:list')") @GetMapping() diff --git a/ruoyi-ui/src/api/monitor/cache.js b/ruoyi-ui/src/api/monitor/cache.js new file mode 100644 index 0000000..2ffaf7a --- /dev/null +++ b/ruoyi-ui/src/api/monitor/cache.js @@ -0,0 +1,9 @@ +import request from '@/utils/request' + +// 鏌ヨ缂撳瓨璇︾粏 +export function getCache() { + return request({ + url: '/monitor/cache', + method: 'get' + }) +} diff --git a/ruoyi-ui/src/assets/icons/svg/redis.svg b/ruoyi-ui/src/assets/icons/svg/redis.svg new file mode 100644 index 0000000..2f1d62d --- /dev/null +++ b/ruoyi-ui/src/assets/icons/svg/redis.svg @@ -0,0 +1 @@ +<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1605865043777" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="856" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M1023.786667 611.84c-0.426667 9.770667-13.354667 20.693333-39.893334 34.56-54.613333 28.458667-337.749333 144.896-397.994666 176.298667-60.288 31.402667-93.738667 31.104-141.354667 8.32-47.616-22.741333-348.842667-144.469333-403.114667-170.368-27.093333-12.970667-40.917333-23.893333-41.386666-34.218667v103.509333c0 10.325333 14.250667 21.290667 41.386666 34.261334 54.272 25.941333 355.541333 147.626667 403.114667 170.368 47.616 22.784 81.066667 23.082667 141.354667-8.362667 60.245333-31.402667 343.338667-147.797333 397.994666-176.298667 27.776-14.464 40.106667-25.728 40.106667-35.925333v-102.058667l-0.213333-0.085333z m0-168.746667c-0.512 9.770667-13.397333 20.650667-39.893334 34.517334-54.613333 28.458667-337.749333 144.896-397.994666 176.298666-60.288 31.402667-93.738667 31.104-141.354667 8.362667-47.616-22.741333-348.842667-144.469333-403.114667-170.410667-27.093333-12.928-40.917333-23.893333-41.386666-34.176v103.509334c0 10.325333 14.250667 21.248 41.386666 34.218666 54.272 25.941333 355.498667 147.626667 403.114667 170.368 47.616 22.784 81.066667 23.082667 141.354667-8.32 60.245333-31.402667 343.338667-147.84 397.994666-176.298666 27.776-14.506667 40.106667-25.770667 40.106667-35.968v-102.058667l-0.256-0.042667z m0-175.018666c0.469333-10.410667-13.141333-19.541333-40.533334-29.610667-53.248-19.498667-334.634667-131.498667-388.522666-151.253333-53.888-19.712-75.818667-18.901333-139.093334 3.84C392.234667 113.706667 92.629333 231.253333 39.338667 252.074667c-26.666667 10.496-39.68 20.181333-39.253334 30.506666V386.133333c0 10.325333 14.250667 21.248 41.386667 34.218667 54.272 25.941333 355.498667 147.669333 403.114667 170.410667 47.616 22.741333 81.066667 23.04 141.354666-8.362667 60.245333-31.402667 343.338667-147.84 397.994667-176.298667 27.776-14.506667 40.106667-25.770667 40.106667-35.968V268.074667h-0.341334zM366.677333 366.08l237.269334-36.437333-71.68 105.088-165.546667-68.650667z m524.8-94.634667l-140.330666 55.466667-15.232 5.973333-140.245334-55.466666 155.392-61.44 140.373334 55.466666z m-411.989333-101.674666l-22.954667-42.325334 71.594667 27.989334 67.498667-22.101334-18.261334 43.733334 68.778667 25.770666-88.704 9.216-19.882667 47.786667-32.085333-53.290667-102.4-9.216 76.416-27.562666z m-176.768 59.733333c70.058667 0 126.805333 21.973333 126.805333 49.109333s-56.746667 49.152-126.805333 49.152-126.848-22.058667-126.848-49.152c0-27.136 56.789333-49.152 126.848-49.152z" p-id="857"></path></svg> \ No newline at end of file diff --git a/ruoyi-ui/src/views/monitor/cache/index.vue b/ruoyi-ui/src/views/monitor/cache/index.vue new file mode 100644 index 0000000..c78a220 --- /dev/null +++ b/ruoyi-ui/src/views/monitor/cache/index.vue @@ -0,0 +1,151 @@ +<template> + <div class="app-container"> + <el-row> + <el-col :span="24" class="card-box"> + <el-card> + <div slot="header"><span>鍩烘湰淇℃伅</span></div> + <div class="el-table el-table--enable-row-hover el-table--medium"> + <table cellspacing="0" style="width: 100%"> + <tbody> + <tr> + <td><div class="cell">Redis鐗堟湰</div></td> + <td><div class="cell" v-if="cache.info">{{ cache.info.redis_version }}</div></td> + <td><div class="cell">杩愯妯″紡</div></td> + <td><div class="cell" v-if="cache.info">{{ cache.info.redis_mode == "standalone" ? "鍗曟満" : "闆嗙兢" }}</div></td> + <td><div class="cell">绔彛</div></td> + <td><div class="cell" v-if="cache.info">{{ cache.info.tcp_port }}</div></td> + <td><div class="cell">瀹㈡埛绔暟</div></td> + <td><div class="cell" v-if="cache.info">{{ cache.info.connected_clients }}</div></td> + </tr> + <tr> + <td><div class="cell">杩愯鏃堕棿(澶�)</div></td> + <td><div class="cell" v-if="cache.info">{{ cache.info.uptime_in_days }}</div></td> + <td><div class="cell">浣跨敤鍐呭瓨</div></td> + <td><div class="cell" v-if="cache.info">{{ cache.info.used_memory_human }}</div></td> + <td><div class="cell">浣跨敤CPU</div></td> + <td><div class="cell" v-if="cache.info">{{ parseFloat(cache.info.used_cpu_user_children).toFixed(2) }}</div></td> + <td><div class="cell">鍐呭瓨閰嶇疆</div></td> + <td><div class="cell" v-if="cache.info">{{ cache.info.maxmemory_human }}</div></td> + </tr> + <tr> + <td><div class="cell">AOF鏄惁寮�鍚�</div></td> + <td><div class="cell" v-if="cache.info">{{ cache.info.aof_enabled == "0" ? "鍚�" : "鏄�" }}</div></td> + <td><div class="cell">RDB鏄惁鎴愬姛</div></td> + <td><div class="cell" v-if="cache.info">{{ cache.info.rdb_last_bgsave_status }}</div></td> + <td><div class="cell">Key鏁伴噺</div></td> + <td><div class="cell" v-if="cache.dbSize">{{ cache.dbSize }} </div></td> + <td><div class="cell">缃戠粶鍏ュ彛/鍑哄彛</div></td> + <td><div class="cell" v-if="cache.info">{{ cache.info.instantaneous_input_kbps }}kps/{{cache.info.instantaneous_output_kbps}}kps</div></td> + </tr> + </tbody> + </table> + </div> + </el-card> + </el-col> + + <el-col :span="12" class="card-box"> + <el-card> + <div slot="header"><span>鍛戒护缁熻</span></div> + <div class="el-table el-table--enable-row-hover el-table--medium"> + <div ref="commandstats" style="height: 420px" /> + </div> + </el-card> + </el-col> + + <el-col :span="12" class="card-box"> + <el-card> + <div slot="header"> + <span>鍐呭瓨淇℃伅</span> + </div> + <div class="el-table el-table--enable-row-hover el-table--medium"> + <div ref="usedmemory" style="height: 420px" /> + </div> + </el-card> + </el-col> + </el-row> + </div> +</template> + +<script> +import { getCache } from "@/api/monitor/cache"; +import echarts from "echarts"; + +export default { + name: "Server", + data() { + return { + // 鍔犺浇灞備俊鎭� + loading: [], + // 缁熻鍛戒护淇℃伅 + commandstats: null, + // 浣跨敤鍐呭瓨 + usedmemory: null, + // cache淇℃伅 + cache: [], + }; + }, + created() { + this.getList(); + this.openLoading(); + }, + methods: { + /** 鏌ョ紦瀛樿淇℃伅 */ + getList() { + getCache().then((response) => { + this.cache = response.data; + this.loading.close(); + + this.commandstats = echarts.init(this.$refs.commandstats, "macarons"); + this.commandstats.setOption({ + tooltip: { + trigger: "item", + formatter: "{a} <br/>{b} : {c} ({d}%)", + }, + series: [ + { + name: "鍛戒护", + type: "pie", + roseType: "radius", + radius: [15, 95], + center: ["50%", "38%"], + data: response.data.commandStats, + animationEasing: "cubicInOut", + animationDuration: 1000, + }, + ], + }); + this.usedmemory = echarts.init(this.$refs.usedmemory, "macarons"); + this.usedmemory.setOption({ + tooltip: { + formatter: "{b} <br/>{a} : {c}M", + }, + series: [ + { + name: "宄板��", + type: "gauge", + detail: { + formatter: "{value}M", + }, + data: [ + { + value: parseFloat(this.cache.info.used_memory_human), + name: "鍐呭瓨娑堣��", + }, + ], + }, + ], + }); + }); + }, + // 鎵撳紑鍔犺浇灞� + openLoading() { + this.loading = this.$loading({ + lock: true, + text: "鎷煎懡璇诲彇涓�", + spinner: "el-icon-loading", + background: "rgba(0, 0, 0, 0.7)", + }); + }, + }, +}; +</script> diff --git a/ruoyi-ui/src/views/system/user/profile/userAvatar.vue b/ruoyi-ui/src/views/system/user/profile/userAvatar.vue index 37ae1dd..deeabe7 100644 --- a/ruoyi-ui/src/views/system/user/profile/userAvatar.vue +++ b/ruoyi-ui/src/views/system/user/profile/userAvatar.vue @@ -1,6 +1,6 @@ <template> <div> - <img v-bind:src="options.img" @click="editCropper()" title="鐐瑰嚮涓婁紶澶村儚" class="img-circle img-lg" /> + <div class="user-info-head" @click="editCropper()"><img v-bind:src="options.img" title="鐐瑰嚮涓婁紶澶村儚" class="img-circle img-lg" /></div> <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body @opened="modalOpened"> <el-row> <el-col :xs="24" :md="12" :style="{height: '350px'}"> @@ -139,4 +139,28 @@ } } }; -</script> \ No newline at end of file +</script> +<style scoped lang="scss"> +.user-info-head { + position: relative; + display: inline-block; +} + +.user-info-head:hover:after { + content: '+'; + position: absolute; + left: 0; + right: 0; + top: 0; + bottom: 0; + color: #eee; + background: rgba(0, 0, 0, 0.5); + font-size: 24px; + font-style: normal; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + cursor: pointer; + line-height: 110px; + border-radius: 50%; +} +</style> \ No newline at end of file diff --git a/sql/ry_20201021.sql b/sql/ry_20201123.sql similarity index 98% rename from sql/ry_20201021.sql rename to sql/ry_20201123.sql index b8f0991..92a5927 100644 --- a/sql/ry_20201021.sql +++ b/sql/ry_20201123.sql @@ -174,9 +174,10 @@ insert into sys_menu values('110', '瀹氭椂浠诲姟', '2', '2', 'job', 'monitor/job/index', 1, 0, 'C', '0', '0', 'monitor:job:list', 'job', 'admin', sysdate(), '', null, '瀹氭椂浠诲姟鑿滃崟'); insert into sys_menu values('111', '鏁版嵁鐩戞帶', '2', '3', 'druid', 'monitor/druid/index', 1, 0, 'C', '0', '0', 'monitor:druid:list', 'druid', 'admin', sysdate(), '', null, '鏁版嵁鐩戞帶鑿滃崟'); insert into sys_menu values('112', '鏈嶅姟鐩戞帶', '2', '4', 'server', 'monitor/server/index', 1, 0, 'C', '0', '0', 'monitor:server:list', 'server', 'admin', sysdate(), '', null, '鏈嶅姟鐩戞帶鑿滃崟'); -insert into sys_menu values('113', '琛ㄥ崟鏋勫缓', '3', '1', 'build', 'tool/build/index', 1, 0, 'C', '0', '0', 'tool:build:list', 'build', 'admin', sysdate(), '', null, '琛ㄥ崟鏋勫缓鑿滃崟'); -insert into sys_menu values('114', '浠g爜鐢熸垚', '3', '2', 'gen', 'tool/gen/index', 1, 0, 'C', '0', '0', 'tool:gen:list', 'code', 'admin', sysdate(), '', null, '浠g爜鐢熸垚鑿滃崟'); -insert into sys_menu values('115', '绯荤粺鎺ュ彛', '3', '3', 'swagger', 'tool/swagger/index', 1, 0, 'C', '0', '0', 'tool:swagger:list', 'swagger', 'admin', sysdate(), '', null, '绯荤粺鎺ュ彛鑿滃崟'); +insert into sys_menu values('113', '缂撳瓨鐩戞帶', '2', '5', 'cache', 'monitor/cache/index', 1, 0, 'C', '0', '0', 'monitor:cache:list', 'redis', 'admin', sysdate(), '', null, '缂撳瓨鐩戞帶鑿滃崟'); +insert into sys_menu values('114', '琛ㄥ崟鏋勫缓', '3', '1', 'build', 'tool/build/index', 1, 0, 'C', '0', '0', 'tool:build:list', 'build', 'admin', sysdate(), '', null, '琛ㄥ崟鏋勫缓鑿滃崟'); +insert into sys_menu values('115', '浠g爜鐢熸垚', '3', '2', 'gen', 'tool/gen/index', 1, 0, 'C', '0', '0', 'tool:gen:list', 'code', 'admin', sysdate(), '', null, '浠g爜鐢熸垚鑿滃崟'); +insert into sys_menu values('116', '绯荤粺鎺ュ彛', '3', '3', 'swagger', 'tool/swagger/index', 1, 0, 'C', '0', '0', 'tool:swagger:list', 'swagger', 'admin', sysdate(), '', null, '绯荤粺鎺ュ彛鑿滃崟'); -- 涓夌骇鑿滃崟 insert into sys_menu values('500', '鎿嶄綔鏃ュ織', '108', '1', 'operlog', 'monitor/operlog/index', 1, 0, 'C', '0', '0', 'monitor:operlog:list', 'form', 'admin', sysdate(), '', null, '鎿嶄綔鏃ュ織鑿滃崟'); insert into sys_menu values('501', '鐧诲綍鏃ュ織', '108', '2', 'logininfor', 'monitor/logininfor/index', 1, 0, 'C', '0', '0', 'monitor:logininfor:list', 'logininfor', 'admin', sysdate(), '', null, '鐧诲綍鏃ュ織鑿滃崟'); @@ -247,12 +248,12 @@ insert into sys_menu values('1053', '鐘舵�佷慨鏀�', '110', '5', '#', '', 1, 0, 'F', '0', '0', 'monitor:job:changeStatus', '#', 'admin', sysdate(), '', null, ''); insert into sys_menu values('1054', '浠诲姟瀵煎嚭', '110', '7', '#', '', 1, 0, 'F', '0', '0', 'monitor:job:export', '#', 'admin', sysdate(), '', null, ''); -- 浠g爜鐢熸垚鎸夐挳 -insert into sys_menu values('1055', '鐢熸垚鏌ヨ', '114', '1', '#', '', 1, 0, 'F', '0', '0', 'tool:gen:query', '#', 'admin', sysdate(), '', null, ''); -insert into sys_menu values('1056', '鐢熸垚淇敼', '114', '2', '#', '', 1, 0, 'F', '0', '0', 'tool:gen:edit', '#', 'admin', sysdate(), '', null, ''); -insert into sys_menu values('1057', '鐢熸垚鍒犻櫎', '114', '3', '#', '', 1, 0, 'F', '0', '0', 'tool:gen:remove', '#', 'admin', sysdate(), '', null, ''); -insert into sys_menu values('1058', '瀵煎叆浠g爜', '114', '2', '#', '', 1, 0, 'F', '0', '0', 'tool:gen:import', '#', 'admin', sysdate(), '', null, ''); -insert into sys_menu values('1059', '棰勮浠g爜', '114', '4', '#', '', 1, 0, 'F', '0', '0', 'tool:gen:preview', '#', 'admin', sysdate(), '', null, ''); -insert into sys_menu values('1060', '鐢熸垚浠g爜', '114', '5', '#', '', 1, 0, 'F', '0', '0', 'tool:gen:code', '#', 'admin', sysdate(), '', null, ''); +insert into sys_menu values('1055', '鐢熸垚鏌ヨ', '115', '1', '#', '', 1, 0, 'F', '0', '0', 'tool:gen:query', '#', 'admin', sysdate(), '', null, ''); +insert into sys_menu values('1056', '鐢熸垚淇敼', '115', '2', '#', '', 1, 0, 'F', '0', '0', 'tool:gen:edit', '#', 'admin', sysdate(), '', null, ''); +insert into sys_menu values('1057', '鐢熸垚鍒犻櫎', '115', '3', '#', '', 1, 0, 'F', '0', '0', 'tool:gen:remove', '#', 'admin', sysdate(), '', null, ''); +insert into sys_menu values('1058', '瀵煎叆浠g爜', '115', '2', '#', '', 1, 0, 'F', '0', '0', 'tool:gen:import', '#', 'admin', sysdate(), '', null, ''); +insert into sys_menu values('1059', '棰勮浠g爜', '115', '4', '#', '', 1, 0, 'F', '0', '0', 'tool:gen:preview', '#', 'admin', sysdate(), '', null, ''); +insert into sys_menu values('1060', '鐢熸垚浠g爜', '115', '5', '#', '', 1, 0, 'F', '0', '0', 'tool:gen:code', '#', 'admin', sysdate(), '', null, ''); -- ---------------------------- @@ -305,6 +306,7 @@ insert into sys_role_menu values ('2', '113'); insert into sys_role_menu values ('2', '114'); insert into sys_role_menu values ('2', '115'); +insert into sys_role_menu values ('2', '116'); insert into sys_role_menu values ('2', '500'); insert into sys_role_menu values ('2', '501'); insert into sys_role_menu values ('2', '1000'); -- Gitblit v1.9.3