Authored by wangning

Merge branch 'wn1020'

... ... @@ -11,6 +11,8 @@ import org.apache.commons.lang.StringUtils;
import org.influxdb.dto.QueryResult;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.*;
... ... @@ -25,6 +27,8 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc
private static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
Logger log = LoggerFactory.getLogger(ServiceAccessMapperImpl.class);
//根据context获取总响应次数和平均耗时
@Override
public Map<String,NewJavaApiInfoRep> getBaseDataByContext(NewJavaApiInfoReq req) {
... ... @@ -406,6 +410,7 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc
String sql1 = String.format("select count(cost),mean(cost) from service_access where %s and time > '%s' and time < '%s' group by hostAddress,context;",contextFilter,startDateStr,endDateStr);
String sql2 = String.format("select count(cost) from service_access where %s and time > '%s' and time < '%s' and cost > %d group by hostAddress,context",contextFilter,startDateStr,endDateStr,costThreshold);
String sql = sql1 + sql2;
log.info("getAlarmData sql is " + sql);
List<Map> list = new ArrayList<>();
list.addAll(getAlarmData(InfluxDBContants.AWS,sql));
list.addAll(getAlarmData(InfluxDBContants.Q_CLOUD,sql));
... ...
... ... @@ -271,10 +271,10 @@ public class ServiceServerExceptionMapperImpl extends InfluxDBQuery implements S
String sql = "";
if(req.getServiceType() == -1){
sql = String.format("select stack from service_server_exception where %s and hostAddress = '%s' and time > '%s' and time < '%s'",contextFilter,req.getIp(),req.getStartTime(),req.getEndTime());
sql = String.format("select stack from service_server_exception where %s and hostAddress = '%s' and time > '%s' and time < '%s' order by time desc limit 50",contextFilter,req.getIp(),req.getStartTime(),req.getEndTime());
}else{
sql = String.format("select stack from service_server_exception where context='%s' and hostAddress = '%s' and time > '%s' and time < '%s'",req.getServiceName(),req.getIp(),req.getStartTime(),req.getEndTime());
sql = String.format("select stack from service_server_exception where context='%s' and hostAddress = '%s' and time > '%s' and time < '%s' order by time desc limit 50",req.getServiceName(),req.getIp(),req.getStartTime(),req.getEndTime());
}
String source = "";
... ... @@ -298,9 +298,9 @@ public class ServiceServerExceptionMapperImpl extends InfluxDBQuery implements S
}
if(StringUtils.isNotBlank(req.getIp())){
sql = String.format("select stack from service_server_exception where context='%s' and time > '%s' and time < '%s' and hostAddress = '%s' and event = '%s'",req.getServiceName(),req.getStartTime(),req.getEndTime(),req.getIp(),req.getApiName());
sql = String.format("select stack from service_server_exception where context='%s' and time > '%s' and time < '%s' and hostAddress = '%s' and event = '%s' order by time desc limit 50",req.getServiceName(),req.getStartTime(),req.getEndTime(),req.getIp(),req.getApiName());
}else{
sql = String.format("select stack from service_server_exception where context='%s' and time > '%s' and time < '%s' and event = '%s'",req.getServiceName(),req.getStartTime(),req.getEndTime(),req.getApiName());
sql = String.format("select stack from service_server_exception where context='%s' and time > '%s' and time < '%s' and event = '%s' order by time desc limit 50",req.getServiceName(),req.getStartTime(),req.getEndTime(),req.getApiName());
}
return queryErrorInfoList(source,sql);
... ...
... ... @@ -379,6 +379,7 @@ public class NewJavaApiInfoServiceImpl implements NewJavaApiInfoService {
costThreshold = 150;
}
String nowString = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
log.info("sendAlarmMsg nowString is :" + nowString + ",costThreshold is " + costThreshold);
List<Map> list = serviceAccessMapper.getAlarmData(costThreshold);
//获取cpu、内存、带宽使用情况
Map vmInfoMap = vmInfoMapper.getVMInfo();
... ...