|
@@ -96,19 +96,17 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
|
@@ -96,19 +96,17 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
96
|
List<String> ipList=null;
|
96
|
List<String> ipList=null;
|
97
|
for(MObjectInfo obj:redisProxymList){
|
97
|
for(MObjectInfo obj:redisProxymList){
|
98
|
paramMonitor=new StringBuffer();
|
98
|
paramMonitor=new StringBuffer();
|
99
|
- String[] ports=null;
|
|
|
100
|
- if(StringUtils.isBlank(obj.getMoTags())){
|
|
|
101
|
- ports=obj.getMoTags().split(",");
|
|
|
102
|
- }
|
99
|
+ String[] ports=obj.getMoTags().split(",");;
|
|
|
100
|
+ log.info("two port is {}",obj.getMoTags());
|
103
|
String result= TelnetUtils.getResult(obj.getMoHostIp(),Integer.valueOf(ports[0]));
|
101
|
String result= TelnetUtils.getResult(obj.getMoHostIp(),Integer.valueOf(ports[0]));
|
104
|
redisMonitor = new RedisMonitor();
|
102
|
redisMonitor = new RedisMonitor();
|
105
|
if(StringUtils.isNotBlank(result)){
|
103
|
if(StringUtils.isNotBlank(result)){
|
106
|
paramMonitor.append("1,");
|
104
|
paramMonitor.append("1,");
|
107
|
boolean proxyFlag=RedisCommonUtil.getRedisIsSlave(obj.getMoHostIp(),Integer.valueOf(ports[1]));
|
105
|
boolean proxyFlag=RedisCommonUtil.getRedisIsSlave(obj.getMoHostIp(),Integer.valueOf(ports[1]));
|
108
|
if(proxyFlag){
|
106
|
if(proxyFlag){
|
109
|
- paramMonitor.append("OK,");
|
107
|
+ paramMonitor.append("探测成功;");
|
110
|
}else{
|
108
|
}else{
|
111
|
- paramMonitor.append("ERROR,");
|
109
|
+ paramMonitor.append("探测失败;");
|
112
|
}
|
110
|
}
|
113
|
//取舍成功重新设为1
|
111
|
//取舍成功重新设为1
|
114
|
JSONObject response=JSONObject.parseObject(result);
|
112
|
JSONObject response=JSONObject.parseObject(result);
|
|
@@ -117,10 +115,10 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
|
@@ -117,10 +115,10 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
117
|
int curr_connections=(Integer)response.get("curr_connections");
|
115
|
int curr_connections=(Integer)response.get("curr_connections");
|
118
|
if(total_connections>0){
|
116
|
if(total_connections>0){
|
119
|
//总连接数
|
117
|
//总连接数
|
120
|
- paramMonitor.append(total_connections+",");
|
118
|
+ paramMonitor.append("总连接数:"+total_connections+";");
|
121
|
}
|
119
|
}
|
122
|
if (total_connections > 0) {
|
120
|
if (total_connections > 0) {
|
123
|
- paramMonitor.append(curr_connections+",");
|
121
|
+ paramMonitor.append("当前连接数:"+curr_connections+";");
|
124
|
}
|
122
|
}
|
125
|
//查看代理下的redis
|
123
|
//查看代理下的redis
|
126
|
JSONObject alpha=response.getJSONObject("alpha");
|
124
|
JSONObject alpha=response.getJSONObject("alpha");
|
|
@@ -131,7 +129,7 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
|
@@ -131,7 +129,7 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
131
|
ipList.add(key+":"+obj.getMoTypeId());
|
129
|
ipList.add(key+":"+obj.getMoTypeId());
|
132
|
}
|
130
|
}
|
133
|
}
|
131
|
}
|
134
|
- tMap.put(obj.getMoHostIp()+":"+obj.getMoTags(),ipList);
|
132
|
+ tMap.put(obj.getMoHostIp()+":"+ports[1],ipList);
|
135
|
redisMonitor.setIsFailed(1);
|
133
|
redisMonitor.setIsFailed(1);
|
136
|
redisMonitor.setParamMonitor(paramMonitor.toString());
|
134
|
redisMonitor.setParamMonitor(paramMonitor.toString());
|
137
|
}
|
135
|
}
|
|
@@ -141,7 +139,7 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
|
@@ -141,7 +139,7 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
141
|
redisMonitor.setParamMonitor("0,");
|
139
|
redisMonitor.setParamMonitor("0,");
|
142
|
}
|
140
|
}
|
143
|
redisMonitor.setNodeFrom(redisTweproxyMap.get(obj.getMoTypeId()));
|
141
|
redisMonitor.setNodeFrom(redisTweproxyMap.get(obj.getMoTypeId()));
|
144
|
- redisMonitor.setNodeTo(obj.getMoHostIp()+":"+obj.getMoTags());
|
142
|
+ redisMonitor.setNodeTo(obj.getMoHostIp()+":"+ports[1]);
|
145
|
redisMonitor.setLevel(1);
|
143
|
redisMonitor.setLevel(1);
|
146
|
redisMonitor.setRedisType(obj.getMoTypeId());
|
144
|
redisMonitor.setRedisType(obj.getMoTypeId());
|
147
|
redisInfoList.add(redisMonitor);
|
145
|
redisInfoList.add(redisMonitor);
|
|
@@ -175,13 +173,18 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
|
@@ -175,13 +173,18 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
175
|
String role=(String)result.get("role");
|
173
|
String role=(String)result.get("role");
|
176
|
paramMonitor.append(role+",");
|
174
|
paramMonitor.append(role+",");
|
177
|
try {
|
175
|
try {
|
178
|
- BigDecimal maxmemory=BigDecimal.valueOf(Long.valueOf(result.get("maxmemory").toString()));
|
|
|
179
|
- BigDecimal byteDang=BigDecimal.valueOf(Long.valueOf(1024*1024));
|
|
|
180
|
- BigDecimal maxMemoryMb = maxmemory.divide(byteDang,2,4);
|
|
|
181
|
- paramMonitor.append(maxMemoryMb+"M,");
|
|
|
182
|
- BigDecimal used_memory=BigDecimal.valueOf(Long.valueOf(result.get("used_memory").toString()));
|
|
|
183
|
- BigDecimal useProportion = used_memory.divide(maxmemory,2,4);
|
|
|
184
|
- paramMonitor.append(useProportion+"%,");
|
176
|
+ long maxmemory=RedisCommonUtil.getRedisMaxMemory(ipConfig[0], Integer.valueOf(ipConfig[1]));
|
|
|
177
|
+ if(maxmemory==0){
|
|
|
178
|
+ paramMonitor.append("最大内存为0");
|
|
|
179
|
+ }else{
|
|
|
180
|
+ BigDecimal byteDang=BigDecimal.valueOf(Long.valueOf(1024*1024));
|
|
|
181
|
+ BigDecimal maxMemoryMb = BigDecimal.valueOf(maxmemory).divide(byteDang,2,4);
|
|
|
182
|
+ paramMonitor.append(maxMemoryMb+"M,");
|
|
|
183
|
+
|
|
|
184
|
+ BigDecimal used_memory=BigDecimal.valueOf(Long.valueOf(result.get("used_memory").toString()));
|
|
|
185
|
+ BigDecimal useProportion = used_memory.divide(BigDecimal.valueOf(maxmemory),2,4);
|
|
|
186
|
+ paramMonitor.append(useProportion+"%,");
|
|
|
187
|
+ }
|
185
|
}catch (Exception e){
|
188
|
}catch (Exception e){
|
186
|
log.error("计算Redis使用率错误",e);
|
189
|
log.error("计算Redis使用率错误",e);
|
187
|
paramMonitor.append("0.00%,");
|
190
|
paramMonitor.append("0.00%,");
|