Authored by qinchao

修改bug

... ... @@ -3,6 +3,8 @@ package com.monitor.influxdb;
import org.influxdb.InfluxDB;
import org.influxdb.dto.BatchPoints;
import org.influxdb.dto.Point;
import org.influxdb.dto.Query;
import org.influxdb.dto.QueryResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -62,4 +64,17 @@ public class InfluxDataReporter {
log.error("InfluxDataReporter write to influxdb error", e);
}
}
public QueryResult queryResult(String dataSource, String command, String database){
Query query = new Query(command, database);
try {
QueryResult queryResult = inluxDBSingle.getInfluxDBByName(dataSource)
.getInfluxDB().query(query);
return queryResult;
} catch (Exception e) {
log.error("influxdb query failed! influxDBName:{},commond:{},database:{},exception{}",dataSource,command,database,e);
return null;
}
}
}
... ...
... ... @@ -2,6 +2,7 @@ package com.monitor.middleware.nginx.task.job.oneJob;
import com.monitor.common.util.SpringContextUtils;
import com.monitor.influxdb.InfluxDBQuery;
import com.monitor.influxdb.InfluxDataReporter;
import com.monitor.influxdb.contants.InfluxDBContants;
import com.monitor.middleware.nginx.common.ApiMapValueCompare;
import com.monitor.middleware.nginx.constant.InterVar;
... ... @@ -21,7 +22,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* Created by yoho on 2016/6/28.
*/
public class BaseLogJob extends InfluxDBQuery implements Callable {
public class BaseLogJob implements Callable {
public static final Logger DEBUG = LoggerFactory.getLogger(BaseLogJob.class);
private static ConcurrentHashMap<String, Integer> KINDEXMAPS = new ConcurrentHashMap<>();
... ... @@ -32,6 +33,9 @@ public class BaseLogJob extends InfluxDBQuery implements Callable {
protected List<ApiSeriesModel> apiSeriesModelList = new ArrayList<>();
//
public InfluxDataReporter influxDataReporter;
private String type;
DecimalFormat format = new DecimalFormat("0.00");
... ... @@ -40,6 +44,8 @@ public class BaseLogJob extends InfluxDBQuery implements Callable {
public BaseLogJob(String measureName, String type) {
this.influxDataReporter = SpringContextUtils.getBeanByClass(InfluxDataReporter.class);
this.alarmMsgComp = SpringContextUtils.getBeanByClass(AlarmMsgComp.class);
this.measureName = measureName;
... ... @@ -97,7 +103,7 @@ public class BaseLogJob extends InfluxDBQuery implements Callable {
DEBUG.debug("Start to execute query command : {}", sql);
try {
QueryResult result = query(InfluxDBContants.AWS, sql, InterVar.DBNAME);
QueryResult result = influxDataReporter.queryResult(InfluxDBContants.AWS, sql, InterVar.DBNAME);
if (null == result || 0 == result.getResults().size()) {
DEBUG.error("Failed to execute query commnad: {} ", sql);
... ...
package com.monitor.middleware.nginx.task.job.oneJob;
import com.monitor.common.util.SpringContextUtils;
import com.monitor.influxdb.InfluxDBQuery;
import com.monitor.influxdb.InfluxDataReporter;
import com.monitor.influxdb.contants.InfluxDBContants;
import com.monitor.middleware.nginx.common.ErrorMapValueCompare;
import com.monitor.middleware.nginx.constant.InterVar;
... ... @@ -21,13 +21,16 @@ import java.util.concurrent.Callable;
/**
* Created by yoho on 2016/6/29.
*/
public class ErrorLogJob extends InfluxDBQuery implements Callable {
public class ErrorLogJob implements Callable {
public static final Logger DEBUG = LoggerFactory.getLogger(ErrorLogJob.class);
private String type;
private AlarmMsgComp alarmMsgComp;
//
public InfluxDataReporter influxDataReporter;
public static final HashMap<String, Integer> KINDEMAPS = new HashMap<>();
private List<ErrorSeriesModel> errorSeriesModelList = new ArrayList<>();
... ... @@ -36,6 +39,9 @@ public class ErrorLogJob extends InfluxDBQuery implements Callable {
public ErrorLogJob(String type) {
this.influxDataReporter = SpringContextUtils.getBeanByClass(InfluxDataReporter.class);
this.alarmMsgComp = SpringContextUtils.getBeanByClass(AlarmMsgComp.class);
this.type = type;
... ... @@ -55,7 +61,7 @@ public class ErrorLogJob extends InfluxDBQuery implements Callable {
DEBUG.debug("Start to execute query command : {}", sql);
QueryResult result = query(InfluxDBContants.AWS, sql, InterVar.DBNAME);
QueryResult result = influxDataReporter.queryResult(InfluxDBContants.AWS, sql, InterVar.DBNAME);
buildErrorModel(result.getResults().get(0).getSeries());
... ...