...
|
...
|
@@ -44,8 +44,8 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
|
|
*1、处理twemproxy
|
|
|
***********************************************************************/
|
|
|
List<RedisMonitor> redisInfoList=new ArrayList<RedisMonitor>();
|
|
|
redisInfoList.add(new RedisMonitor("AWS","AWS",0,null));
|
|
|
redisInfoList.add(new RedisMonitor("Qcloud","Qcloud",0,null));
|
|
|
redisInfoList.add(new RedisMonitor("AWS","AWS",0,1,null));
|
|
|
redisInfoList.add(new RedisMonitor("Qcloud","Qcloud",0,1,null));
|
|
|
RedisMonitor redisMonitor=null;
|
|
|
//List<MObjectInfo> mlist= mObjectInfoMapper.getMoInfosByAlias("com_twemproxy");
|
|
|
MObjectInfo a=new MObjectInfo();
|
...
|
...
|
@@ -64,31 +64,36 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
|
|
for(MObjectInfo obj:mlist){
|
|
|
paramMonitor=new StringBuffer();
|
|
|
String result= TelnetUtils.getResult(obj.getMoHostIp(),22222);
|
|
|
if(StringUtils.isBlank(result)){
|
|
|
continue;
|
|
|
}
|
|
|
JSONObject response=JSONObject.parseObject(result);
|
|
|
if(null != response){
|
|
|
int total_connections=(Integer)response.get("total_connections");
|
|
|
int curr_connections=(Integer)response.get("curr_connections");
|
|
|
if(total_connections>0){
|
|
|
paramMonitor.append("总连接数:"+total_connections);
|
|
|
}
|
|
|
if (total_connections > 0) {
|
|
|
paramMonitor.append("当前接数:"+curr_connections);
|
|
|
}
|
|
|
//查看代理下的redis
|
|
|
JSONObject alpha=response.getJSONObject("alpha");
|
|
|
ipList=new ArrayList<String>();
|
|
|
for (Map.Entry<String, Object> entry : alpha.entrySet()) {
|
|
|
String key=entry.getKey();
|
|
|
if(key.indexOf(":")>1){
|
|
|
ipList.add(key);
|
|
|
redisMonitor = new RedisMonitor();
|
|
|
if(StringUtils.isNotBlank(result)){
|
|
|
//取舍成功重新设为1
|
|
|
JSONObject response=JSONObject.parseObject(result);
|
|
|
if(null != response){
|
|
|
int total_connections=(Integer)response.get("total_connections");
|
|
|
int curr_connections=(Integer)response.get("curr_connections");
|
|
|
if(total_connections>0){
|
|
|
paramMonitor.append("总连接数:"+total_connections);
|
|
|
}
|
|
|
if (total_connections > 0) {
|
|
|
paramMonitor.append("当前接数:"+curr_connections);
|
|
|
}
|
|
|
//查看代理下的redis
|
|
|
JSONObject alpha=response.getJSONObject("alpha");
|
|
|
ipList=new ArrayList<String>();
|
|
|
for (Map.Entry<String, Object> entry : alpha.entrySet()) {
|
|
|
String key=entry.getKey();
|
|
|
if(key.indexOf(":")>1){
|
|
|
ipList.add(key);
|
|
|
}
|
|
|
}
|
|
|
tMap.put(obj.getMoHostIp(),ipList);
|
|
|
redisMonitor.setIsFailed(1);
|
|
|
redisMonitor.setParamMonitor(paramMonitor.toString());
|
|
|
}
|
|
|
tMap.put(obj.getMoHostIp(),ipList);
|
|
|
}else{
|
|
|
redisMonitor.setIsFailed(0);
|
|
|
redisMonitor.setParamMonitor("状态:宕机;");
|
|
|
}
|
|
|
redisMonitor = new RedisMonitor();
|
|
|
if(StringUtils.isNotBlank(obj.getMoName()) && obj.getMoName().contains("aws")){
|
|
|
redisMonitor.setNodeFrom("AWS");
|
|
|
}else if(obj.getMoName().contains("qq")){
|
...
|
...
|
@@ -96,10 +101,7 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
|
|
}
|
|
|
redisMonitor.setNodeTo(obj.getMoHostIp());
|
|
|
redisMonitor.setLevel(1);
|
|
|
redisMonitor.setParamMonitor(paramMonitor.toString());
|
|
|
redisInfoList.add(redisMonitor);
|
|
|
//obj.setParamMonitor(paramMonitor.toString());
|
|
|
//redisMonitorMapper.updateByPrimaryKey(obj);
|
|
|
}
|
|
|
|
|
|
/**********************************************************************
|
...
|
...
|
@@ -117,18 +119,20 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
|
|
String[] ipConfig=ipStr.split(":");
|
|
|
Map<String,Object> result=null;
|
|
|
if(ipConfig.length==2){
|
|
|
int isFailed=0;
|
|
|
result= RedisInfoUtil.getRedisInfo(ipConfig[0], Integer.valueOf(ipConfig[1]));
|
|
|
paramMonitor=new StringBuffer();
|
|
|
if(null==result){
|
|
|
paramMonitor.append("状态:宕机;");
|
|
|
}else{
|
|
|
isFailed=1;
|
|
|
String role=(String)result.get("role");
|
|
|
paramMonitor.append("角色:"+role+";");
|
|
|
paramMonitor.append("用量:"+result.get("used_memory_rss")+";");
|
|
|
paramMonitor.append("内存碎片比率:" + result.get("mem_fragmentation_ratio") + ";");
|
|
|
// paramMonitor.append(":"+isSlave+";");
|
|
|
}
|
|
|
redisInfoList.add(new RedisMonitor(key,ipStr,2,paramMonitor.toString()));
|
|
|
redisInfoList.add(new RedisMonitor(key,ipStr,2,isFailed,paramMonitor.toString()));
|
|
|
}
|
|
|
}
|
|
|
}
|
...
|
...
|
|