mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 12:18:42 +08:00 
			
		
		
		
	新增缓存监控功能
This commit is contained in:
		@@ -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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -4,7 +4,6 @@ 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.controller.BaseController;
 | 
			
		||||
import com.ruoyi.common.core.domain.AjaxResult;
 | 
			
		||||
import com.ruoyi.framework.web.domain.Server;
 | 
			
		||||
 | 
			
		||||
@@ -15,7 +14,7 @@ import com.ruoyi.framework.web.domain.Server;
 | 
			
		||||
 */
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping("/monitor/server")
 | 
			
		||||
public class ServerController extends BaseController
 | 
			
		||||
public class ServerController
 | 
			
		||||
{
 | 
			
		||||
    @PreAuthorize("@ss.hasPermi('monitor:server:list')")
 | 
			
		||||
    @GetMapping()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user