...
|
...
|
@@ -33,7 +33,6 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
|
|
|
|
|
Logger log = LoggerFactory.getLogger(RedisMonitorHandleServiceImpl.class);
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
HttpRestClient httpRestClient;
|
|
|
|
...
|
...
|
@@ -52,10 +51,6 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
|
|
@Autowired
|
|
|
private SnsMobileConfig snsMobileConfig;
|
|
|
|
|
|
private static Map<String, Long> lastUpTimeMap = new HashMap<>();
|
|
|
|
|
|
private static Map<String, Long> lastRequestCountMap = new HashMap<>();
|
|
|
|
|
|
@Override
|
|
|
public void redisMonitor() {
|
|
|
List<RedisMonitor> redisInfoList=new ArrayList<RedisMonitor>();
|
...
|
...
|
@@ -176,26 +171,12 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
|
|
double caps = -1;
|
|
|
|
|
|
//如果数据为0,即没有探测出数据,不记录该干扰数据
|
|
|
if (0 < requestCount && 0 < upTime) {
|
|
|
|
|
|
//如果map中有该ip的数据,则计算caps值以及记录当前request跟uptime字段值到map中
|
|
|
if (null != lastRequestCountMap.get(ipString)
|
|
|
&& null != lastUpTimeMap.get(ipString)) {
|
|
|
|
|
|
long lastRequestCount = lastRequestCountMap.get(ipString);
|
|
|
long lastUpTime = lastUpTimeMap.get(ipString);
|
|
|
caps = (requestCount - lastRequestCount) * 1.0 / (upTime - lastUpTime) / redisCount;
|
|
|
}
|
|
|
|
|
|
//将当前的uptime request数据存到map中
|
|
|
lastRequestCountMap.put(ipString, requestCount);
|
|
|
lastUpTimeMap.put(ipString, upTime);
|
|
|
|
|
|
log.info("requestCount:" + requestCount + " upTime:" + upTime);
|
|
|
if (0 < requestCount) {
|
|
|
//twemproxy文档说明 request值为每30秒的汇总数据
|
|
|
caps = requestCount / 30 / redisCount;
|
|
|
}
|
|
|
|
|
|
paramMonitor.append("caps:" + caps + ";");
|
|
|
paramMonitor.append("uptime:" + upTime + ";");
|
|
|
|
|
|
tMap.put(obj.getMoHostIp()+":"+ports[1],ipList);
|
|
|
redisMonitor.setIsFailed(1);
|
...
|
...
|
@@ -286,9 +267,6 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService |
|
|
***********************************************************************/
|
|
|
if(!CollectionUtils.isEmpty(redisInfoList)){
|
|
|
log.info("bachInsertRedisMonitor redis monitor:"+redisInfoList);
|
|
|
log.info("monitorInsertJSON:"+ JSONArray.toJSONString(redisAlarmList));
|
|
|
log.info("lastRequestCountMap:" + JSONObject.toJSONString(lastRequestCountMap));
|
|
|
log.info("lastUpTimeMap:" + JSONObject.toJSONString(lastUpTimeMap));
|
|
|
redisMonitorMapper.deleteAllRedisMonitor();
|
|
|
redisMonitorMapper.bachInsertRedisMonitor(redisInfoList);
|
|
|
}
|
...
|
...
|
|