diff --git a/skyeye-service/src/main/java/com/skyeye/authority/service/SysRedisMonitorService.java b/skyeye-service/src/main/java/com/skyeye/authority/service/SysRedisMonitorService.java index 2f14439b2d2baec95f5ddbd934d9c654af5527d9..aca03254f1421c35f6a6396f6309cf5f65463043 100644 --- a/skyeye-service/src/main/java/com/skyeye/authority/service/SysRedisMonitorService.java +++ b/skyeye-service/src/main/java/com/skyeye/authority/service/SysRedisMonitorService.java @@ -9,4 +9,6 @@ public interface SysRedisMonitorService { public void queryRedisLogsList(InputObject inputObject, OutputObject outputObject) throws Exception; + public void queryRedisKeysList(InputObject inputObject, OutputObject outputObject) throws Exception; + } diff --git a/skyeye-service/src/main/java/com/skyeye/authority/service/impl/SysRedisMonitorServiceImpl.java b/skyeye-service/src/main/java/com/skyeye/authority/service/impl/SysRedisMonitorServiceImpl.java index 58d8475f040a3b641f3f36008a5d41b25a011f26..b32f576e2cc42f1a650edce8648a4f8a94ee75ff 100644 --- a/skyeye-service/src/main/java/com/skyeye/authority/service/impl/SysRedisMonitorServiceImpl.java +++ b/skyeye-service/src/main/java/com/skyeye/authority/service/impl/SysRedisMonitorServiceImpl.java @@ -64,4 +64,24 @@ public class SysRedisMonitorServiceImpl implements SysRedisMonitorService{ outputObject.settotal(beans.size()); } + /** + * + * @Title: queryRedisKeysList + * @Description: 获取当前数据库中key的数量 + * @param @param inputObject + * @param @param outputObject + * @param @throws Exception 参数 + * @return void 返回类型 + * @throws + */ + @Override + public void queryRedisKeysList(InputObject inputObject, OutputObject outputObject) throws Exception { + List> beans = jedisClientClusterService.getClusterNodes(); + for(Map bean : beans){ + bean.put("keys", jedisClientClusterService.dbSize(bean.get("ip").toString())); + } + outputObject.setBeans(beans); + outputObject.settotal(beans.size()); + } + } diff --git a/skyeye-service/src/main/java/com/skyeye/jedis/JedisClientClusterService.java b/skyeye-service/src/main/java/com/skyeye/jedis/JedisClientClusterService.java index 9bdfa71959342831fbe8cc01d059fb7acbb7e37d..e4b9e5615ec0fc403f233fe910fef9f33c01123e 100644 --- a/skyeye-service/src/main/java/com/skyeye/jedis/JedisClientClusterService.java +++ b/skyeye-service/src/main/java/com/skyeye/jedis/JedisClientClusterService.java @@ -34,11 +34,11 @@ public interface JedisClientClusterService { * * @Title: dbSize * @Description: 获取占用内存大小 - * @param @return - * @param @throws Exception 参数 + * @param @param ip + * @param @return 参数 * @return Long 返回类型 * @throws */ - public Long dbSize(String ip); - + public Map dbSize(String ip); + } diff --git a/skyeye-service/src/main/java/com/skyeye/jedis/impl/JedisClientCluster.java b/skyeye-service/src/main/java/com/skyeye/jedis/impl/JedisClientCluster.java index 6a09b53203356d64b8e0605ff76dfa663bfda756..b2e669ed3d23ffa087a0b13a5cf89594c28a4eeb 100644 --- a/skyeye-service/src/main/java/com/skyeye/jedis/impl/JedisClientCluster.java +++ b/skyeye-service/src/main/java/com/skyeye/jedis/impl/JedisClientCluster.java @@ -7,17 +7,13 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; - import net.sf.json.JSONArray; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; - import com.alibaba.fastjson.JSON; import com.skyeye.common.util.ToolUtil; import com.skyeye.jedis.JedisClient; import com.skyeye.jedis.JedisClientClusterService; - import redis.clients.jedis.Client; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisCluster; @@ -234,7 +230,28 @@ public class JedisClientCluster implements JedisClient, JedisClientClusterServic } @Override - public Long dbSize(String ip) { + public Map dbSize(String ip) { + Jedis jedis = null; + try { + Map jedisPools = jedisCluster.getClusterNodes(); + Iterator> entries = jedisPools.entrySet().iterator(); + while (entries.hasNext()) { + Entry entry = entries.next(); + if(entry.getKey().indexOf(ip) != -1){ + jedis = entry.getValue().getResource(); + //配置redis服务信息 + Client client = jedis.getClient(); + client.dbSize(); + long dbSize = client.getIntegerReply(); + jedis.close(); + Map map = new HashMap(); + map.put("createTime", ToolUtil.getTimeAndToString()); + map.put("dbSize", dbSize); + return map; + } + } + } finally { + } return null; } diff --git a/skyeye-web/src/main/java/com/skyeye/authority/controller/SysRedisMonitorController.java b/skyeye-web/src/main/java/com/skyeye/authority/controller/SysRedisMonitorController.java index 7f7cc320e9219ef45b8a38dce61a0a53ca7df83a..5c9d069962a1436a6c342c0413ff6b3994d54283 100644 --- a/skyeye-web/src/main/java/com/skyeye/authority/controller/SysRedisMonitorController.java +++ b/skyeye-web/src/main/java/com/skyeye/authority/controller/SysRedisMonitorController.java @@ -48,4 +48,20 @@ public class SysRedisMonitorController { sysRedisMonitorService.queryRedisLogsList(inputObject, outputObject); } + /** + * + * @Title: queryRedisKeysList + * @Description: 获取当前数据库中key的数量 + * @param @param inputObject + * @param @param outputObject + * @param @throws Exception 参数 + * @return void 返回类型 + * @throws + */ + @RequestMapping("/post/SysRedisMonitorController/queryRedisKeysList") + @ResponseBody + public void queryRedisKeysList(InputObject inputObject, OutputObject outputObject) throws Exception{ + sysRedisMonitorService.queryRedisKeysList(inputObject, outputObject); + } + } diff --git a/skyeye-web/src/main/resources/mapping/reqmapping.xml b/skyeye-web/src/main/resources/mapping/reqmapping.xml index 7a789c0293acbe780faa1322d1f62e58bb2f8e6b..1aaad6a01ad84a33791d0d8260cdde45f6904c66 100644 --- a/skyeye-web/src/main/resources/mapping/reqmapping.xml +++ b/skyeye-web/src/main/resources/mapping/reqmapping.xml @@ -160,7 +160,9 @@ - + + + diff --git a/skyeye-web/src/main/webapp/tpl/sysredis/redismonitorlist.html b/skyeye-web/src/main/webapp/tpl/sysredis/redismonitorlist.html index 9e0b77eb1caa654a5251f3524e18d4b42a2dbd7d..80f2872d692c8c16d6802279e92eeb207b648d72 100644 --- a/skyeye-web/src/main/webapp/tpl/sysredis/redismonitorlist.html +++ b/skyeye-web/src/main/webapp/tpl/sysredis/redismonitorlist.html @@ -15,7 +15,7 @@
  • redis服务器信息
  • redis日志信息
  • -
  • Area
  • +
  • redis内存数量
  • Pie
@@ -34,7 +34,9 @@
-
3
+
+ +
4