Pārlūkot izejas kodu

Merge branch 'master' of http://192.168.1.220:10080/esb/esb

Airhead 8 gadi atpakaļ
vecāks
revīzija
565719f27e
25 mainītis faili ar 581 papildinājumiem un 632 dzēšanām
  1. 0 6
      hos-broker/pom.xml
  2. 22 23
      hos-broker/src/main/java/com/yihu/hos/common/appender/JMSAppender.java
  3. 14 9
      hos-broker/src/main/java/com/yihu/hos/common/scheduler/MonitorScheduler.java
  4. 0 64
      hos-broker/src/main/java/com/yihu/hos/controllers/ServiceMonitorController.java
  5. 5 5
      hos-broker/src/main/java/com/yihu/hos/models/BusinessLog.java
  6. 9 21
      hos-broker/src/main/java/com/yihu/hos/models/ServiceMetrics.java
  7. 100 168
      hos-broker/src/main/java/com/yihu/hos/services/ServiceMonitorService.java
  8. 3 3
      hos-camel/src/main/java/qlc/route/QlcRouteBulider.java
  9. 16 0
      hos-web-framework-dependencies/pom.xml
  10. 1 1
      hos-web-framework/src/main/java/com/yihu/hos/web/framework/dao/SQLGeneralDAO.java
  11. 1 1
      hos-web-framework/src/main/java/com/yihu/hos/web/framework/dao/XSQLGeneralDAO.java
  12. 1 3
      src/main/java/com/yihu/hos/common/SessionOutTimeFilter.java
  13. 12 0
      src/main/java/com/yihu/hos/monitor/controller/ServerMonitorController.java
  14. 38 6
      src/main/java/com/yihu/hos/monitor/controller/ServiceMonitorController.java
  15. 30 0
      src/main/java/com/yihu/hos/monitor/dao/ServiceMonitorDao.java
  16. 17 0
      src/main/java/com/yihu/hos/monitor/service/ServerMonitorService.java
  17. 86 173
      src/main/java/com/yihu/hos/monitor/service/ServiceMonitorService.java
  18. 9 0
      src/main/java/com/yihu/hos/system/model/SystemServiceFlow.java
  19. 37 0
      src/main/java/com/yihu/hos/system/model/SystemServiceFlowConfig.java
  20. 5 0
      src/main/resources/resource/SystemServiceFlow.hbm.xml
  21. 23 0
      src/main/resources/resource/SystemServiceFlowConfig.hbm.xml
  22. 2 2
      src/main/webapp/WEB-INF/ehr/jsp/monitor/server/sEnvManage.jsp
  23. 46 44
      src/main/webapp/WEB-INF/ehr/jsp/monitor/server/sEnvManageJs.jsp
  24. 7 18
      src/main/webapp/WEB-INF/ehr/jsp/monitor/service/sEnvManage.jsp
  25. 97 85
      src/main/webapp/WEB-INF/ehr/jsp/monitor/service/sEnvManageJs.jsp

+ 0 - 6
hos-broker/pom.xml

@ -55,12 +55,6 @@
            <groupId>com.yihu.hos</groupId>
            <artifactId>hos-web-framework</artifactId>
            <version>1.1.1-SNAPSHOT</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>log4j-over-slf4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.camel/camel-stream -->
        <!-- sigar -->

+ 22 - 23
hos-broker/src/main/java/com/yihu/hos/common/appender/JMSAppender.java

@ -60,12 +60,12 @@ import java.util.Properties;
   <pre>
   InitialContext jndiContext = new InitialContext();
   </pre>
  
 * <p>Calling the no-argument <code>InitialContext()</code> method
 * will also work from within Enterprise Java Beans (EJBs) because it
 * is part of the EJB contract for application servers to provide each
 * bean an environment naming context (ENC).
    
 * <p>In the second approach, several predetermined properties are set
 * and these properties are passed to the <code>InitialContext</code>
 * constructor to connect to the naming service provider. For example,
@ -93,7 +93,7 @@ import java.util.Properties;
</pre>
  * <p>Other JMS providers will obviously require different values.
  * 
  *
  * The initial JNDI context can be obtained by calling the
  * no-argument <code>InitialContext()</code> method in EJBs. Only
  * clients running in a separate JVM need to be concerned about the
