...
|
...
|
@@ -96,19 +96,17 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
|
|
List<String> ipList=null;
|
|
|
for(MObjectInfo obj:redisProxymList){
|
|
|
paramMonitor=new StringBuffer();
|
|
|
String[] ports=null;
|
|
|
if(StringUtils.isBlank(obj.getMoTags())){
|
|
|
ports=obj.getMoTags().split(",");
|
|
|
}
|
|
|
String[] ports=obj.getMoTags().split(",");;
|
|
|
log.info("two port is {}",obj.getMoTags());
|
|
|
String result= TelnetUtils.getResult(obj.getMoHostIp(),Integer.valueOf(ports[0]));
|
|
|
redisMonitor = new RedisMonitor();
|
|
|
if(StringUtils.isNotBlank(result)){
|
|
|
paramMonitor.append("1,");
|
|
|
boolean proxyFlag=RedisCommonUtil.getRedisIsSlave(obj.getMoHostIp(),Integer.valueOf(ports[1]));
|
|
|
if(proxyFlag){
|
|
|
paramMonitor.append("OK,");
|
|
|
paramMonitor.append("探测成功;");
|
|
|
}else{
|
|
|
paramMonitor.append("ERROR,");
|
|
|
paramMonitor.append("探测失败;");
|
|
|
}
|
|
|
//取舍成功重新设为1
|
|
|
JSONObject response=JSONObject.parseObject(result);
|
...
|
...
|
@@ -117,10 +115,10 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
|
|
int curr_connections=(Integer)response.get("curr_connections");
|
|
|
if(total_connections>0){
|
|
|
//总连接数
|
|
|
paramMonitor.append(total_connections+",");
|
|
|
paramMonitor.append("总连接数:"+total_connections+";");
|
|
|
}
|
|
|
if (total_connections > 0) {
|
|
|
paramMonitor.append(curr_connections+",");
|
|
|
paramMonitor.append("当前连接数:"+curr_connections+";");
|
|
|
}
|
|
|
//查看代理下的redis
|
|
|
JSONObject alpha=response.getJSONObject("alpha");
|
...
|
...
|
@@ -131,7 +129,7 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
|
|
ipList.add(key+":"+obj.getMoTypeId());
|
|
|
}
|
|
|
}
|
|
|
tMap.put(obj.getMoHostIp()+":"+obj.getMoTags(),ipList);
|
|
|
tMap.put(obj.getMoHostIp()+":"+ports[1],ipList);
|
|
|
redisMonitor.setIsFailed(1);
|
|
|
redisMonitor.setParamMonitor(paramMonitor.toString());
|
|
|
}
|
...
|
...
|
@@ -141,7 +139,7 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
|
|
redisMonitor.setParamMonitor("0,");
|
|
|
}
|
|
|
redisMonitor.setNodeFrom(redisTweproxyMap.get(obj.getMoTypeId()));
|
|
|
redisMonitor.setNodeTo(obj.getMoHostIp()+":"+obj.getMoTags());
|
|
|
redisMonitor.setNodeTo(obj.getMoHostIp()+":"+ports[1]);
|
|
|
redisMonitor.setLevel(1);
|
|
|
redisMonitor.setRedisType(obj.getMoTypeId());
|
|
|
redisInfoList.add(redisMonitor);
|
...
|
...
|
@@ -175,13 +173,18 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
|
|
String role=(String)result.get("role");
|
|
|
paramMonitor.append(role+",");
|
|
|
try {
|
|
|
BigDecimal maxmemory=BigDecimal.valueOf(Long.valueOf(result.get("maxmemory").toString()));
|
|
|
BigDecimal byteDang=BigDecimal.valueOf(Long.valueOf(1024*1024));
|
|
|
BigDecimal maxMemoryMb = maxmemory.divide(byteDang,2,4);
|
|
|
paramMonitor.append(maxMemoryMb+"M,");
|
|
|
BigDecimal used_memory=BigDecimal.valueOf(Long.valueOf(result.get("used_memory").toString()));
|
|
|
BigDecimal useProportion = used_memory.divide(maxmemory,2,4);
|
|
|
paramMonitor.append(useProportion+"%,");
|
|
|
long maxmemory=RedisCommonUtil.getRedisMaxMemory(ipConfig[0], Integer.valueOf(ipConfig[1]));
|
|
|
if(maxmemory==0){
|
|
|
paramMonitor.append("最大内存为0");
|
|
|
}else{
|
|
|
BigDecimal byteDang=BigDecimal.valueOf(Long.valueOf(1024*1024));
|
|
|
BigDecimal maxMemoryMb = BigDecimal.valueOf(maxmemory).divide(byteDang,2,4);
|
|
|
paramMonitor.append(maxMemoryMb+"M,");
|
|
|
|
|
|
BigDecimal used_memory=BigDecimal.valueOf(Long.valueOf(result.get("used_memory").toString()));
|
|
|
BigDecimal useProportion = used_memory.divide(BigDecimal.valueOf(maxmemory),2,4);
|
|
|
paramMonitor.append(useProportion+"%,");
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
log.error("计算Redis使用率错误",e);
|
|
|
paramMonitor.append("0.00%,");
|
...
|
...
|
|