Authored by jack

Merge branch 'master' of http://git.yoho.cn/ops/monitor-service

Showing 21 changed files with 1187 additions and 45 deletions
... ... @@ -118,6 +118,11 @@
<artifactId>jsch</artifactId>
<version>0.1.53</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.8.1</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
... ...
... ... @@ -20,6 +20,8 @@ public class InfluxDBContants {
public static final String YOHO_ORDER = "yoho_order";
public static final String YOHO_EVENT = "yoho_event";
public static final String APP_ALARM = "app_alarm";
public static final String MIDDLEWARE_ALARM = "middleware_alarm";
... ... @@ -30,6 +32,8 @@ public class InfluxDBContants {
public static final String JAVA_PROJECT="java_project";
public static final String ZABBIX="zabbix";
/**
* influxdb 表
*/
... ... @@ -43,5 +47,11 @@ public class InfluxDBContants {
public static final String JAVA_PROJECT_STATUS="java_project_status";
public static final String SERVICE_ACCESS="service_access";
public static final String SERVICE_SERVER_EXCEPTION= "service_server_exception";
public static final String VM_INFO = "vm_info";
}
\ No newline at end of file
... ...
package com.monitor.influxdb.mapper;
import com.monitor.model.request.NewJavaApiInfoReq;
import com.monitor.model.response.NewJavaApiDetailInfoRep;
import com.monitor.model.response.NewJavaApiInfoRep;
import java.util.List;
import java.util.Map;
/**
* Created by yoho on 2016/10/20.
*/
public interface ServiceAccessMapper {
Map<String,NewJavaApiInfoRep> getBaseDataByContext(String context,String startDateStr,String endDateStr);
Map<String,List<String>> getTimeoutInfo(String context, String startDateStr, String endDateStr);
Map<String,List> getGraphInfo(String context);
List<NewJavaApiDetailInfoRep> getDataByContextAndIP(NewJavaApiInfoReq req);
Map<String,List<String>> getTimeoutInfoByContextAndIp(NewJavaApiInfoReq req);
}
... ...
package com.monitor.influxdb.mapper;
import com.monitor.model.request.NewJavaApiInfoReq;
import java.util.List;
import java.util.Map;
/**
* Created by yoho on 2016/10/20.
*/
public interface ServiceServerExceptionMapper {
Map<String,List<String>> getErrorDataByContext(String context,String startDateStr,String endDateStr);
Map<String,List> getGraphInfo(String context);
Map<String,List<String>> getErrorDataByContextAndIp(NewJavaApiInfoReq req);
}
... ...
package com.monitor.influxdb.mapper;
import java.util.Map;
/**
* Created by yoho on 2016/10/24.
*/
public interface VMInfoMapper {
Map getVMInfo();
}
... ...
package com.monitor.influxdb.mapper.impl;
import com.monitor.influxdb.InfluxDBQuery;
import com.monitor.influxdb.contants.InfluxDBContants;
import com.monitor.influxdb.mapper.ServiceAccessMapper;
import com.monitor.model.request.NewJavaApiInfoReq;
import com.monitor.model.response.NewJavaApiDetailInfoRep;
import com.monitor.model.response.NewJavaApiInfoRep;
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.*;
/**
* Created by yoho on 2016/10/20.
*/
@Component
public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAccessMapper {
Logger log = LoggerFactory.getLogger(ServiceAccessMapperImpl.class);
//根据context获取总响应次数和平均耗时
@Override
public Map<String,NewJavaApiInfoRep> getBaseDataByContext(String context,String startDateStr,String endDateStr) {
Map<String,NewJavaApiInfoRep> map = new HashMap<>();
String sql = String.format("select count(cost),mean(cost) from service_access where context = '%s' and time > '%s' and time < '%s' group by hostAddress",context,startDateStr,endDateStr);
// String sql = "select count(cost),mean(cost) from service_access group by hostAddress";
map.putAll(getDataByContext(InfluxDBContants.AWS,sql));
map.putAll(getDataByContext(InfluxDBContants.Q_CLOUD,sql));
return map;
}
private Map<String,NewJavaApiInfoRep> getDataByContext(String source,String sql) {
Map<String,NewJavaApiInfoRep> map = new HashMap<>();
QueryResult queryResult = query(source, sql, InfluxDBContants.YOHO_EVENT);
QueryResult.Result rel = queryResult.getResults().get(0);
List<QueryResult.Series> listSeries = rel.getSeries();
if(listSeries == null)
return map;
for(QueryResult.Series series : listSeries){
String hostAddress = series.getTags().get("hostAddress");
Double count = (Double)series.getValues().get(0).get(1);
Double mean = (Double)series.getValues().get(0).get(2);
NewJavaApiInfoRep newJavaApiInfoRep = new NewJavaApiInfoRep();
newJavaApiInfoRep.setTotalCount(count.intValue());
newJavaApiInfoRep.setAvgCost(mean.intValue());
map.put(hostAddress,newJavaApiInfoRep);
}
return map;
}
@Override
public Map<String,List<String>> getTimeoutInfo(String context, String startDateStr, String endDateStr) {
Map<String,List<String>> map = new HashMap();
String sql = String.format("select ip,stack from service_access where context='%s' and cost > 200 and time > '%s' and time < '%s'",context,startDateStr,endDateStr);
// String sql = "select ip,stack from service_access where context='gateway' and cost > 200";
map.putAll(getTimeoutInfo(InfluxDBContants.AWS,sql));
map.putAll(getTimeoutInfo(InfluxDBContants.Q_CLOUD,sql));
return map;
}
private Map<String,List<String>> getTimeoutInfo(String source,String sql) {
Map<String,List<String>> map = new HashMap();
QueryResult queryResult = query(source, sql, InfluxDBContants.YOHO_EVENT);
QueryResult.Result rel = queryResult.getResults().get(0);
List<QueryResult.Series> listSeries = rel.getSeries();
if(listSeries == null)
return map;
QueryResult.Series series = listSeries.get(0);
List<List<Object>> values = series.getValues();
for (List<Object> objects : values){
if(objects.get(1) == null || objects.get(2) == null)
continue;
String ip = (String)objects.get(1);
String stack = (String)objects.get(2);
List<String> stackList = map.get(ip);
if(stackList == null){
stackList = new ArrayList<>();
stackList.add(stack);
map.put(ip,stackList);
}else{
stackList.add(stack);
}
}
return map;
}
@Override
public Map<String,List> getGraphInfo(String context){
Map<String,List> map = new HashMap();
String sql = String.format("SELECT mean(cost) FROM service_access WHERE time > now() - 10m and context = '%s' GROUP BY hostAddress,time(1m) fill(null)",context);
// String sql = "select mean(cost) from service_access where time > '2016-10-20 02:25:00' and time < '2016-10-20 02:51:00' and context = 'gateway' GROUP BY hostAddress,time(1m) fill(null)";
map.putAll(getGraphInfo(InfluxDBContants.AWS,sql));
map.putAll(getGraphInfo(InfluxDBContants.Q_CLOUD,sql));
return map;
}
private Map<String,List> getGraphInfo(String source,String sql) {
Map<String,List> resultMap = new HashMap<>();
QueryResult queryResult = query(source, sql, InfluxDBContants.YOHO_EVENT);
QueryResult.Result rel = queryResult.getResults().get(0);
List<QueryResult.Series> listSeries = rel.getSeries();
if(listSeries == null)
return resultMap;
for(QueryResult.Series series : listSeries){
String hostAddress = series.getTags().get("hostAddress");
List valuesList = (List)series.getValues();
List<String> timeList = new ArrayList<>();
List<Integer> meanList = new ArrayList<>();
List list = new ArrayList<>();
for(int i=0;i<valuesList.size();i++){
List avgValueList = (List)valuesList.get(i);
String time = (String)avgValueList.get(0);
DateTime one = DateTime.parse(time);
one = one.withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone("Asia/Shanghai")));
String formatTime = one.toString("HH:mm");
timeList.add(formatTime);
if(avgValueList.get(1) == null){
meanList.add(0);
}else{
meanList.add(((Double)avgValueList.get(1)).intValue());
}
}
list.add(timeList);
list.add(meanList);
resultMap.put(hostAddress,list);
}
return resultMap;
}
@Override
public List<NewJavaApiDetailInfoRep> getDataByContextAndIP(NewJavaApiInfoReq req) {
List<NewJavaApiDetailInfoRep> list = new ArrayList<>();
String source = "";
String sql = "";
if(req.getCloudType()==2){
source = InfluxDBContants.Q_CLOUD;
}else{
source = InfluxDBContants.AWS;
}
if(StringUtils.isNotBlank(req.getIp())){
sql = String.format("select count(cost),mean(cost) from service_access where context = '%s' and hostAddress = '%s' group by event",req.getServiceName(),req.getIp());
}else{
sql = String.format("select count(cost),mean(cost) from service_access where context = '%s' group by event",req.getServiceName());
}
QueryResult queryResult = query(source, sql, InfluxDBContants.YOHO_EVENT);
QueryResult.Result rel = queryResult.getResults().get(0);
List<QueryResult.Series> listSeries = rel.getSeries();
if(listSeries == null)
return list;
for(QueryResult.Series series : listSeries){
NewJavaApiDetailInfoRep rep = new NewJavaApiDetailInfoRep();
String apiName = series.getTags().get("event");
Double count = (Double)series.getValues().get(0).get(1);
Double mean = (Double)series.getValues().get(0).get(2);
rep.setApiName(apiName);
rep.setTotalCount(count.intValue());
rep.setAvgCost(mean.intValue());
list.add(rep);
}
return list;
}
@Override
public Map<String,List<String>> getTimeoutInfoByContextAndIp(NewJavaApiInfoReq req) {
String source = "";
String sql = "";
if(req.getCloudType()==2){
source = InfluxDBContants.Q_CLOUD;
}else{
source = InfluxDBContants.AWS;
}
if(StringUtils.isNotBlank(req.getIp())){
sql = String.format("select event,stack from service_access where context='%s' and cost > 200 and ip = '%s'",req.getServiceName(),req.getIp());
}else{
sql = String.format("select event,stack from service_access where context='%s' and cost > 200 ",req.getServiceName());
}
Map<String,List<String>> map = new HashMap();
QueryResult queryResult = query(source, sql, InfluxDBContants.YOHO_EVENT);
QueryResult.Result rel = queryResult.getResults().get(0);
List<QueryResult.Series> listSeries = rel.getSeries();
if(listSeries == null)
return map;
QueryResult.Series series = listSeries.get(0);
List<List<Object>> values = series.getValues();
for (List<Object> objects : values){
if(objects.get(1) == null || objects.get(2) == null)
continue;
String event = (String)objects.get(1);
String stack = (String)objects.get(2);
List<String> stackList = map.get(event);
if(stackList == null){
stackList = new ArrayList<>();
stackList.add(stack);
map.put(event,stackList);
}else{
stackList.add(stack);
}
}
return map;
}
}
... ...
package com.monitor.influxdb.mapper.impl;
import com.monitor.influxdb.InfluxDBQuery;
import com.monitor.influxdb.contants.InfluxDBContants;
import com.monitor.influxdb.mapper.ServiceServerExceptionMapper;
import com.monitor.model.request.NewJavaApiInfoReq;
import com.monitor.model.response.NewJavaApiInfoRep;
import org.apache.commons.lang.StringUtils;
import org.influxdb.dto.QueryResult;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.springframework.stereotype.Component;
import java.util.*;
/**
* Created by yoho on 2016/10/20.
*/
@Component
public class ServiceServerExceptionMapperImpl extends InfluxDBQuery implements ServiceServerExceptionMapper {
//根据context获取错误信息列表
@Override
public Map<String,List<String>> getErrorDataByContext(String context,String startDateStr,String endDateStr) {
Map<String,List<String>> map = new HashMap();
String sql = String.format("select ip,stack from service_server_exception where context='%s' and time > '%s' and time < '%s'",context,startDateStr,endDateStr);
// String sql = "select ip,stack from service_server_exception";
map.putAll(getDataByContext(InfluxDBContants.AWS,sql));
map.putAll(getDataByContext(InfluxDBContants.Q_CLOUD,sql));
return map;
}
private Map<String,List<String>> getDataByContext(String source,String sql) {
Map<String,List<String>> map = new HashMap();
QueryResult queryResult = query(source, sql, InfluxDBContants.YOMO_MONITOR);
QueryResult.Result rel = queryResult.getResults().get(0);
List<QueryResult.Series> listSeries = rel.getSeries();
if(listSeries == null)
return map;
QueryResult.Series series = listSeries.get(0);
List<List<Object>> values = series.getValues();
for (List<Object> objects : values){
if(objects.get(1) == null || objects.get(2) == null)
continue;
String ip = objects.get(1).toString();
String stack = objects.get(2).toString();
List<String> stackList = map.get(ip);
if(stackList == null){
stackList = new ArrayList<>();
stackList.add(stack);
map.put(ip,stackList);
}else{
stackList.add(stack);
}
}
return map;
}
@Override
public Map<String,List> getGraphInfo(String context){
Map<String,List> map = new HashMap();
String sql = String.format("select count(stack) from service_server_exception where context = '%s' and time > now() - 10m GROUP BY hostAddress,time(1m) fill(null)",context);
// String sql = "select count(stack) from service_server_exception where time > '2016-10-20 12:04:00' and time < '2016-10-20 12:14:00' GROUP BY hostAddress,time(1m) fill(null)";
map.putAll(getGraphInfo(InfluxDBContants.AWS,sql));
map.putAll(getGraphInfo(InfluxDBContants.Q_CLOUD,sql));
return map;
}
private Map<String,List> getGraphInfo(String source,String sql) {
Map<String,List> resultMap = new HashMap<>();
QueryResult queryResult = query(source, sql, InfluxDBContants.YOMO_MONITOR);
QueryResult.Result rel = queryResult.getResults().get(0);
List<QueryResult.Series> listSeries = rel.getSeries();
if(listSeries == null)
return resultMap;
for(QueryResult.Series series : listSeries){
String hostAddress = series.getTags().get("hostAddress");
List valuesList = (List)series.getValues();
List<String> timeList = new ArrayList<>();
List<Integer> countList = new ArrayList<>();
List list = new ArrayList<>();
for(int i=0;i<valuesList.size();i++){
List avgValueList = (List)valuesList.get(i);
String time = (String)avgValueList.get(0);
DateTime one = DateTime.parse(time);
one = one.withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone("Asia/Shanghai")));
String formatTime = one.toString("HH:mm");
timeList.add(formatTime);
if(avgValueList.get(1) == null){
countList.add(0);
}else{
countList.add(((Double)avgValueList.get(1)).intValue());
}
}
list.add(timeList);
list.add(countList);
resultMap.put(hostAddress,list);
}
return resultMap;
}
@Override
public Map<String,List<String>> getErrorDataByContextAndIp(NewJavaApiInfoReq req) {
Map<String,List<String>> map = new HashMap();
String source = "";
String sql = "";
if(req.getCloudType()==2){
source = InfluxDBContants.Q_CLOUD;
}else{
source = InfluxDBContants.AWS;
}
if(StringUtils.isNotBlank(req.getIp())){
sql = String.format("select event,stack from service_server_exception where context='%s' and hostAddress = '%s'",req.getServiceName(),req.getIp());
}else{
sql = String.format("select event,stack from service_server_exception where context='%s'",req.getServiceName());
}
QueryResult queryResult = query(source, sql, InfluxDBContants.YOMO_MONITOR);
QueryResult.Result rel = queryResult.getResults().get(0);
List<QueryResult.Series> listSeries = rel.getSeries();
if(listSeries == null)
return map;
QueryResult.Series series = listSeries.get(0);
List<List<Object>> values = series.getValues();
for (List<Object> objects : values){
if(objects.get(1) == null || objects.get(2) == null)
continue;
String event = objects.get(1).toString();
String stack = objects.get(2).toString();
List<String> stackList = map.get(event);
if(stackList == null){
stackList = new ArrayList<>();
stackList.add(stack);
map.put(event,stackList);
}else{
stackList.add(stack);
}
}
return map;
}
}
... ...
package com.monitor.influxdb.mapper.impl;
import com.monitor.influxdb.InfluxDBQuery;
import com.monitor.influxdb.contants.InfluxDBContants;
import com.monitor.influxdb.mapper.VMInfoMapper;
import com.monitor.model.response.NewJavaApiInfoRep;
import org.influxdb.dto.QueryResult;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by yoho on 2016/10/24.
*/
@Component
public class VMInfoMapperImpl extends InfluxDBQuery implements VMInfoMapper {
@Override
public Map getVMInfo() {
Map map = new HashMap<>();
String sql = "select CPU_UTIL_USER,MEMORY_SIZE_AVAILABLE,MEMORY_SIZE_TOTAL,NET_IF_IN,NET_IF_OUT from vm_info group by ip order by time desc limit 1";
map.putAll(getVMInfo(InfluxDBContants.AWS,sql));
map.putAll(getVMInfo(InfluxDBContants.Q_CLOUD,sql));
return map;
}
private Map getVMInfo(String source,String sql){
Map map = new HashMap<>();
QueryResult queryResult = query(source, sql, InfluxDBContants.ZABBIX);
QueryResult.Result rel = queryResult.getResults().get(0);
List<QueryResult.Series> listSeries = rel.getSeries();
if(listSeries == null)
return map;
for(QueryResult.Series series : listSeries){
String ip = series.getTags().get("ip");
List list = series.getValues().get(0);
map.put(ip,list);
}
return map;
}
}
... ...
package com.monitor.javaserver.ctrl;
import com.monitor.common.util.HttpRestClient;
import com.monitor.influxdb.InluxDBSingle;
import com.monitor.influxdb.contants.InfluxDBContants;
import com.monitor.javaserver.service.NewJavaApiInfoService;
import com.monitor.model.request.NewJavaApiInfoReq;
import com.monitor.model.response.BaseResponse;
import com.monitor.model.response.NewJavaApiDetailInfoRep;
import com.monitor.model.response.NewJavaApiInfoRep;
import org.apache.commons.lang.math.RandomUtils;
import org.influxdb.dto.Point;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.text.DecimalFormat;
import java.util.*;
/**
* Created by wangning on 2016/10/20.
* java服务接口监控
*/
@Controller
@RequestMapping("newJavaApiInfo")
public class NewJavaApiInfoCtrl {
Logger log = LoggerFactory.getLogger(NewJavaApiInfoCtrl.class);
@Autowired
NewJavaApiInfoService newJavaApiInfoService;
@Autowired
private InluxDBSingle inluxDBSingle;
@Autowired
HttpRestClient httpRestClient;
private static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
//根据serviceName和timeInterval查询每台ip的监控信息
@RequestMapping("/queryByServiceType")
@ResponseBody
public BaseResponse getJavaApiStatus(@RequestBody NewJavaApiInfoReq req) {
log.info("queryByServiceType accept pram : {},{},{}",req.getServiceType(),req.getServiceName(),req.getTimeInterval());
//influxdb使用的是utc时间
DateTime endDateTime = DateTime.now(DateTimeZone.UTC);
DateTime startDateTime = endDateTime.minusMinutes(req.getTimeInterval());
String startDateStr = startDateTime.toString(DATE_TIME_FORMAT);
String endDateStr = endDateTime.toString(DATE_TIME_FORMAT);
List<NewJavaApiInfoRep> list = newJavaApiInfoService.getJavaApiStatus(req,startDateStr,endDateStr);
Map returnMap = new HashMap();
returnMap.put("startTime",startDateStr);
returnMap.put("endTime",endDateStr);
returnMap.put("content",list);
BaseResponse rep = new BaseResponse();
rep.setData(returnMap);
return rep;
}
//根据serviceName获取平均耗时和异常次数的曲线图信息
@RequestMapping("/getJavaApiGraph")
@ResponseBody
public BaseResponse getJavaApiGraph(@RequestBody NewJavaApiInfoReq req) {
log.info("getJavaApiGraph accept pram : {},{},{}",req.getServiceType(),req.getServiceName(),req.getGraphType());
Map map = newJavaApiInfoService.getJavaApiGraph(req);
BaseResponse rep = new BaseResponse();
rep.setData(map);
return rep;
}
//根据serviceType获取所有ip列表
@RequestMapping("/getIPList")
@ResponseBody
public BaseResponse getIPList(@RequestBody NewJavaApiInfoReq req) {
log.info("getIPList accept pram : {},{},{}",req.getCloudType(),req.getServiceType(),req.getServiceName());
List<String> ipList = newJavaApiInfoService.getIPList(req);
BaseResponse rep = new BaseResponse();
rep.setData(ipList);
return rep;
}
//根据context和ip查询详细接口信息
@RequestMapping("/queryByServiceTypeAndIP")
@ResponseBody
public BaseResponse queryByServiceTypeAndIP(@RequestBody NewJavaApiInfoReq req) {
log.info("getIPList accept pram : {},{},{}",req.getCloudType(),req.getServiceType(),req.getServiceName(),req.getIp(),req.getStartTime(),req.getEndTime());
List<NewJavaApiDetailInfoRep> list = newJavaApiInfoService.queryByServiceTypeAndIP(req);
BaseResponse rep = new BaseResponse();
rep.setData(list);
return rep;
}
@RequestMapping("/test")
@ResponseBody
public BaseResponse test() {
String[] strs = new String[]{"192.168.102.76","172.31.31.169","172.31.28.166","172.31.17.195","172.16.6.235","172.16.6.170","10.66.0.5","10.66.0.4","10.66.0.6","10.66.0.7","10.66.0.8","10.66.0.9","10.66.0.10","10.66.0.11","10.66.0.12","10.66.0.13","10.66.0.14"};
DecimalFormat df = new DecimalFormat("######0.00");
for(int i = 0;i<strs.length;i++){
String ip = strs[i];
Double CPU_UTIL_USER = Double.parseDouble(df.format(RandomUtils.nextDouble()));
Double MEMORY_SIZE_AVAILABLE = Double.parseDouble(df.format(RandomUtils.nextDouble() * 1000));
Double MEMORY_SIZE_TOTAL = Double.parseDouble(df.format(RandomUtils.nextDouble() * 1000));
Double NET_IF_IN = Double.parseDouble(df.format(RandomUtils.nextDouble() * 1000));
Double NET_IF_OUT = Double.parseDouble(df.format(RandomUtils.nextDouble() * 1000));
Point point = Point.measurement("vm_info")
.tag("ip",ip)
.addField("CPU_UTIL_USER",CPU_UTIL_USER).addField("MEMORY_SIZE_AVAILABLE",MEMORY_SIZE_AVAILABLE).addField("MEMORY_SIZE_TOTAL",MEMORY_SIZE_TOTAL)
.addField("NET_IF_IN",NET_IF_IN).addField("NET_IF_OUT",NET_IF_OUT)
.build();
inluxDBSingle.getInfluxDBByName(InfluxDBContants.AWS).getInfluxDB()
.write(InfluxDBContants.ZABBIX, "default", point);
}
return null;
}
@RequestMapping("/test2")
@ResponseBody
public BaseResponse test2() {
String[] strs = new String[]{"192.168.102.76","172.31.31.169","172.31.28.166","172.31.17.195","172.16.6.235","172.16.6.170","10.66.0.5","10.66.0.4","10.66.0.6","10.66.0.7","10.66.0.8","10.66.0.9","10.66.0.10","10.66.0.11","10.66.0.12","10.66.0.13","10.66.0.14"};
for(int i = 0;i<strs.length;i++){
String ip = strs[i];
Point point = Point.measurement("service_access")
.tag("context","gateway").tag("event","/gateway").tag("host","/gateway")
.tag("hostAddress",ip).tag("src_service","app.product.promotion").tag("status_code","200")
.addField("cost", RandomUtils.nextInt(199) + 2000).addField("ip",ip)
.addField("stack","Total Delay [15004ms] /gateway +---[15004ms] - com.yoho.core.common.monitor.ThreadProfileInterceptor.preHandle - [enter:1476930300814,exit:1476930315818] +---[15004ms] - app.product.data. - [enter:1476930300814,exit:1476930315818]")
.build();
inluxDBSingle.getInfluxDBByName(InfluxDBContants.AWS).getInfluxDB()
.write(InfluxDBContants.YOHO_EVENT, "default", point);
}
return null;
}
@RequestMapping("/test3")
@ResponseBody
public BaseResponse test3() {
String[] strs = new String[]{"192.168.102.76","172.31.31.169","172.31.28.166","172.31.17.195","172.16.6.235","172.16.6.170","10.66.0.5","10.66.0.4","10.66.0.6","10.66.0.7","10.66.0.8","10.66.0.9","10.66.0.10","10.66.0.11","10.66.0.12","10.66.0.13","10.66.0.14"};
for(int i = 0;i<strs.length;i++){
String ip = strs[i];
Point point = Point.measurement("service_server_exception")
.tag("context","gateway").tag("event","/gateway").tag("host","/brower/favorite/isFavorite")
.tag("hostAddress",ip).tag("service_name","brower/favorite/isFavorite")
.addField("ip",ip)
.addField("stack","org.apache.catalina\\n.connector.ClientAbortException: java.io.IOException: 断开的管道\\n\\tat org.apache.catalina.connector.OutputBuffer\\n.realWriteBytes(OutputBuffer.java:393)\\n\\tat org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk\\n.java:426)\\n\\tat org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:342)\\n\\tat org\\n.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:317)\\n\\tat org.apache.catalina.connector\\n.CoyoteOutputStream.flush(CoyoteOutputStream.java:110)\\n\\tat com.fasterxml.jackson.core.json.UTF8JsonGenerator\\n.flush(UTF8JsonGenerator.java:1022)\\n\\tat com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter\\n.java:891)\\n\\tat org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.writeInternal\\n(AbstractJackson2HttpMessageConverter.java:264)\\n\\tat org.springframework.http.converter.AbstractGenericHttpMessageConverter\\n.write(AbstractGenericHttpMessageConverter.java:100)\\n\\tat org.springframework.web.servlet.mvc.method\\n.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor\\n.java:202)\\n\\tat org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor\\n.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:133)\\n\\tat org.springframework\\n.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor\\n.java:165)\\n\\tat org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue\\n(HandlerMethodReturnValueHandlerComposite.java:80)\\n\\tat org.springframework.web.servlet.mvc.method.annotation\\n.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:126)\\n\\tat org.springframework\\n.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter\\n.java:806)\\n\\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal\\n(RequestMappingHandlerAdapter.java:729)\\n\\tat org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter\\n.handle(AbstractHandlerMethodAdapter.java:85)\\n\\tat org.springframework.web.servlet.DispatcherServlet\\n.doDispatch(DispatcherServlet.java:959)\\n\\tat org.springframework.web.servlet.DispatcherServlet.doService\\n(DispatcherServlet.java:893)\\n\\tat org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet\\n.java:970)\\n\\tat org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)\\n\\n\\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:648)\\n\\tat org.springframework.web.servlet\\n.FrameworkServlet.service(FrameworkServlet.java:846)\\n\\tat javax.servlet.http.HttpServlet.service(HttpServlet\\n.java:729)\\n\\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain\\n.java:291)\\n\\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java\\n:206)\\n\\tat org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)\\n\\tat org.apache.catalina\\n.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)\\n\\tat org.apache.catalina\\n.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)\\n\\tat org.springframework.web\\n.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)\\n\\tat org.springframework\\n.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\\n\\tat org.apache.catalina.core\\n.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)\\n\\tat org.apache.catalina.core\\n.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)\\n\\tat org.apache.catalina.core.StandardWrapperValve\\n.invoke(StandardWrapperValve.java:217)\\n\\tat org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve\\n.java:106)\\n\\tat org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502\\n)\\n\\tat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)\\n\\tat org.apache\\n.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)\\n\\tat org.apache.catalina.core.StandardEngineValve\\n.invoke(StandardEngineValve.java:88)\\n\\tat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter\\n.java:518)\\n\\tat org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java\\n:1091)\\n\\tat org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java\\n:673)\\n\\tat org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)\\n\\tat\\n org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)\\n\\tat java.util.concurrent\\n.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\\n\\tat java.util.concurrent.ThreadPoolExecutor$Worker\\n.run(ThreadPoolExecutor.java:617)\\n\\tat org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run\\n(TaskThread.java:61)\\n\\tat java.lang.Thread.run(Thread.java:745)\\nCaused by: java.io.IOException: 断开\\n的管道\\n\\tat sun.nio.ch.FileDispatcherImpl.write0(Native Method)\\n\\tat sun.nio.ch.SocketDispatcher.write\\n(SocketDispatcher.java:47)\\n\\tat sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)\\n\\tat sun.nio\\n.ch.IOUtil.write(IOUtil.java:65)\\n\\tat sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471\\n)\\n\\tat org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:124)\\n\\tat org.apache.tomcat.util\\n.net.NioBlockingSelector.write(NioBlockingSelector.java:101)\\n\\tat org.apache.tomcat.util.net.NioSelectorPool\\n.write(NioSelectorPool.java:172)\\n\\tat org.apache.coyote.http11.InternalNioOutputBuffer.writeToSocket\\n(InternalNioOutputBuffer.java:139)\\n\\tat org.apache.coyote.http11.InternalNioOutputBuffer.addToBB(InternalNioOutputBuffer\\n.java:197)\\n\\tat org.apache.coyote.http11.InternalNioOutputBuffer.access$000(InternalNioOutputBuffer\\n.java:41)\\n\\tat org.apache.coyote.http11.InternalNioOutputBuffer$SocketOutputBuffer.doWrite(InternalNioOutputBuffer\\n.java:320)\\n\\tat org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFilter.java\\n:118)\\n\\tat org.apache.coyote.http11.AbstractOutputBuffer.doWrite(AbstractOutputBuffer.java:256)\\n\\tat\\n org.apache.coyote.Response.doWrite(Response.java:501)\\n\\tat org.apache.catalina.connector.OutputBuffer\\n.realWriteBytes(OutputBuffer.java:388)\\n\\t... 47 more\\n")
.build();
inluxDBSingle.getInfluxDBByName(InfluxDBContants.AWS).getInfluxDB()
.write(InfluxDBContants.YOMO_MONITOR, "default", point);
}
return null;
}
}
... ...
package com.monitor.javaserver.service;
import com.monitor.model.request.NewJavaApiInfoReq;
import com.monitor.model.response.NewJavaApiDetailInfoRep;
import com.monitor.model.response.NewJavaApiInfoRep;
import java.util.List;
import java.util.Map;
/**
* Created by yoho on 2016/10/20.
*/
public interface NewJavaApiInfoService {
List<NewJavaApiInfoRep> getJavaApiStatus(NewJavaApiInfoReq req,String startDateStr,String endDateStr);
Map getJavaApiGraph(NewJavaApiInfoReq req);
List<String> getIPList(NewJavaApiInfoReq req);
List<NewJavaApiDetailInfoRep> queryByServiceTypeAndIP(NewJavaApiInfoReq req);
}
... ...
package com.monitor.javaserver.service.impl;
import com.model.MObjectInfo;
import com.model.TypeInfo;
import com.monitor.influxdb.mapper.ServiceAccessMapper;
import com.monitor.influxdb.mapper.ServiceServerExceptionMapper;
import com.monitor.influxdb.mapper.VMInfoMapper;
import com.monitor.javaserver.service.NewJavaApiInfoService;
import com.monitor.model.request.NewJavaApiInfoReq;
import com.monitor.model.response.NewJavaApiDetailInfoRep;
import com.monitor.model.response.NewJavaApiInfoRep;
import com.monitor.mysql.mapper.MObjectInfoMapper;
import com.monitor.mysql.mapper.MTypeInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
/**
* Created by yoho on 2016/10/20.
*/
@Service
public class NewJavaApiInfoServiceImpl implements NewJavaApiInfoService {
@Autowired
MObjectInfoMapper mObjectInfoMapper;
@Autowired
ServiceAccessMapper serviceAccessMapper;
@Autowired
ServiceServerExceptionMapper serviceServerExceptionMapper;
@Autowired
private MTypeInfoMapper mTypeInfoMapper;
@Autowired
private VMInfoMapper vmInfoMapper;
@Override
public List<NewJavaApiInfoRep> getJavaApiStatus(NewJavaApiInfoReq req,String startDateStr,String endDateStr) {
List<MObjectInfo> objectInfoList = getMObjectInfoList(req);
if(CollectionUtils.isEmpty(objectInfoList)){
return null;
}
//获取总请求次数和平均耗时
Map<String,NewJavaApiInfoRep> infoMap = serviceAccessMapper.getBaseDataByContext(req.getServiceName(),startDateStr,endDateStr);
//获取超时数据
Map<String,List<String>> timeoutInfoMap = serviceAccessMapper.getTimeoutInfo(req.getServiceName(),startDateStr,endDateStr);
//获取异常数据
Map<String,List<String>> errorInfoMap = serviceServerExceptionMapper.getErrorDataByContext(req.getServiceName(),startDateStr,endDateStr);
//获取cpu、内存、带宽使用情况
Map vmInfoMap = vmInfoMapper.getVMInfo();
List<NewJavaApiInfoRep> returnList = new ArrayList<>();
for(MObjectInfo mObjectInfo :objectInfoList){
NewJavaApiInfoRep resp = new NewJavaApiInfoRep();
String ip = mObjectInfo.getMoHostIp();
resp.setIp(ip);
if(ip.startsWith("172")){
resp.setType("AWS");
}else{
resp.setType("QCloud");
}
resp.setTotalCount(infoMap.get(ip) == null ? 0 : infoMap.get(ip).getTotalCount());
resp.setAvgCost(infoMap.get(ip) == null ? 0 : infoMap.get(ip).getAvgCost());
resp.setErrorCount(errorInfoMap.get(ip) == null ? 0 : errorInfoMap.get(ip).size());
resp.setErrorInfo(errorInfoMap.get(ip));
resp.setTimeoutInfo(timeoutInfoMap.get(ip));
List vmList = (List)vmInfoMap.get(ip);
if(vmList != null){
resp.setCpuRate("" + vmList.get(1) + "%");
resp.setMemoryRate("" + vmList.get(2) + "/" + vmList.get(3));
resp.setBandwidth("" + vmList.get(4) + "/" + vmList.get(5));
}
returnList.add(resp);
}
return returnList;
}
@Override
public Map getJavaApiGraph(NewJavaApiInfoReq req){
Map returnMap = new HashMap();
List<MObjectInfo> objectInfoList = getMObjectInfoList(req);
if(CollectionUtils.isEmpty(objectInfoList)){
return null;
}
Map<String,List> map = null;
if(req.getGraphType()==2){
map = serviceServerExceptionMapper.getGraphInfo(req.getServiceName());
}else{
map = serviceAccessMapper.getGraphInfo(req.getServiceName());
}
List<String> timeList = new ArrayList<String>();
List contentList = new ArrayList<>();
for(MObjectInfo mObjectInfo :objectInfoList){
Map dataMap = new HashMap();
String ip = mObjectInfo.getMoHostIp();
List list = map.get(ip);
if(list != null && list.size() > 0){
if(timeList.size()==0){
timeList = (List)list.get(0);
}
dataMap.put("data",list.get(1));
}else{
dataMap.put("data",new ArrayList<>());
}
dataMap.put("name",ip);
contentList.add(dataMap);
}
returnMap.put("time",timeList);
returnMap.put("content",contentList);
return returnMap;
}
@Override
public List<String> getIPList(NewJavaApiInfoReq req){
List<MObjectInfo> objectInfoList = mObjectInfoMapper.getTypeMosInfo(req.getServiceType());
List<String> ipList = new ArrayList<>();
for(MObjectInfo mObjectInfo : objectInfoList){
if(req.getCloudType()==2){
if(mObjectInfo.getMoHostIp().startsWith("10.")){
ipList.add(mObjectInfo.getMoHostIp());
}
}else{
if(mObjectInfo.getMoHostIp().startsWith("172.")){
ipList.add(mObjectInfo.getMoHostIp());
}
}
}
return ipList;
}
//查询根据servicetype查询所有ip信息
private List<MObjectInfo> getMObjectInfoList(NewJavaApiInfoReq req){
if(req.getServiceType() == 0){
TypeInfo typeInfo = mTypeInfoMapper.selectTypeInfoByName(req.getServiceName());
if(typeInfo == null){
return null;
}
req.setServiceType(typeInfo.getTypeId());
}
List<MObjectInfo> objectInfoList = mObjectInfoMapper.getTypeMosInfo(req.getServiceType());
return objectInfoList;
}
@Override
public List<NewJavaApiDetailInfoRep> queryByServiceTypeAndIP(NewJavaApiInfoReq req) {
List<NewJavaApiDetailInfoRep> returnList = new ArrayList<>();
//获取总请求次数和平均耗时
List<NewJavaApiDetailInfoRep> dataList = serviceAccessMapper.getDataByContextAndIP(req);
//获取超时数据
Map<String,List<String>> timeoutInfoMap = serviceAccessMapper.getTimeoutInfoByContextAndIp(req);
//获取异常数据
Map<String,List<String>> exceptionMap = serviceServerExceptionMapper.getErrorDataByContextAndIp(req);
for(NewJavaApiDetailInfoRep rep :dataList){
NewJavaApiDetailInfoRep returnRep = new NewJavaApiDetailInfoRep();
String apiName = rep.getApiName();
returnRep.setApiName(apiName);
returnRep.setErrorInfo(exceptionMap.get(apiName));
returnRep.setTotalCount(rep.getTotalCount());
returnRep.setAvgCost(rep.getAvgCost());
returnRep.setErrorCount(exceptionMap.get(apiName) == null ? 0 : exceptionMap.get(apiName).size());
returnRep.setTimeoutInfo(timeoutInfoMap.get(apiName));
returnList.add(returnRep);
}
return returnList;
}
}
... ...
... ... @@ -14,6 +14,4 @@ public class CenterSwitchModel {
private String exe;
private String toCloud;
}
... ...
package com.monitor.model.request;
/**
* Created by yoho on 2016/10/20.
*/
public class NewJavaApiInfoReq {
private int serviceType;
private String serviceName;
private int timeInterval;
//曲线图类型,1:平均耗时,2:异常次数
private int graphType;
private String ip;
private String startTime;
private String endTime;
//1:aws 2:qcloud
private int cloudType;
public int getServiceType() {
return serviceType;
}
public void setServiceType(int serviceType) {
this.serviceType = serviceType;
}
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
public int getTimeInterval() {
return timeInterval;
}
public void setTimeInterval(int timeInterval) {
this.timeInterval = timeInterval;
}
public int getGraphType() {
return graphType;
}
public void setGraphType(int graphType) {
this.graphType = graphType;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public int getCloudType() {
return cloudType;
}
public void setCloudType(int cloudType) {
this.cloudType = cloudType;
}
}
... ...
package com.monitor.model.response;
import java.util.List;
/**
* Created by yoho on 2016/10/25.
*/
public class NewJavaApiDetailInfoRep {
private Integer totalCount = 0;
private Integer errorCount = 0;
private List<String> errorInfo;
private List<String> timeoutInfo;
private Integer avgCost = 0;
private String apiName;
public Integer getTotalCount() {
return totalCount;
}
public void setTotalCount(Integer totalCount) {
this.totalCount = totalCount;
}
public Integer getErrorCount() {
return errorCount;
}
public void setErrorCount(Integer errorCount) {
this.errorCount = errorCount;
}
public List<String> getErrorInfo() {
return errorInfo;
}
public void setErrorInfo(List<String> errorInfo) {
this.errorInfo = errorInfo;
}
public List<String> getTimeoutInfo() {
return timeoutInfo;
}
public void setTimeoutInfo(List<String> timeoutInfo) {
this.timeoutInfo = timeoutInfo;
}
public Integer getAvgCost() {
return avgCost;
}
public void setAvgCost(Integer avgCost) {
this.avgCost = avgCost;
}
public String getApiName() {
return apiName;
}
public void setApiName(String apiName) {
this.apiName = apiName;
}
}
... ...
package com.monitor.model.response;
import java.util.List;
/**
* Created by yoho on 2016/10/20.
*/
public class NewJavaApiInfoRep {
private String ip;
private String type;
private Integer totalCount = 0;
private Integer errorCount = 0;
private List<String> errorInfo;
private List<String> timeoutInfo;
private Integer avgCost = 0;
private String cpuRate = "";
private String memoryRate = "";
private String bandwidth = "";
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Integer getTotalCount() {
return totalCount;
}
public void setTotalCount(Integer totalCount) {
this.totalCount = totalCount;
}
public Integer getErrorCount() {
return errorCount;
}
public void setErrorCount(Integer errorCount) {
this.errorCount = errorCount;
}
public List<String> getErrorInfo() {
return errorInfo;
}
public void setErrorInfo(List<String> errorInfo) {
this.errorInfo = errorInfo;
}
public String getCpuRate() {
return cpuRate;
}
public void setCpuRate(String cpuRate) {
this.cpuRate = cpuRate;
}
public String getMemoryRate() {
return memoryRate;
}
public void setMemoryRate(String memoryRate) {
this.memoryRate = memoryRate;
}
public String getBandwidth() {
return bandwidth;
}
public void setBandwidth(String bandwidth) {
this.bandwidth = bandwidth;
}
public Integer getAvgCost() {
return avgCost;
}
public void setAvgCost(Integer avgCost) {
this.avgCost = avgCost;
}
public List<String> getTimeoutInfo() {
return timeoutInfo;
}
public void setTimeoutInfo(List<String> timeoutInfo) {
this.timeoutInfo = timeoutInfo;
}
}
... ...
... ... @@ -18,7 +18,7 @@
</select>
<select id="getTypeMosInfo" parameterType="int" resultType="com.model.MObjectInfo" resultMap="mobjectInfoMapper">
SELECT * FROM mobject_info WHERE type_id = #{moTypeId}
SELECT * FROM mobject_info WHERE type_id = #{moTypeId} order by host_ip DESC
</select>
<!-- <select id="getHostMosInfo" parameterType="int" resultType="com.model.MObjectInfo" resultMap="mobjectInfoMapper">
... ...
... ... @@ -69,10 +69,10 @@ public class DBWorkCtrl {
@ResponseBody
public BaseResponse<Integer> checkRole(String role) {
if (HandlerRole.DEVELOP.equals(role)){
// if (HandlerRole.DEVELOP.equals(role)){
return new BaseResponse<>(1);
}
return new BaseResponse<>(0);
// }
// return new BaseResponse<>(0);
}
... ...
... ... @@ -89,10 +89,10 @@ public class ReleaseWorkCtrl {
@ResponseBody
public BaseResponse<Integer> checkRole(String role) {
if (HandlerRole.DEVELOP.equals(role)){
// if (HandlerRole.DEVELOP.equals(role)){
return new BaseResponse<>(1);
}
return new BaseResponse<>(0);
// }
// return new BaseResponse<>(0);
}
}
... ...
... ... @@ -72,7 +72,7 @@ public class CommodUtil {
*/
public static List<String> exe(String commond) {
// try {
// Thread.sleep(10000);
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
... ...
... ... @@ -20,7 +20,7 @@ public class CenterSwitchCtrl {
@RequestMapping("/getSwitchList")
@ResponseBody
public BaseResponse getSwitchList(){
public BaseResponse getSwitchList() {
List<CenterSwitchModel> list = new ArrayList<>();
CenterSwitchModel all = new CenterSwitchModel();
... ... @@ -29,43 +29,43 @@ public class CenterSwitchCtrl {
list.add(all);
CenterSwitchModel db_aws_master_readonly = new CenterSwitchModel();
db_aws_master_readonly.setName("db_aws_master_readonly");
db_aws_master_readonly.setCName("数据库只读");
db_aws_master_readonly.setName("switch_db_aws_readonly");
db_aws_master_readonly.setCName("aws数据读写切换");
list.add(db_aws_master_readonly);
CenterSwitchModel db_qcloud_remove_readonly = new CenterSwitchModel();
db_qcloud_remove_readonly.setName("db_qcloud_remove_readonly");
db_qcloud_remove_readonly.setCName("数据库可写");
db_qcloud_remove_readonly.setName("switch_db_qcloud_readonly");
db_qcloud_remove_readonly.setCName("qq数据读写切换");
list.add(db_qcloud_remove_readonly);
CenterSwitchModel cobar = new CenterSwitchModel();
cobar.setName("cobar");
cobar.setName("switch_cobar");
cobar.setCName("cobar");
list.add(cobar);
CenterSwitchModel redis = new CenterSwitchModel();
redis.setName("redis_qcloudtomaster");
redis.setName("switch_redis");
redis.setCName("redis");
list.add(redis);
CenterSwitchModel internel_dns_aws = new CenterSwitchModel();
internel_dns_aws.setName("internel_dns_aws");
internel_dns_aws.setName("switch_internel_dns_aws");
internel_dns_aws.setCName("aws内部DNS");
list.add(internel_dns_aws);
CenterSwitchModel internel_dns_qcloud = new CenterSwitchModel();
internel_dns_qcloud.setName("internel_dns_qcloud");
internel_dns_qcloud.setName("switch_internel_dns_qcloud");
internel_dns_qcloud.setCName("qcloud内部DNS");
list.add(internel_dns_qcloud);
CenterSwitchModel switch_lua = new CenterSwitchModel();
switch_lua.setName("switch_lua");
switch_lua.setCName("lua 切换");
switch_lua.setCName("lua");
list.add(switch_lua);
CenterSwitchModel switch_dnspod = new CenterSwitchModel();
switch_dnspod.setName("switch_dnspod");
switch_dnspod.setCName("dnspod 切换");
switch_dnspod.setCName("dnspod");
list.add(switch_dnspod);
return new BaseResponse(list);
... ... @@ -73,31 +73,23 @@ public class CenterSwitchCtrl {
@RequestMapping("/doExe")
@ResponseBody
public BaseResponse doExe(@RequestBody CenterSwitchModel centerSwitchModel){
public BaseResponse doExe(@RequestBody CenterSwitchModel centerSwitchModel) {
StringBuilder commond = new StringBuilder("ssh root@10.66.4.25 sh /root/script/oneKeySwitch/");
if ("aws".equals(centerSwitchModel.getToCloud()) && !"switch_lua".equals(centerSwitchModel.getName()) ){
centerSwitchModel.setName(centerSwitchModel.getName() + "_re");
}
if (!"switch_lua".equals(centerSwitchModel.getName())){
commond.append(centerSwitchModel.getName());
commond.append(".sh ");
commond.append(centerSwitchModel.getToCloud());
}else {
commond.append("switch_lua.sh -e switch -s ");
commond.append(centerSwitchModel.getToCloud());
}
List<String> resultList = CommodUtil.exe(commond.toString());
commond.append(centerSwitchModel.getName());
commond.append(".sh ");
commond.append(centerSwitchModel.getExe());
List<String> resultList = CommodUtil.exe(commond.toString());
StringBuilder result = new StringBuilder();
for (String str : resultList){
result.append(str).append("\r\n");
for (String str : resultList) {
result.append(str).append("</br>");
}
BaseResponse baseResponse = new BaseResponse();
baseResponse.setData(result.toString());
return baseResponse;
}
}
... ...
# ******************** influxdb common configs ********************
influxdb.num=2
influxdb.name=test;alarm
influxdb.ip=http://192.168.102.162:8086;http://123.206.79.151:18086
influxdb.user=yoho;root
influxdb.pwd=Yoho_9646;root
influxdb.connect.timeout=15;15
influxdb.read.timeout=40;40
influxdb.write.timeout=20;20
influxdb.num=4
influxdb.name=test;alarm;aws;qcloud
influxdb.ip=http://192.168.102.76:8086;http://192.168.102.76:8086;http://127.0.0.1:8086;http://127.0.0.1:8086
influxdb.user=yoho;root;root;root
influxdb.pwd=Yoho_9646;root;root;root
influxdb.connect.timeout=15;15;15;15
influxdb.read.timeout=40;40;40;40
influxdb.write.timeout=20;20;20;20
aws.influxdb.url=http://192.168.102.76:8086
aws.influxdb.user=root
... ...