@ -193,7 +193,7 @@ public class JMSAppender extends AppenderSkeleton {
	if(urlPkgPrefixes != null) {
	  env.put(Context.URL_PKG_PREFIXES, urlPkgPrefixes);
	}
	
	if(securityPrincipalName != null) {
	  env.put(Context.SECURITY_PRINCIPAL, securityPrincipalName);
	  if(securityCredentials != null) {
@ -202,7 +202,7 @@ public class JMSAppender extends AppenderSkeleton {
	    LogLog.warn("You have set SecurityPrincipalName option but not the "
			+"SecurityCredentials. This is likely to cause problems.");
	  }
	}	
	}
	jndi = new InitialContext(env);
      } else {
	jndi = new InitialContext();
@ -212,8 +212,8 @@ public class JMSAppender extends AppenderSkeleton {
      topicConnectionFactory = (TopicConnectionFactory) lookup(jndi, tcfBindingName);
      LogLog.debug("About to create TopicConnection.");
      if(userName != null) {
	topicConnection = topicConnectionFactory.createTopicConnection(userName, 
								       password); 
	topicConnection = topicConnectionFactory.createTopicConnection(userName,
								       password);
      } else {
	topicConnection = topicConnectionFactory.createTopicConnection();
      }
@ -228,7 +228,7 @@ public class JMSAppender extends AppenderSkeleton {
      LogLog.debug("Creating TopicPublisher.");
      topicPublisher = topicSession.createPublisher(topic);
      
      LogLog.debug("Starting TopicConnection.");
      topicConnection.start();
@ -315,13 +315,12 @@ public class JMSAppender extends AppenderSkeleton {
        return;
      }
      ObjectMessage msg = topicSession.createObjectMessage();
      String message = event.getMessage().toString();
      String routeId = StringUtil.toString(event.getMDC("camel.routeId"));
      if (message.contains("("+routeId+") log[servers:")) {
        String body = message.substring(message.indexOf("Body:") + 5);
        String totalServers = message.substring(message.indexOf("log[servers:") + 13, message.indexOf(","));
        String serverName = message.substring(message.indexOf("name") + 6, message.indexOf("]"));
        String code = message.substring(message.indexOf("code") + 6, message.indexOf("]"));
        Map<String, Object> map = new HashMap<>();
        map.put("exchangeId", StringUtil.toString(event.getMDC("camel.exchangeId")));
        map.put("correlationId", StringUtil.toString(event.getMDC("camel.correlationId")));
@ -330,7 +329,7 @@ public class JMSAppender extends AppenderSkeleton {
        map.put("breadcrumbId",StringUtil.toString(event.getMDC("camel.breadcrumbId")));
        map.put("camelContextId", StringUtil.toString(event.getMDC("camel.contextId")));
        map.put("totalServers", Integer.parseInt(totalServers));
        map.put("serverName", serverName);
        map.put("code", code);
        map.put("body", body);
        map.put("fireTimeSource", DateUtil.toStringFormatGMTTime(DateUtil.toGMTTime(event.getTimeStamp()), DateUtil.DEFAULT_TIMESTAMP_FORMAT));
        msg.setObject(JSONObject.fromObject(map).toString());
@ -351,15 +350,15 @@ public class JMSAppender extends AppenderSkeleton {
   * meaning of this option.
   * */
  public String getInitialContextFactoryName() {
    return initialContextFactoryName;    
    return initialContextFactoryName;
  }
  
  public void setInitialContextFactoryName(String initialContextFactoryName) {
    this.initialContextFactoryName = initialContextFactoryName;
  }
  public String getProviderURL() {
    return providerURL;    
    return providerURL;
  }
  public void setProviderURL(String providerURL) {
@ -373,18 +372,18 @@ public class JMSAppender extends AppenderSkeleton {
  public void setURLPkgPrefixes(String urlPkgPrefixes ) {
    this.urlPkgPrefixes = urlPkgPrefixes;
  }
  
  public String getSecurityCredentials() {
    return securityCredentials;    
    return securityCredentials;
  }
  public void setSecurityCredentials(String securityCredentials) {
    this.securityCredentials = securityCredentials;
  }
  
  
  public String getSecurityPrincipalName() {
    return securityPrincipalName;    
    return securityPrincipalName;
  }
  public void setSecurityPrincipalName(String securityPrincipalName) {
@ -392,7 +391,7 @@ public class JMSAppender extends AppenderSkeleton {
  }
  public String getUserName() {
    return userName;    
    return userName;
  }
  /**
@ -407,7 +406,7 @@ public class JMSAppender extends AppenderSkeleton {
  }
  public String getPassword() {
    return password;    
    return password;
  }
  /**
@ -449,8 +448,8 @@ public class JMSAppender extends AppenderSkeleton {
  protected TopicPublisher  getTopicPublisher() {
    return topicPublisher;
  }
  
  /** 
  /**
   * The JMSAppender sends serialized events and consequently does not
   * require a layout.
   */

+ 14 - 9
hos-broker/src/main/java/com/yihu/hos/common/scheduler/MonitorScheduler.java

@ -1,5 +1,6 @@
package com.yihu.hos.common.scheduler;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.yihu.hos.common.constants.MonitorConstant;
import com.yihu.hos.common.util.MongodbUtil;
import com.yihu.hos.common.util.SigarUtil;
@ -35,8 +36,12 @@ public class MonitorScheduler {
    public void statusCheck() {
        System.out.println("每分钟执行一次。开始============================================");
        //TODO 采集服务器健康监控指标数据 statusTask.healthCheck();
        collectEnvHealth();
        collectServiceHealth();
//        collectEnvHealth();
//        try {
//            collectServiceHealth();
//        } catch (JsonProcessingException e) {
//            e.printStackTrace();
//        }
        System.out.println("每分钟执行一次。结束。");
    }
@ -78,15 +83,15 @@ public class MonitorScheduler {
        return "";
    }
    public void collectServiceHealth(){
    public void collectServiceHealth() throws JsonProcessingException {
        Date now = new Date();
        Date beforeDate = new Date(now.getTime() - 60000);
        System.out.println(DateUtil.toString(beforeDate, DateUtil.DEFAULT_YMDHMSDATE_FORMAT));
        System.out.println(DateUtil.toString(now, DateUtil.DEFAULT_YMDHMSDATE_FORMAT));
//        serviceMonitorService.bandwidth(beforeDate.toString(), now.toString());
//        serviceMonitorService.qps(beforeDate.toString(), now.toString());
//        serviceMonitorService.delay(beforeDate.toString(), now.toString());
//        serviceMonitorService.usage(beforeDate.toString(), now.toString());
        String beginTime = DateUtil.toString(beforeDate, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
        String endTime = DateUtil.toString(now, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
        serviceMonitorService.bandwidth(beginTime, endTime);
        serviceMonitorService.qps(beginTime, endTime);
        serviceMonitorService.delay(beginTime, endTime);
        serviceMonitorService.usage(beginTime, endTime);
    }
//    @Scheduled(fixedRate=10000)

+ 0 - 64
hos-broker/src/main/java/com/yihu/hos/controllers/ServiceMonitorController.java

@ -1,64 +0,0 @@
package com.yihu.hos.controllers;
import com.yihu.hos.services.ServiceMonitorService;
import com.yihu.hos.web.framework.model.Result;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
@Controller
@RequestMapping("/service")
public class ServiceMonitorController {
    @Resource(name = ServiceMonitorService.BEAN_ID)
    private ServiceMonitorService serviceMonitorService;
    @RequestMapping(value = "/bandwidth", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "获取带宽", produces = "application/json", notes = "获取带宽")
    public Result bandwidth(
            @ApiParam(name = "beginTime", value = "开始时间", required = true)
            @RequestParam(value = "beginTime") String beginTime,
            @ApiParam(name = "endTime", value = "结束时间", required = true)
            @RequestParam(value = "endTime") String endTime) {
        return serviceMonitorService.bandwidth(beginTime, endTime);
    }
    @RequestMapping(value = "/qps", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "获取吞吐量", produces = "application/json", notes = "获取吞吐量")
    public Result qps(
            @ApiParam(name = "beginTime", value = "开始时间", required = true)
            @RequestParam(value = "beginTime") String beginTime,
            @ApiParam(name = "endTime", value = "结束时间", required = true)
            @RequestParam(value = "endTime") String endTime) {
        return serviceMonitorService.qps(beginTime, endTime);
    }
    @RequestMapping(value = "/usage", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "获取使用率", produces = "application/json", notes = "获取使用率")
    public Result usage(
            @ApiParam(name = "beginTime", value = "开始时间", required = true)
            @RequestParam(value = "beginTime") String beginTime,
            @ApiParam(name = "endTime", value = "结束时间", required = true)
            @RequestParam(value = "endTime") String endTime) {
        return serviceMonitorService.usage(beginTime, endTime);
    }
    @RequestMapping(value = "/delay", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "获取延时", produces = "application/json", notes = "获取延时")
    public Result delay(
            @ApiParam(name = "beginTime", value = "开始时间", required = true)
            @RequestParam(value = "beginTime") String beginTime,
            @ApiParam(name = "endTime", value = "结束时间", required = true)
            @RequestParam(value = "endTime") String endTime) {
        return serviceMonitorService.delay(beginTime, endTime);
    }
}

+ 5 - 5
hos-broker/src/main/java/com/yihu/hos/models/BusinessLog.java

@ -22,7 +22,7 @@ public class BusinessLog {
    @Indexed
    private String breadcrumbId;
    private Integer totalServers;
    private String serverName;
    private String code;
    private String camelContextId;
    private String body;
    private Integer bodyLength;
@ -128,11 +128,11 @@ public class BusinessLog {
        this.totalServers = totalServers;
    }
    public String getServerName() {
        return serverName;
    public String getCode() {
        return code;
    }
    public void setServerName(String serverName) {
        this.serverName = serverName;
    public void setCode(String code) {
        this.code = code;
    }
}

+ 9 - 21
hos-broker/src/main/java/com/yihu/hos/models/ServiceMetrics.java

@ -13,12 +13,8 @@ import java.util.Date;
public class ServiceMetrics {
    @Id
    private String id;
    @Indexed
    private String routeId;
    @Indexed
    private String breadcrumbId;
    private String type;
    private String name;
    private String value;
    private String createTime;
@ -30,22 +26,6 @@ public class ServiceMetrics {
        this.id = id;
    }
    public String getRouteId() {
        return routeId;
    }
    public void setRouteId(String routeId) {
        this.routeId = routeId;
    }
    public String getBreadcrumbId() {
        return breadcrumbId;
    }
    public void setBreadcrumbId(String breadcrumbId) {
        this.breadcrumbId = breadcrumbId;
    }
    public String getType() {
        return type;
    }
@ -54,6 +34,14 @@ public class ServiceMetrics {
        this.type = type;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getValue() {
        return value;
    }

+ 100 - 168
hos-broker/src/main/java/com/yihu/hos/services/ServiceMonitorService.java

@ -1,12 +1,13 @@
package com.yihu.hos.services;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mongodb.*;
import com.yihu.hos.core.datatype.DateUtil;
import com.yihu.hos.core.datatype.NumberUtil;
import com.yihu.hos.core.datatype.StringUtil;
import com.yihu.hos.models.BusinessLog;
import com.yihu.hos.models.ServiceMetrics;
import com.yihu.hos.web.framework.model.Result;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoOperations;
@ -21,10 +22,9 @@ import java.util.Date;
@Service("ServiceMonitorService")
public class ServiceMonitorService {
    public static final String BEAN_ID = "ServiceMonitorService";
    @Autowired
    private MongoOperations mongoOperations;
    private DBCollection businessLog;
//    public Result mapReduce(String beginTime, String endTime) {
//        DBCollection businessLogDB = mongoOperations.getCollection(mongoOperations
//                .getCollectionName(BusinessLog.class));
@ -81,170 +81,95 @@ public class ServiceMonitorService {
//        return jsonObject;
//    }
    public Result bandwidth(String beginTime, String endTime) {
        DBCollection businessLog = mongoOperations.getCollection(mongoOperations
                .getCollectionName(BusinessLog.class));
        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
                new BasicDBObject[]{
                        new BasicDBObject().append("fireTime",
                                new BasicDBObject().append(QueryOperators.GTE, DateUtil.toTimestamp(beginTime))),
                        new BasicDBObject().append("fireTime",
                                new BasicDBObject().append(QueryOperators.LT, DateUtil.toTimestamp(endTime)))});
    public DBCollection getBusinessLog() {
        if (businessLog == null) {
            businessLog = mongoOperations.getCollection(mongoOperations
                    .getCollectionName(BusinessLog.class));
        }
        return businessLog;
        DBObject match = new BasicDBObject("$match", queryObject);
    }
    public void bandwidth(String beginTime, String endTime) {
        // Now the $group operation
        DBObject groupFields = new BasicDBObject( "_id",
                new BasicDBObject("breadcrumbId", "$breadcrumbId")
                .append("routeId", "$routeId"));
//        groupFields.put("routeId", new BasicDBObject( "$first", "$routeId"));
        groupFields.put("count", new BasicDBObject( "$sum", 1));
        groupFields.put("beginTime", new BasicDBObject( "$first", "$fireTimeSource"));
        groupFields.put("endTime", new BasicDBObject("$last", "$fireTimeSource"));
        DBObject group = new BasicDBObject("$group", groupFields);
        // build the $sort operation
        DBObject sortFields =  new BasicDBObject( "_id", 1);
        DBObject sort = new BasicDBObject("$sort", sortFields );
        DBObject match = getMatchFields(beginTime, endTime);
        DBObject flowGroup = getFlowGroupFields();
        DBObject sort = getSortFields();
        DBObject serviceGroup = getServiceGroupFields();
        // run aggregation
        AggregationOutput flowOutput = getBusinessLog().aggregate(match, flowGroup, sort);
        // run aggregation
        AggregationOutput output = businessLog.aggregate(match, group, sort);
        AggregationOutput serviceOutput = getBusinessLog().aggregate(match, serviceGroup, sort);
        Integer calls = 0;
        long interval = 0;
        String routeId = "";
        String breadcrumbId = "";
        for (DBObject dbObject : output.results()) {
        for (DBObject dbObject : flowOutput.results()) {
            Integer count = Integer.parseInt(StringUtil.toString(dbObject.get("count")));
            BasicDBObject id = (BasicDBObject) dbObject.get("_id");
            routeId = StringUtil.toString(id.get("routeId"));
            breadcrumbId  = StringUtil.toString(id.get("breadcrumbId"));
            if (count >= 2) {
                calls++;
                String begin = StringUtil.toString(dbObject.get("beginTime"));
                String end = StringUtil.toString(dbObject.get("endTime"));
                Date from = DateUtil.toTimestamp(begin, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
                Date to = DateUtil.toTimestamp(end, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
                interval += (to.getTime() - from.getTime())/1000;
            }
        }
        long interval = getInterval(beginTime, endTime);
        BigDecimal bandwidth = NumberUtil.divideBigDecimal(BigDecimal.valueOf(calls), BigDecimal.valueOf(interval));
        saveServiceMetrics(routeId, "bandwidth", bandwidth.toString(), endTime);
        ServiceMetrics serviceMetrics = new ServiceMetrics();
        serviceMetrics.setRouteId(routeId);
        serviceMetrics.setBreadcrumbId(breadcrumbId);
        serviceMetrics.setType("bandwidth");
        serviceMetrics.setValue(bandwidth.toString());
        serviceMetrics.setCreateTime(endTime);
        mongoOperations.save(serviceMetrics);
        JSONObject result = new JSONObject();
        result.put("bandwidth", bandwidth);
        System.out.println(result);
        return Result.success(result.toString());
        Integer calls1 = 0;
        String code = "";
        for (DBObject dbObject : serviceOutput.results()) {
            Integer count = Integer.parseInt(StringUtil.toString(dbObject.get("count")));
            BasicDBObject id = (BasicDBObject) dbObject.get("_id");
            code = StringUtil.toString(id.get("code"));
            calls++;
        }
        BigDecimal bandwidth1 = NumberUtil.divideBigDecimal(BigDecimal.valueOf(calls1), BigDecimal.valueOf(interval));
        saveServiceMetrics(code, "bandwidth", bandwidth1.toString(), endTime);
    }
    public Result qps(String beginTime, String endTime) {
        DBCollection businessLog = mongoOperations.getCollection(mongoOperations
                .getCollectionName(BusinessLog.class));
        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
                new BasicDBObject[]{
                        new BasicDBObject().append("fireTime",
                                new BasicDBObject().append(QueryOperators.GTE, DateUtil.toTimestamp(beginTime))),
                        new BasicDBObject().append("fireTime",
                                new BasicDBObject().append(QueryOperators.LT, DateUtil.toTimestamp(endTime)))});
        DBObject match = new BasicDBObject("$match", queryObject);
        // Now the $group operation
        DBObject groupFields = new BasicDBObject( "_id",
                new BasicDBObject("breadcrumbId", "$breadcrumbId")
                        .append("routeId", "$routeId"));
        groupFields.put("count", new BasicDBObject( "$sum", 1));
        groupFields.put("total", new BasicDBObject( "$first", "$totalServers"));
        groupFields.put("beginTime", new BasicDBObject( "$first", "$fireTimeSource"));
        groupFields.put("endTime", new BasicDBObject( "$last", "$fireTimeSource"));
        DBObject group = new BasicDBObject("$group", groupFields);
        // build the $sort operation
        DBObject sortFields =  new BasicDBObject( "_id", 1);
        DBObject sort = new BasicDBObject("$sort", sortFields );
    public void qps(String beginTime, String endTime) {
        DBObject match = getMatchFields(beginTime, endTime);
        DBObject group = getFlowGroupFields();
        DBObject sort = getSortFields();
        // run aggregation
        AggregationOutput output = businessLog.aggregate(match, group, sort);
        AggregationOutput output = getBusinessLog().aggregate(match, group, sort);
        Integer calls = 0;
        long interval = 0;
        String routeId = "";
        String breadcrumbId = "";
        for (DBObject dbObject : output.results()) {
            Integer count = Integer.parseInt(StringUtil.toString(dbObject.get("count")));
            BasicDBObject id = (BasicDBObject) dbObject.get("_id");
            routeId = StringUtil.toString(id.get("routeId"));
            breadcrumbId  = StringUtil.toString(id.get("breadcrumbId"));
            if (count >= 2) {
                Integer total = Integer.parseInt(StringUtil.toString(dbObject.get("total")));
                if (total == count) {
                    calls++;
                    String begin = StringUtil.toString(dbObject.get("beginTime"));
                    String end = StringUtil.toString(dbObject.get("endTime"));
                    Date from = DateUtil.toTimestamp(begin, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
                    Date to = DateUtil.toTimestamp(end, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
                    interval += (to.getTime() - from.getTime())/1000;
                }
            }
        }
        long interval = getInterval(beginTime, endTime);
        BigDecimal qps = NumberUtil.divideBigDecimal(BigDecimal.valueOf(calls), BigDecimal.valueOf(interval));
        ServiceMetrics serviceMetrics = new ServiceMetrics();
        serviceMetrics.setRouteId(routeId);
        serviceMetrics.setBreadcrumbId(breadcrumbId);
        serviceMetrics.setType("qps");
        serviceMetrics.setValue(qps.toString());
        serviceMetrics.setCreateTime(endTime);
        mongoOperations.save(serviceMetrics);
        JSONObject result = new JSONObject();
        result.put("qps", qps);
        return Result.success(result.toString());
        saveServiceMetrics(routeId, "qps", qps.toString(), endTime);
    }
    public Result usage(String beginTime, String endTime) {
        DBCollection businessLog = mongoOperations.getCollection(mongoOperations
                .getCollectionName(BusinessLog.class));
        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
                new BasicDBObject[]{
                        new BasicDBObject().append("fireTime",
                                new BasicDBObject().append(QueryOperators.GTE, DateUtil.toTimestamp(beginTime))),
                        new BasicDBObject().append("fireTime",
                                new BasicDBObject().append(QueryOperators.LT, DateUtil.toTimestamp(endTime)))});
        DBObject match = new BasicDBObject("$match", queryObject);
        // Now the $group operation
        DBObject groupFields = new BasicDBObject( "_id",
                new BasicDBObject("breadcrumbId", "$breadcrumbId")
                        .append("routeId", "$routeId"));
        groupFields.put("count", new BasicDBObject( "$sum", 1));
        groupFields.put("total", new BasicDBObject( "$first", "$totalServers"));
        DBObject group = new BasicDBObject("$group", groupFields);
        // build the $sort operation
        DBObject sortFields =  new BasicDBObject( "_id", 1);
        DBObject sort = new BasicDBObject("$sort", sortFields );
    public void usage(String beginTime, String endTime) throws JsonProcessingException {
        DBObject match = getMatchFields(beginTime, endTime);
        DBObject group = getFlowGroupFields();
        DBObject sort = getSortFields();
        // run aggregation
        AggregationOutput output = businessLog.aggregate(match, group, sort);
        AggregationOutput output = getBusinessLog().aggregate(match, group, sort);
        Integer successCount = 0;
        Integer failureCount = 0;
        String routeId = "";
        String breadcrumbId = "";
        for (DBObject dbObject : output.results()) {
            Integer total = Integer.parseInt(StringUtil.toString(dbObject.get("total")));
            Integer count = Integer.parseInt(StringUtil.toString(dbObject.get("count")));
            BasicDBObject id = (BasicDBObject) dbObject.get("_id");
            routeId = StringUtil.toString(id.get("routeId"));
            breadcrumbId  = StringUtil.toString(id.get("breadcrumbId"));
            if (total == count) {
                successCount++;
            } else {
                failureCount++;
                 failureCount++;
            }
        }
@ -252,22 +177,33 @@ public class ServiceMonitorService {
        result.put("totalCount", successCount + failureCount);
        result.put("successCount", successCount);
        result.put("failureCount", failureCount);
        ObjectMapper objectMapper = new ObjectMapper();
        saveServiceMetrics(routeId, "usage", objectMapper.writeValueAsString(result.toString()), endTime);
    }
        ServiceMetrics serviceMetrics = new ServiceMetrics();
        serviceMetrics.setRouteId(routeId);
        serviceMetrics.setBreadcrumbId(breadcrumbId);
        serviceMetrics.setType("usage");
        serviceMetrics.setValue(result.toString());
        serviceMetrics.setCreateTime(endTime);
        mongoOperations.save(serviceMetrics);
    public void delay(String beginTime, String endTime) {
        DBObject match = getMatchFields(beginTime, endTime);
        DBObject group = getFlowGroupFields();
        DBObject sort = getSortFields();
        // run aggregation
        AggregationOutput output = getBusinessLog().aggregate(match, group, sort);
        Integer calls = 0;
        String routeId = "";
        for (DBObject dbObject : output.results()) {
            Integer count = Integer.parseInt(StringUtil.toString(dbObject.get("count")));
            BasicDBObject id = (BasicDBObject) dbObject.get("_id");
            routeId = StringUtil.toString(id.get("routeId"));
            if (count >= 2) {
                calls++;
            }
        }
        return Result.success(result.toString());
        long interval = getInterval(beginTime, endTime);
        BigDecimal delay =  NumberUtil.divideBigDecimal(BigDecimal.valueOf(interval), BigDecimal.valueOf(calls));
        saveServiceMetrics(routeId, "delay", delay.toString(), endTime);
    }
    public Result delay(String beginTime, String endTime) {
        DBCollection businessLog = mongoOperations.getCollection(mongoOperations
                .getCollectionName(BusinessLog.class));
    public DBObject getMatchFields(String beginTime, String endTime) {
        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
                new BasicDBObject[]{
                        new BasicDBObject().append("fireTime",
@ -275,53 +211,49 @@ public class ServiceMonitorService {
                        new BasicDBObject().append("fireTime",
                                new BasicDBObject().append(QueryOperators.LT, DateUtil.toTimestamp(endTime)))});
        DBObject match = new BasicDBObject("$match", queryObject);
        return new BasicDBObject("$match", queryObject);
    }
    public DBObject getServiceGroupFields() {
        // Now the $group operation
        DBObject groupFields = new BasicDBObject( "_id",
                new BasicDBObject("id", "$_id")
                        .append("code", "$code"));
        groupFields.put("count", new BasicDBObject( "$sum", 1));
        groupFields.put("total", new BasicDBObject( "$first", "$totalServers"));
        return new BasicDBObject("$group", groupFields);
    }
    public DBObject getFlowGroupFields() {
        // Now the $group operation
        DBObject groupFields = new BasicDBObject( "_id",
                new BasicDBObject("breadcrumbId", "$breadcrumbId")
                        .append("routeId", "$routeId"));
        groupFields.put("count", new BasicDBObject( "$sum", 1));
        groupFields.put("beginTime", new BasicDBObject( "$first", "$fireTimeSource"));
        groupFields.put("endTime", new BasicDBObject( "$last", "$fireTimeSource"));
        DBObject group = new BasicDBObject("$group", groupFields);
        groupFields.put("total", new BasicDBObject( "$first", "$totalServers"));
        return new BasicDBObject("$group", groupFields);
    }
        // build the $sort operation
    public DBObject getSortFields() {
        DBObject sortFields =  new BasicDBObject( "_id", 1);
        DBObject sort = new BasicDBObject("$sort", sortFields );
        // run aggregation
        AggregationOutput output = businessLog.aggregate(match, group, sort);
        Integer calls = 0;
        long interval = 0;
        String routeId = "";
        String breadcrumbId = "";
        for (DBObject dbObject : output.results()) {
            Integer count = Integer.parseInt(StringUtil.toString(dbObject.get("count")));
            BasicDBObject id = (BasicDBObject) dbObject.get("_id");
            routeId = StringUtil.toString(id.get("routeId"));
            breadcrumbId  = StringUtil.toString(id.get("breadcrumbId"));
            if (count >= 2) {
                calls++;
                String begin = StringUtil.toString(dbObject.get("beginTime"));
                String end = StringUtil.toString(dbObject.get("endTime"));
                Date from = DateUtil.toTimestamp(begin, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
                Date to = DateUtil.toTimestamp(end, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
                interval += (to.getTime() - from.getTime())/1000;
            }
        }
        return new BasicDBObject("$sort", sortFields );
    }
        BigDecimal delay =  NumberUtil.divideBigDecimal(BigDecimal.valueOf(interval), BigDecimal.valueOf(calls));
        JSONObject result = new JSONObject();
        result.put("delay", delay);
    public long getInterval(String beginTime, String endTime) {
        Date from = DateUtil.toTimestamp(beginTime, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
        Date to = DateUtil.toTimestamp(endTime, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
        long interval = (to.getTime() - from.getTime())/1000;
        return interval;
    }
    public void saveServiceMetrics(String name, String type, String value, String createTime) {
        ServiceMetrics serviceMetrics = new ServiceMetrics();
        serviceMetrics.setRouteId(routeId);
        serviceMetrics.setBreadcrumbId(breadcrumbId);
        serviceMetrics.setType("delay");
        serviceMetrics.setValue(delay.toString());
        serviceMetrics.setCreateTime(endTime);
        serviceMetrics.setName(name);
        serviceMetrics.setType(type);
        serviceMetrics.setValue(value);
        serviceMetrics.setCreateTime(createTime);
        mongoOperations.save(serviceMetrics);
        return Result.success(result.toString());
    }
}

+ 3 - 3
hos-camel/src/main/java/qlc/route/QlcRouteBulider.java

@ -14,10 +14,10 @@ public class QlcRouteBulider extends RouteBuilder {
    public void configure() throws Exception {
        from("jetty:http4://192.168.131.101:8066/qlc").routeId("qlc")
                .process(new Processor1()).setHeader(Exchange.HTTP_METHOD, constant("POST"))
                .to("http4://192.168.131.101:8088/api/v1.0/qlc/queryUserInfo").log("servers: 3,name: queryUserInfo")
                .to("http4://192.168.131.101:8088/api/v1.0/qlc/queryUserInfo").log("servers: 3,code: queryUserInfo")
                .process(new Processor2()).setHeader(Exchange.HTTP_METHOD, constant("POST"))
                .to("http4://192.168.131.101:8088/api/v1.0/qlc/patientInformation").log("servers: 3,name: patientInformation")
                .to("http4://192.168.131.101:8088/api/v1.0/qlc/patientInformation").log("servers: 3,code: patientInformation")
                .process(new Processor2()).setHeader(Exchange.HTTP_METHOD, constant("POST"))
                .to("http4://192.168.131.101:8088/crawler/patient").log("servers: 3,name: patient").to("stream:out"); // 2. 为路由配置组件或终端节点.
                .to("http4://192.168.131.101:8088/crawler/patient").log("servers: 3,code: patient").to("stream:out"); // 2. 为路由配置组件或终端节点.
    }
}

+ 16 - 0
hos-web-framework-dependencies/pom.xml

@ -60,10 +60,26 @@
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-mongodb</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>log4j-over-slf4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>jcl-over-slf4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.mongodb</groupId>

+ 1 - 1
hos-web-framework/src/main/java/com/yihu/hos/web/framework/dao/SQLGeneralDAO.java

@ -374,7 +374,7 @@ public class SQLGeneralDAO implements XSQLGeneralDAO {
        return count1;
    }
    public Object get(Class tClass, String tableName, Integer id) {
    public Object get(Class tClass, String tableName, Object id) {
        SqlCreator sqlCreator = new SqlCreator(tClass);
        sqlCreator.equalCondition("id", id);
        String sql = sqlCreator.selectData(tableName);

+ 1 - 1
hos-web-framework/src/main/java/com/yihu/hos/web/framework/dao/XSQLGeneralDAO.java

@ -62,7 +62,7 @@ public interface XSQLGeneralDAO {
    <T> Integer getDataSetInt(Class<T> var1, String var2, String var3);
    <T> Object get(Class<T> var1, String var2, Integer var3);
    <T> Object get(Class<T> var1, String var2, Object var3);
    Session getCurrentSession();

+ 1 - 3
src/main/java/com/yihu/hos/common/SessionOutTimeFilter.java

@ -23,9 +23,7 @@ public class SessionOutTimeFilter extends OncePerRequestFilter {
        if (path.indexOf("/login") != -1
                || path.indexOf("/system/loginAction") != -1
                || path.indexOf("/error") != -1
                || path.indexOf("/datapush") != -1
                || path.indexOf("/crawler") != -1
                || path.indexOf("/patient") != -1
                || path.indexOf("/monitor") != -1
                || path.indexOf("/test.jsp") != -1
                || path.indexOf("/logoutAction") != -1
                || path.indexOf(httpServletRequest.getContextPath() + "/static-dev") != -1

+ 12 - 0
src/main/java/com/yihu/hos/monitor/controller/ServerMonitorController.java

@ -72,4 +72,16 @@ public class ServerMonitorController {
    }
    @RequestMapping(value = "/trees", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取服务器树列表", produces = "application/json", notes = "获取服务器树列表")
    public Result trees() {
        try {
            return monitorService.getServerTreeList();
        } catch (Exception e) {
            return Result.error("获取服务树列表失败");
        }
    }
}

+ 38 - 6
src/main/java/com/yihu/hos/monitor/controller/ServiceMonitorController.java

@ -1,5 +1,6 @@
package com.yihu.hos.monitor.controller;
import com.yihu.hos.core.datatype.DateUtil;
import com.yihu.hos.monitor.service.ServiceMonitorService;
import com.yihu.hos.web.framework.model.Result;
import io.swagger.annotations.ApiOperation;
@ -12,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.Date;
/**
 * @author HZY
@ -34,14 +36,44 @@ public class ServiceMonitorController {
    }
    @RequestMapping(value = "/server/metrics", method = RequestMethod.GET)
    @RequestMapping(value = "/metrics", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取服务指标", produces = "application/json", notes = "获取服务指标")
    public Result metrics(
            @ApiParam(name = "beginTime", value = "开始时间", required = true)
            @RequestParam(value = "beginTime") String beginTime,
            @ApiParam(name = "endTime", value = "结束时间", required = true)
            @RequestParam(value = "endTime") String endTime) {
        return monitorService.metrics(beginTime, endTime);
            @ApiParam(name = "id", value = "serviceID", required = true)
            @RequestParam(value = "id") String id) {
        Date now = new Date();
        Date beforeDate = new Date(now.getTime() - 3600000);
        String beginTime = DateUtil.toString(beforeDate, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
        String endTime = DateUtil.toString(now, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
        try {
            return monitorService.metrics(id, beginTime, endTime);
        } catch (Exception e) {
            return Result.error("获取服务指标失败");
        }
    }
    @RequestMapping(value = "/trees", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取服务树列表", produces = "application/json", notes = "获取服务树列表")
    public Result trees() {
        try {
            return monitorService.getServiceTreeList();
        } catch (Exception e) {
            return Result.error("获取服务树列表失败");
        }
    }
    @RequestMapping(value = "/info", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取服务树列表", produces = "application/json", notes = "获取服务树列表")
    public Result getServiceInfo(
            @ApiParam(name = "code", value = "服务器IP", required = true)
            @RequestParam(value = "host") String code) {
        try {
            return monitorService.getServiceTreeList();
        } catch (Exception e) {
            return Result.error("获取服务树列表失败");
        }
    }
}

+ 30 - 0
src/main/java/com/yihu/hos/monitor/dao/ServiceMonitorDao.java

@ -0,0 +1,30 @@
package com.yihu.hos.monitor.dao;
import com.yihu.hos.system.model.SystemServiceEndpoint;
import com.yihu.hos.system.model.SystemServiceFlow;
import com.yihu.hos.system.model.SystemServiceFlowConfig;
import com.yihu.hos.web.framework.dao.SQLGeneralDAO;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
 * Created by chenweida on 2016/1/25.
 */
@Repository("ServiceMonitorDao")
public class ServiceMonitorDao extends SQLGeneralDAO {
    public static final String BEAN_ID = "ServiceMonitorDao";
    public List<SystemServiceFlowConfig> getAllFlowEndpoints() throws Exception {
        return (List<SystemServiceFlowConfig>) super.hibernateTemplate.find("from SystemServiceFlowConfig");
    }
    public List<SystemServiceFlow> getAllFlows() throws Exception {
        return (List<SystemServiceFlow>) super.hibernateTemplate.find("from SystemServiceFlow");
    }
    public List<SystemServiceEndpoint> getAllEndpoints() throws Exception {
        return (List<SystemServiceEndpoint>) super.hibernateTemplate.find("from SystemServiceEndpoint");
    }
}

+ 17 - 0
src/main/java/com/yihu/hos/monitor/service/ServerMonitorService.java

@ -4,6 +4,7 @@ import com.mongodb.*;
import com.yihu.hos.core.datatype.DateUtil;
import com.yihu.hos.web.framework.model.ActionResult;
import com.yihu.hos.web.framework.model.Result;
import com.yihu.hos.web.framework.model.TreeView;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoOperations;
@ -100,4 +101,20 @@ public class ServerMonitorService {
        return actionResult;
    }
    public Result getServerTreeList() throws Exception {
        List<TreeView> treeList = new ArrayList<>();
        mongoOperations = new MongoTemplate(mongo, envHealth);
        Set<String> collections = mongoOperations.getCollectionNames();
        for (String host : collections) {
            TreeView rootTree = new TreeView();
            rootTree.setId("host" + host);
            rootTree.setPid("-1");
            rootTree.setText(host);
            treeList.add(rootTree);
        }
        JSONArray jsonArray = new JSONArray(treeList);
        return Result.success(jsonArray.toString());
    }
}

+ 86 - 173
src/main/java/com/yihu/hos/monitor/service/ServiceMonitorService.java

@ -1,12 +1,12 @@
package com.yihu.hos.monitor.service;
import com.mongodb.*;
import com.yihu.hos.core.datatype.DateUtil;
import com.yihu.hos.core.datatype.NumberUtil;
import com.yihu.hos.core.datatype.StringUtil;
import com.yihu.hos.monitor.model.BusinessLog;
import com.yihu.hos.web.framework.model.ActionResult;
import com.yihu.hos.monitor.dao.ServiceMonitorDao;
import com.yihu.hos.system.model.SystemServiceEndpoint;
import com.yihu.hos.system.model.SystemServiceFlow;
import com.yihu.hos.system.model.SystemServiceFlowConfig;
import com.yihu.hos.web.framework.model.Result;
import com.yihu.hos.web.framework.model.TreeView;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -14,8 +14,10 @@ import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Date;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2016/1/27.
@ -23,7 +25,8 @@ import java.util.Date;
@Service("ServiceMonitorService")
public class ServiceMonitorService {
    public static final String BEAN_ID = "ServiceMonitorService";
    public static final String envHealth = "envHealth";
    public static final String dbName = "log";
    public static final String tableName = "serviceMetrics";
    @Autowired
    private MongoOperations mongoOperations;
@ -31,6 +34,10 @@ public class ServiceMonitorService {
    @Autowired
    private Mongo mongo;
    @Autowired
    private ServiceMonitorDao serviceMonitorDao;
//    public Result mapReduce(String beginTime, String endTime) {
//        DBCollection businessLogDB = mongoOperations.getCollection(mongoOperations
//                .getCollectionName(BusinessLog.class));
@ -87,189 +94,95 @@ public class ServiceMonitorService {
//        return jsonObject;
//    }
    public Result metrics(String beginTime, String endTime) {
        JSONObject bandwidth = bandwidth(beginTime, endTime);
        JSONObject qps = qps(beginTime, endTime);
        JSONObject delay = delay(beginTime, endTime);
        JSONObject usage = usage(beginTime, endTime);
        JSONArray jsonArray = new JSONArray();
        jsonArray.put(bandwidth);
        jsonArray.put(qps);
        jsonArray.put(delay);
        jsonArray.put(usage);
        return Result.success(jsonArray.toString());
    }
    public JSONObject bandwidth(String beginTime, String endTime) {
        DBCollection businessLog = mongoOperations.getCollection(mongoOperations
                .getCollectionName(BusinessLog.class));
        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
                new BasicDBObject[]{
                        new BasicDBObject().append("fireTime",
                                new BasicDBObject().append(QueryOperators.GTE, DateUtil.toTimestamp(beginTime))),
                        new BasicDBObject().append("fireTime",
                                new BasicDBObject().append(QueryOperators.LT, DateUtil.toTimestamp(endTime)))});
        DBObject match = new BasicDBObject("$match", queryObject);
        // Now the $group operation
        DBObject groupFields = new BasicDBObject( "_id", "$breadcrumbId");
        groupFields.put("count", new BasicDBObject( "$sum", 1));
        groupFields.put("beginTime", new BasicDBObject( "$first", "$fireTimeSource"));
        groupFields.put("endTime", new BasicDBObject( "$last", "$fireTimeSource"));
        DBObject group = new BasicDBObject("$group", groupFields);
        // build the $sort operation
        DBObject sortFields =  new BasicDBObject( "_id", 1);
        DBObject sort = new BasicDBObject("$sort", sortFields );
        // run aggregation
        AggregationOutput output = businessLog.aggregate(match, group, sort);
        Integer calls = 0;
        long interval = 0;
        for (DBObject dbObject : output.results()) {
            Integer count = Integer.parseInt(StringUtil.toString(dbObject.get("count")));
            if (count >= 2) {
                calls++;
                String begin = StringUtil.toString(dbObject.get("beginTime"));
                String end = StringUtil.toString(dbObject.get("endTime"));
                Date from = DateUtil.toTimestamp(begin, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
                Date to = DateUtil.toTimestamp(end, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
                interval += (to.getTime() - from.getTime())/1000;
            }
    public Result metrics(String id, String beginTime, String endTime) throws Exception {
        String name;
        if (id.contains("flow")) {
            Integer flowId = Integer.parseInt(id.replace("flow", ""));
            SystemServiceFlow systemServiceFlow = (SystemServiceFlow) serviceMonitorDao.get(SystemServiceFlow.class, "system_service_flow", flowId);
            name = systemServiceFlow.getName();
        } else {
            String endpointId =id.replace("endpoint", "");
            SystemServiceEndpoint systemServiceEndpoint = (SystemServiceEndpoint) serviceMonitorDao.get(SystemServiceEndpoint.class, "system_service_endpoint", endpointId);
            name = systemServiceEndpoint.getName();
        }
        JSONObject result = new JSONObject();
        result.put("bandwidth", NumberUtil.divideBigDecimal(BigDecimal.valueOf(calls), BigDecimal.valueOf(interval)));
        return result;
    }
    public JSONObject qps(String beginTime, String endTime) {
        DBCollection businessLog = mongoOperations.getCollection(mongoOperations
                .getCollectionName(BusinessLog.class));
        mongoOperations = new MongoTemplate(mongo, dbName);
        DBCollection metrics = mongoOperations.getCollection(tableName);
        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
                new BasicDBObject[]{
                        new BasicDBObject().append("fireTime",
                                new BasicDBObject().append(QueryOperators.GTE, DateUtil.toTimestamp(beginTime))),
                        new BasicDBObject().append("fireTime",
                                new BasicDBObject().append(QueryOperators.LT, DateUtil.toTimestamp(endTime)))});
        DBObject match = new BasicDBObject("$match", queryObject);
                        new BasicDBObject().append("createTime",
                                new BasicDBObject().append(QueryOperators.GTE, beginTime)),
                        new BasicDBObject().append("createTime",
                                new BasicDBObject().append(QueryOperators.LT, endTime)),
                        new BasicDBObject("name", name)});
        // Now the $group operation
        DBObject groupFields = new BasicDBObject( "_id", "$breadcrumbId");
        groupFields.put("count", new BasicDBObject( "$sum", 1));
        groupFields.put("total", new BasicDBObject( "$first", "$totalServers"));
        groupFields.put("beginTime", new BasicDBObject( "$first", "$fireTimeSource"));
        groupFields.put("endTime", new BasicDBObject( "$last", "$fireTimeSource"));
        DBObject group = new BasicDBObject("$group", groupFields);
        JSONObject result = new JSONObject();
        DBCursor cursor = metrics.find(queryObject);
        JSONArray bandwidth = new JSONArray();
        JSONArray qps = new JSONArray();
        JSONArray usage = new JSONArray();
        JSONArray delay = new JSONArray();
        while(cursor.hasNext()) {
            DBObject dbObject = cursor.next();
            dbObject.removeField("_id");
            String type = dbObject.get("type").toString();
            switch (type) {
                case "bandwidth" : bandwidth.put(dbObject);break;
                case "qps" : qps.put(dbObject);break;
                case "usage" : usage.put(dbObject);break;
                case "delay" : delay.put(dbObject);break;
        // build the $sort operation
        DBObject sortFields =  new BasicDBObject( "_id", 1);
        DBObject sort = new BasicDBObject("$sort", sortFields );
        // run aggregation
        AggregationOutput output = businessLog.aggregate(match, group, sort);
        Integer calls = 0;
        long interval = 0;
        for (DBObject dbObject : output.results()) {
            Integer count = Integer.parseInt(StringUtil.toString(dbObject.get("count")));
            if (count >= 2) {
                Integer total = Integer.parseInt(StringUtil.toString(dbObject.get("total")));
                if (total == count) {
                    calls++;
                    String begin = StringUtil.toString(dbObject.get("beginTime"));
                    String end = StringUtil.toString(dbObject.get("endTime"));
                    Date from = DateUtil.toTimestamp(begin, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
                    Date to = DateUtil.toTimestamp(end, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
                    interval += (to.getTime() - from.getTime())/1000;
                }
            }
        }
        JSONObject result = new JSONObject();
        result.put("qps", NumberUtil.divideBigDecimal(BigDecimal.valueOf(calls), BigDecimal.valueOf(interval)));
        return result;
        result.put("bandwidth", bandwidth);
        result.put("qps", qps);
        result.put("usage", usage);
        result.put("delay", delay);
        return Result.success(result.toString());
    }
    public JSONObject usage(String beginTime, String endTime) {
        DBCollection businessLog = mongoOperations.getCollection(mongoOperations
                .getCollectionName(BusinessLog.class));
        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
                new BasicDBObject[]{
                        new BasicDBObject().append("fireTime",
                                new BasicDBObject().append(QueryOperators.GTE, DateUtil.toTimestamp(beginTime))),
                        new BasicDBObject().append("fireTime",
                                new BasicDBObject().append(QueryOperators.LT, DateUtil.toTimestamp(endTime)))});
        DBObject match = new BasicDBObject("$match", queryObject);
    public Result getServiceTreeList() throws Exception {
        List<TreeView> treeList = new ArrayList<>();
        // Now the $group operation
        DBObject groupFields = new BasicDBObject( "_id", "$breadcrumbId");
        groupFields.put("count", new BasicDBObject( "$sum", 1));
        groupFields.put("total", new BasicDBObject( "$first", "$totalServers"));
        DBObject group = new BasicDBObject("$group", groupFields);
        List<SystemServiceFlow> flowList = serviceMonitorDao.getAllFlows();
        List<SystemServiceFlowConfig> flowEndpointList = serviceMonitorDao.getAllFlowEndpoints();
        List<SystemServiceEndpoint> endpointList = serviceMonitorDao.getAllEndpoints();
        Map<Integer, List<String>> flowEndpointMap = new HashMap<>();
        Map<String, SystemServiceEndpoint> endpointMap = new HashMap<>();
        // build the $sort operation
        DBObject sortFields =  new BasicDBObject( "_id", 1);
        DBObject sort = new BasicDBObject("$sort", sortFields );
        // run aggregation
        AggregationOutput output = businessLog.aggregate(match, group, sort);
        Integer successCount = 0;
        Integer failureCount = 0;
        for (DBObject dbObject : output.results()) {
            Integer total = Integer.parseInt(StringUtil.toString(dbObject.get("total")));
            Integer count = Integer.parseInt(StringUtil.toString(dbObject.get("count")));
            if (total == count) {
                successCount++;
        for (SystemServiceFlowConfig systemServiceFlowConfig : flowEndpointList) {
            List<String> endpointIdList;
            if (flowEndpointMap.containsKey(systemServiceFlowConfig.getFlowId())) {
                endpointIdList = flowEndpointMap.get(systemServiceFlowConfig.getFlowId());
            } else {
                failureCount++;
                endpointIdList = new ArrayList<>();
            }
            endpointIdList.add(systemServiceFlowConfig.getEndpointId());
            flowEndpointMap.put(systemServiceFlowConfig.getFlowId(), endpointIdList);
        }
        JSONObject count = new JSONObject();
        count.put("totalCount", successCount + failureCount);
        count.put("successCount", successCount);
        count.put("failureCount", failureCount);
        JSONObject result = new JSONObject();
        result.put("usage", count);
        return result;
    }
    public JSONObject delay(String beginTime, String endTime) {
        DBCollection businessLog = mongoOperations.getCollection(mongoOperations
                .getCollectionName(BusinessLog.class));
        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
                new BasicDBObject[]{
                        new BasicDBObject().append("fireTime",
                                new BasicDBObject().append(QueryOperators.GTE, DateUtil.toTimestamp(beginTime))),
                        new BasicDBObject().append("fireTime",
                                new BasicDBObject().append(QueryOperators.LT, DateUtil.toTimestamp(endTime)))});
        DBObject match = new BasicDBObject("$match", queryObject);
        // Now the $group operation
        DBObject groupFields = new BasicDBObject( "_id", "$breadcrumbId");
        groupFields.put("count", new BasicDBObject( "$sum", 1));
        groupFields.put("beginTime", new BasicDBObject( "$first", "$fireTimeSource"));
        groupFields.put("endTime", new BasicDBObject( "$last", "$fireTimeSource"));
        DBObject group = new BasicDBObject("$group", groupFields);
        for (SystemServiceEndpoint endpoint : endpointList) {
            endpointMap.put(endpoint.getId(), endpoint);
        }
        // build the $sort operation
        DBObject sortFields =  new BasicDBObject( "_id", 1);
        DBObject sort = new BasicDBObject("$sort", sortFields );
        // run aggregation
        AggregationOutput output = businessLog.aggregate(match, group, sort);
        Integer calls = 0;
        long interval = 0;
        for (DBObject dbObject : output.results()) {
            Integer count = Integer.parseInt(StringUtil.toString(dbObject.get("count")));
            if (count >= 2) {
                calls++;
                String begin = StringUtil.toString(dbObject.get("beginTime"));
                String end = StringUtil.toString(dbObject.get("endTime"));
                Date from = DateUtil.toTimestamp(begin, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
                Date to = DateUtil.toTimestamp(end, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
                interval += (to.getTime() - from.getTime())/1000;
        for (SystemServiceFlow flow : flowList) {
            TreeView rootTree = new TreeView();
            rootTree.setId("flow" + flow.getId());
            rootTree.setPid("-1");
            rootTree.setText(flow.getName());
            treeList.add(rootTree);
            List<String> endpointIdList = flowEndpointMap.get(flow.getId());
            for (String endpointId : endpointIdList) {
                SystemServiceEndpoint endpoint = endpointMap.get(endpointId);
                TreeView childTree = new TreeView();
                childTree.setId("endpoint" + endpoint.getId());
                childTree.setPid(flow.getCode());
                childTree.setText(endpoint.getName());
                treeList.add(childTree);
            }
        }
        JSONObject result = new JSONObject();
        result.put("delay", NumberUtil.divideBigDecimal(BigDecimal.valueOf(interval), BigDecimal.valueOf(calls)));
        return result;
        JSONArray jsonArray = new JSONArray(treeList);
        return Result.success(jsonArray.toString());
    }
}

+ 9 - 0
src/main/java/com/yihu/hos/system/model/SystemServiceFlow.java

@ -14,6 +14,7 @@ public class SystemServiceFlow implements java.io.Serializable {
    private String name;
    private String path;//流程路径
    private String chart;//流程图路径
    private String description;
    private Integer valid;
    private String createDate;
@ -76,6 +77,14 @@ public class SystemServiceFlow implements java.io.Serializable {
        this.chart = chart;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public Integer getValid() {
        return valid;
    }

+ 37 - 0
src/main/java/com/yihu/hos/system/model/SystemServiceFlowConfig.java

@ -0,0 +1,37 @@
package com.yihu.hos.system.model;
/**
 *  系统管理-服务流程
 * @author HZY
 * @vsrsion 1.0
 * Created at 2016/8/19.
 */
public class SystemServiceFlowConfig implements java.io.Serializable {
    private Integer id;
    private Integer flowId;
    private String endpointId;
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public Integer getFlowId() {
        return flowId;
    }
    public void setFlowId(Integer flowId) {
        this.flowId = flowId;
    }
    public String getEndpointId() {
        return endpointId;
    }
    public void setEndpointId(String endpointId) {
        this.endpointId = endpointId;
    }
}

+ 5 - 0
src/main/resources/resource/SystemServiceFlow.hbm.xml

@ -29,6 +29,11 @@
                <comment>流程图路径</comment>
            </column>
        </property>
        <property name="description" type="java.lang.String">
            <column name="description" length="255">
                <comment>描述</comment>
            </column>
        </property>
        <property name="valid" type="java.lang.Integer">
            <column name="valid" length="50">
                <comment>状态</comment>

+ 23 - 0
src/main/resources/resource/SystemServiceFlowConfig.hbm.xml

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- 
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="com.yihu.hos.system.model.SystemServiceFlowConfig" table="system_service_flow_config">
        <id name="id" column="id">
            <generator class="increment"/>
        </id>
        <property name="flowId" type="java.lang.Integer">
            <column name="flow_id" length="11">
                <comment>流程ID</comment>
            </column>
        </property>
        <property name="endpointId" type="java.lang.String">
            <column name="endpoint_id" length="50" not-null="true">
                <comment>服务ID</comment>
            </column>
        </property>
    </class>
</hibernate-mapping>

+ 2 - 2
src/main/webapp/WEB-INF/ehr/jsp/monitor/server/sEnvManage.jsp

@ -23,8 +23,8 @@
    <!--左边 区域-->
    <div position="left"  style="margin-left:10px;margin-top:10px;">
        <input type="hidden" id="nowHost">
        <ul    style="margin-left:50px;margin-top:10px;font-size: 17px;">服务器列表</ul>
        <ul id="div_wrapper_left_ul_resourcetree" class="m-snav"  style="margin-left:50px;margin-top:40px;"></ul>
        <ul    style="margin-left:30px;margin-top:10px;font-size: 17px;">服务器列表</ul>
        <ul id="div_wrapper_left_ul_resourcetree" class="m-snav"  style="margin-left:20px;margin-top:40px;"></ul>
    </div>
    <div position="center" style="margin-left:10px;margin-top:10px;margin-right:10px;">
        <!-- ####### 查询条件部分 ####### -->

+ 46 - 44
src/main/webapp/WEB-INF/ehr/jsp/monitor/server/sEnvManageJs.jsp

@ -6,7 +6,7 @@
    var host ="";
    var myChart;
    $(function () {
        initTree();
        getServerTree();
        //l-layout-left
        //初始化layout
        $("#div_wrapper").ligerLayout({
@ -36,34 +36,6 @@
        getServerInfo(host,type,beginTime,endTime);
        getInfo(host,type,endTime);
        //左侧栏目点击事件
        $('#div_wrapper_left_ul_resourcetree').on("click","li",function(){
           $(this).addClass("active");
            $(this).siblings("li").removeClass("active");
            $(this).find("div").addClass("f-bold");
            $(this).siblings("li").find("div").removeClass("f-bold");
            var host = $(this).find("div").text();
            var beginTime = $("#repeatStartTime").ligerDateEditor("getValue");
            var endTime = $("#repeatEndTime").ligerDateEditor("getValue");
            if(beginTime=="" && $endTime=="")
            {
                $.ligerDialog.error("请选择起始结束时间!");
                return false;
            }
            if(beginTime > endTime)
            {
                $.ligerDialog.error("开始时间不能大于结束时间!");
                return false;
            }
            var type = $(".div-menu .active").attr("data-item");
            //获取服务器监控数据
            getServerInfo(host,type,beginTime,endTime);
            getInfo(host,type,endTime);
        });
        //搜索按钮事件
        $(".m-form-control").on("click","#btnSearch",function(){
@ -82,7 +54,6 @@
            }
            var type = $(".div-menu .active").attr("data-item");
            host = $("#div_wrapper_left_ul_resourcetree").find("li.active").find("div").text();
            //获取服务器监控数据
            getServerInfo(host,type,beginTime,endTime);
            getInfo(host,type,endTime);
@ -102,31 +73,58 @@
                myChart.clear();
                return false;
            }
            host = $("#div_wrapper_left_ul_resourcetree").find("li.active").find("div").text();
            getServerInfo(host,type,beginTime,endTime);
            getInfo(host,type,endTime);
        })
    });
    function initTree(){
    function getServerTree(){
        var serviceTree = $("#div_wrapper_left_ul_resourcetree");
        //初始化树
        var $resourceTree = $('#div_wrapper_left_ul_resourcetree');
        $.ajax({
            type: "GET",
            url: "${contextRoot}/monitor/server/hosts",
            url: "${contextRoot}/monitor/server/trees",
            async: false,
            success: function (msg) {
                // 初始化树形菜单
                var data = msg.data;
                if(data!=null && data.length>0){
                    for(var i=0;i<data.length;i++){
                        if(i==0){
                            $resourceTree.append( "<li class='active'><div class='f-bold' style='margin-top:10px;cursor:pointer;'>"+data[i].host+"</div></li>");
                        }else{
                            $resourceTree.append( "<li><div style='margin-top:10px;cursor:pointer;'>"+data[i].host+"</div></li>");
                var data = JSON.parse(msg.message);
                host = data[0].text;
                if (msg.successFlg) {
                    // 初始化树形菜单
                    serviceTree = serviceTree.ligerTree({
                        data: data,
                        idFieldName: 'id',
                        nodeWidth: 200,
                        parentIDFieldName: 'pid',
                        isExpand: false,
                        onClick: function (obj) {
                            //初始化图表
                            host = obj.data.text;
                            var beginTime = $("#repeatStartTime").ligerDateEditor("getValue");
                            var endTime = $("#repeatEndTime").ligerDateEditor("getValue");
                            if(beginTime=="" && $endTime=="")
                            {
                                $.ligerDialog.error("请选择起始结束时间!");
                                return false;
                            }
                            if(beginTime > endTime)
                            {
                                $.ligerDialog.error("开始时间不能大于结束时间!");
                                return false;
                            }
                            var type = $(".div-menu .active").attr("data-item");
                            //获取服务器监控数据
                            getServerInfo(host,type,beginTime,endTime);
                            getInfo(host,type,endTime);
                        },
                        onSuccess: function (data) {
                            alert(2222);
                            host = data[0].text;
                        }
                    }
                    host = data[0].host;
                    });
                }
            }
        });
@ -271,6 +269,7 @@
         }
         else{
            //TODO 清除数据处理
             myChart.clear();
         }
    },
        memory:function(re){
@ -336,6 +335,7 @@
            }
            else{
               //TODO 清除数据
                myChart.clear();
            }
        },
        files:function(re){
@ -413,6 +413,7 @@
            }
            else{
                //TODO 清除数据
                myChart.clear();
            }
        },
        net:function(re){
@ -484,6 +485,7 @@
            }
            else{
               //TODO 清除数据
                myChart.clear();
            }
        }
    }

+ 7 - 18
src/main/webapp/WEB-INF/ehr/jsp/monitor/service/sEnvManage.jsp

@ -23,38 +23,27 @@
<div id="div_wrapper">
    <!--左边 区域-->
    <div position="left"  style="margin-left:10px;margin-top:10px;">
        <div class="m-form-control" style="margin-bottom: 15px">
            <input type="text" id="div_wrapper_left_inp_search" placeholder="请输入服务器名"/>
        </div>
        <ul id="div_wrapper_left_ul_resourcetree" class="m-snav"></ul>
        <ul id="div_wrapper_left_ul_servicetree" class="m-snav"></ul>
    </div>
    <div position="center" style="margin-left:10px;margin-top:10px;margin-right:10px;">
        <!-- ####### 查询条件部分 ####### -->
        <div class="m-form-inline" data-role-form>
            <div class="m-form-group">
                <label style="width: 100px;">开始时间:</label>
                <div class="m-form-control">
                    <input id="repeatStartTime" type="text" />
                </div>
                <label style="width: 100px;">结束时间:</label>
                <div class="m-form-control">
                    <input id="repeatEndTime" type="text" />
                    <label id="serviceName">dddd</label>
                </div>
                <div class="m-form-control">
                    <div id="btnSearch" class="l-button">
                        <span>搜索</span>
                    </div>
                    <label id="serviceDescription">eeeee</label>
                </div>
            </div>
            <%-- echarts 数据--%>
            <div id="main1" style="width: 600px;height:400px;border: solid deepskyblue 1px;"></div>
            <div id="main1" style="width: 500px;margin-left:50px;height:250px;border: solid deepskyblue 1px;"></div>
            <%-- echarts 数据--%>
            <div id="main2" style="width: 600px;height:400px;border: solid deepskyblue 1px;"></div>
            <div id="main2" style="width: 500px;margin:-250px 0px 20px 550px;height:250px;border: solid deepskyblue 1px;"></div>
            <%-- echarts 数据--%>
            <div id="main3" style="width: 600px;height:400px;border: solid deepskyblue 1px;"></div>
            <div id="main3" style="width: 500px;margin-left:50px;height:250px;border: solid deepskyblue 1px;"></div>
            <%-- echarts 数据--%>
            <div id="main4" style="width: 600px;height:400px;border: solid deepskyblue 1px;"></div>
            <div id="main4" style="width: 500px;margin:-250px 0px 20px 550px;height:250px;border: solid deepskyblue 1px;"></div>
        </div>
    </div>
</div>

+ 97 - 85
src/main/webapp/WEB-INF/ehr/jsp/monitor/service/sEnvManageJs.jsp

@ -12,53 +12,57 @@
            isLeftCollapse: false,//左边区域初始化不可以隐藏
            allowLeftCollapse: false//左边区域不可以隐藏
        });
        debugger;
        //初始化树
        getServiceTree();
    });
        /*初始化时间控件-start*/
        $("#repeatStartTime").ligerDateEditor({
            width: 240,
            showTime: true
        });
        $("#repeatEndTime").ligerDateEditor({
            width: 240,
            showTime: true
        });
        /*初始化时间控件-end*/
        //初始化图表
        var beginTime = $("#repeatStartTime").ligerDateEditor("getValue");
        var endTime = $("#repeatEndTime").ligerDateEditor("getValue");
        getServiceInfo(beginTime,endTime);
        //搜索按钮事件
        $(".m-form-control").on("click","#btnSearch",function(){
            var beginTime = $("#repeatStartTime").ligerDateEditor("getValue");
            var endTime = $("#repeatEndTime").ligerDateEditor("getValue");
            if(beginTime=="" && $endTime=="")
            {
                $.ligerDialog.error("请选择起始结束时间!");
                return false;
    function getServiceTree(){
        var serviceTree = $("#div_wrapper_left_ul_servicetree");
        //初始化树
        $.ajax({
            type: "GET",
            url: "${contextRoot}/monitor/service/trees",
            success: function (msg) {
                debugger;
                if (msg.successFlg) {
                    // 初始化树形菜单
                    serviceTree = serviceTree.ligerTree({
                        data: JSON.parse(msg.message),
                        idFieldName: 'id',
                        nodeWidth: 200,
                        parentIDFieldName: 'pid',
                        isExpand: false,
                        onClick: function (obj) {
                            debugger;
                            //初始化图表
                             getServiceInfo(obj.id);
                        },
                        onSuccess: function (data) {
                            debugger;
                            getServiceInfo(data[0].id);
                        }
                    });
                }
            }
        });
    }
            //获取服务器监控数据
            getServiceInfo(beginTime,endTime);
        })
    });
    function getServiceInfo(beginTime,endTime){
    function getServiceInfo(id){
        $.ajax({
            type: "GET",
            url : "${contextRoot}/monitor/service/metrics",
            dataType : "json",
            data:{beginTime:beginTime,endTime:endTime},
            data:{id:id},
            cache:false,
            success :function(re){
                if(re.successFlg) {
                    //TODO 设置图表
                            service.bandwidth(re);
                            service.qps(re);
                            service.delay(re);
                            service.usage(re);
                    var message = JSON.parse(re.message);
                    service.bandwidth(message.bandwidth);
                    service.qps(message.qps);
                    service.delay(message.delay);
                    service.usage(message.usage);
                } else {
                    $.ligerDialog.error(re.message);
                }
@ -70,25 +74,23 @@
    }
    var service = {
        bandwidth:function(re){
             var me = this;
             var data = re.data;
        bandwidth:function(data){
            // 基于准备好的dom,初始化echarts实例
            var myChart = echarts.init(document.getElementById('main1'));
             if(data!=null && data.length>0)
             {
                 var x = [];
                 var y = [];
                 for(var i=0;i<data.length;i++)
                 {
                     var create_date = data[i].create_date.substring(11,16);
                     x.push(create_date);
                     y.push(data[i].data.totalPerc);
                     var createTime = data[i].createTime.substring(11,16);
                     x.push(createTime);
                     y.push(data[i].value);
                 }
                 // 基于准备好的dom,初始化echarts实例
                 var myChart = echarts.init(document.getElementById('main1'));
                 // 指定图表的配置项和数据
                 var option = {
                     title: {
                         text: ' CPU指标',
                         text: ' 带宽',
                         left: 'center'
                     },
                     tooltip: {
@ -96,7 +98,7 @@
                     },
                     legend: {
                         left: 'left',
                         data: ['总使用率']
                         data: ['使用率']
                     },
                     xAxis: {
                         type: 'category',
@ -116,7 +118,7 @@
                     },
                     series: [
                         {
                             name: '总使用率',
                             name: '使用率',
                             type: 'line',
                             data: y
                         },
@ -124,29 +126,27 @@
                 };
             myChart.setOption(option);
             //设置图例下方的信息
             } else {
                 me.clearTop();
             } else{
                 myChart.clear();
             }
        },
        qps:function(re){
            var me = this;
            var data = re.data;
        qps:function(data){
            // 基于准备好的dom,初始化echarts实例
            var myChart = echarts.init(document.getElementById('main2'));
            if(data!=null && data.length>0)
            {
                var x = [];
                var y = [];
                for(var i=0;i<data.length;i++)
                {
                    var create_date = data[i].create_date.substring(11,16);
                    x.push(create_date);
                    y.push(data[i].data.usedPerc);
                    var createTime = data[i].createTime.substring(11,16);
                    x.push(createTime);
                    y.push(data[i].value);
                }
                // 基于准备好的dom,初始化echarts实例
                var myChart = echarts.init(document.getElementById('main2'));
                // 指定图表的配置项和数据
                var option = {
                    title: {
                        text: ' 内存使用率指标',
                        text: ' 吞吐量',
                        left: 'center'
                    },
                    tooltip: {
@ -183,28 +183,26 @@
                myChart.setOption(option);
            }
            else{
                me.clearTop();
                myChart.clear();
            }
        },
        delay:function(re){
            var me = this;
            var data = re.data;
        delay:function(data){
            // 基于准备好的dom,初始化echarts实例
            var myChart = echarts.init(document.getElementById('main3'));
            if(data!=null && data.length>0)
            {
                var x = [];
                var y = [];
                for(var i=0;i<data.length;i++)
                {
                    var create_date = data[i].create_date.substring(11,16);
                    x.push(create_date);
                    y.push(data[i].total);
                    var createTime = data[i].createTime.substring(11,16);
                    x.push(createTime);
                    y.push(data[i].value);
                }
                // 基于准备好的dom,初始化echarts实例
                var myChart = echarts.init(document.getElementById('main3'));
                // 指定图表的配置项和数据
                var option = {
                    title: {
                        text: ' 磁盘指标',
                        text: ' 延时',
                        left: 'center'
                    },
                    tooltip: {
@ -241,28 +239,32 @@
                myChart.setOption(option);
            }
            else{
                me.clearTop();
                myChart.clear();
            }
        },
        usage:function(re){
            var me = this;
            var data = re.data;
        usage:function(data){
            // 基于准备好的dom,初始化echarts实例
            var myChart = echarts.init(document.getElementById('main4'));
            if(data!=null && data.length>0)
            {
                var x = [];
                var y = [];
                var y1 = [];
                var y2 = [];
                var y3 = [];
                for(var i=0;i<data.length;i++)
                {
                    var create_date = data[i].create_date.substring(11,16);
                    x.push(create_date);
                    y.push(data[i].data.rxbps);
                    var createTime = data[i].createTime.substring(11,16);
                    x.push(createTime);
                    var count = JSON.parse(JSON.parse(data[i].value));
                    y1.push(count.totalCount);
                    y2.push(count.successCount);
                    y3.push(count.failureCount);
                }
                // 基于准备好的dom,初始化echarts实例
                var myChart = echarts.init(document.getElementById('main4'));
                // 指定图表的配置项和数据
                var option = {
                    title: {
                        text: ' 网络指标',
                        text: ' 使用率',
                        left: 'center'
                    },
                    tooltip: {
@ -270,7 +272,7 @@
                    },
                    legend: {
                        left: 'left',
                        data: ['接收']
                        data: ['总使用数', '成功数', '失败数']
                    },
                        xAxis: {
                        type: 'category',
@ -286,23 +288,33 @@
                    },
                    yAxis: {
                        type: 'log',
                        name: '使用率(kbps)'
                        name: '使用数'
                    },
                    series: [
                        {
                            name: '接收',
                            name: '总使用数',
                            type: 'line',
                            data: y
                            data: y1
                        },
                        {
                            name: '成功数',
                            type: 'line',
                            data: y2
                        },
                        {
                            name: '失败数',
                            type: 'line',
                            data: y3
                        }
                    ]
                };
                myChart.setOption(option);
            }
            else{
                me.clearTop();
                myChart.clear();
            }
        }
    }
    };
    /*当前时间*/