Authored by skinny.wu

修改redis caps计算方式

@@ -33,7 +33,6 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService @@ -33,7 +33,6 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService
33 33
34 Logger log = LoggerFactory.getLogger(RedisMonitorHandleServiceImpl.class); 34 Logger log = LoggerFactory.getLogger(RedisMonitorHandleServiceImpl.class);
35 35
36 -  
37 @Autowired 36 @Autowired
38 HttpRestClient httpRestClient; 37 HttpRestClient httpRestClient;
39 38
@@ -52,10 +51,6 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService @@ -52,10 +51,6 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService
52 @Autowired 51 @Autowired
53 private SnsMobileConfig snsMobileConfig; 52 private SnsMobileConfig snsMobileConfig;
54 53
55 - private static Map<String, Long> lastUpTimeMap = new HashMap<>();  
56 -  
57 - private static Map<String, Long> lastRequestCountMap = new HashMap<>();  
58 -  
59 @Override 54 @Override
60 public void redisMonitor() { 55 public void redisMonitor() {
61 List<RedisMonitor> redisInfoList=new ArrayList<RedisMonitor>(); 56 List<RedisMonitor> redisInfoList=new ArrayList<RedisMonitor>();
@@ -176,26 +171,12 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService @@ -176,26 +171,12 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService
176 double caps = -1; 171 double caps = -1;
177 172
178 //如果数据为0,即没有探测出数据,不记录该干扰数据 173 //如果数据为0,即没有探测出数据,不记录该干扰数据
179 - if (0 < requestCount && 0 < upTime) {  
180 -  
181 - //如果map中有该ip的数据,则计算caps值以及记录当前request跟uptime字段值到map中  
182 - if (null != lastRequestCountMap.get(ipString)  
183 - && null != lastUpTimeMap.get(ipString)) {  
184 -  
185 - long lastRequestCount = lastRequestCountMap.get(ipString);  
186 - long lastUpTime = lastUpTimeMap.get(ipString);  
187 - caps = (requestCount - lastRequestCount) * 1.0 / (upTime - lastUpTime) / redisCount;  
188 - }  
189 -  
190 - //将当前的uptime request数据存到map中  
191 - lastRequestCountMap.put(ipString, requestCount);  
192 - lastUpTimeMap.put(ipString, upTime);  
193 -  
194 - log.info("requestCount:" + requestCount + " upTime:" + upTime); 174 + if (0 < requestCount) {
  175 + //twemproxy文档说明 request值为每30秒的汇总数据
  176 + caps = requestCount / 30 / redisCount;
195 } 177 }
196 178
197 paramMonitor.append("caps:" + caps + ";"); 179 paramMonitor.append("caps:" + caps + ";");
198 - paramMonitor.append("uptime:" + upTime + ";");  
199 180
200 tMap.put(obj.getMoHostIp()+":"+ports[1],ipList); 181 tMap.put(obj.getMoHostIp()+":"+ports[1],ipList);
201 redisMonitor.setIsFailed(1); 182 redisMonitor.setIsFailed(1);
@@ -286,9 +267,6 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService @@ -286,9 +267,6 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService
286 ***********************************************************************/ 267 ***********************************************************************/
287 if(!CollectionUtils.isEmpty(redisInfoList)){ 268 if(!CollectionUtils.isEmpty(redisInfoList)){
288 log.info("bachInsertRedisMonitor redis monitor:"+redisInfoList); 269 log.info("bachInsertRedisMonitor redis monitor:"+redisInfoList);
289 - log.info("monitorInsertJSON:"+ JSONArray.toJSONString(redisAlarmList));  
290 - log.info("lastRequestCountMap:" + JSONObject.toJSONString(lastRequestCountMap));  
291 - log.info("lastUpTimeMap:" + JSONObject.toJSONString(lastUpTimeMap));  
292 redisMonitorMapper.deleteAllRedisMonitor(); 270 redisMonitorMapper.deleteAllRedisMonitor();
293 redisMonitorMapper.bachInsertRedisMonitor(redisInfoList); 271 redisMonitorMapper.bachInsertRedisMonitor(redisInfoList);
294 } 272 }