Kaynağa Gözat

计算服务指标

zhenglingfeng 8 yıl önce
ebeveyn
işleme
4c138b2651

+ 2 - 0
hos-broker/src/main/java/com/yihu/hos/common/appender/JMSAppender.java

@ -321,6 +321,7 @@ public class JMSAppender extends AppenderSkeleton {
        String body = message.substring(message.indexOf("Body:") + 5);
        String totalServers = message.substring(message.indexOf("log[servers:") + 13, message.indexOf(","));
        String code = message.substring(message.indexOf("code") + 6, message.indexOf("]"));
        String order = message.substring(message.indexOf("order") + 7, message.length());
        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,6 +331,7 @@ public class JMSAppender extends AppenderSkeleton {
        map.put("camelContextId", StringUtil.toString(event.getMDC("camel.contextId")));
        map.put("totalServers", Integer.parseInt(totalServers));
        map.put("code", code);
        map.put("order", order);
        map.put("body", body);
        map.put("fireTimeSource", DateUtil.toStringFormatGMTTime(DateUtil.toGMTTime(event.getTimeStamp()), DateUtil.DEFAULT_TIMESTAMP_FORMAT));
        msg.setObject(JSONObject.fromObject(map).toString());

+ 22 - 4
hos-broker/src/main/java/com/yihu/hos/common/dao/BrokerDao.java

@ -1,5 +1,6 @@
package com.yihu.hos.common.dao;
import com.yihu.hos.models.SystemServiceEndpoint;
import com.yihu.hos.models.SystemServiceFlow;
import com.yihu.hos.models.SystemServiceFlowClass;
import org.springframework.beans.factory.annotation.Autowired;
@ -16,17 +17,17 @@ public class BrokerDao {
    private JdbcTemplate jdbcTemplate;
    public List<SystemServiceFlow> getSystemServiceFlowList() throws Exception {
        List<SystemServiceFlow> systemServiceFlowList = new ArrayList<SystemServiceFlow>();;
        List<SystemServiceFlow> systemServiceFlowList = new ArrayList<>();;
        String sql = "select * from system_service_flow";
        List list = jdbcTemplate.queryForList(sql);
        Iterator iterator = list.iterator();
        SystemServiceFlow systemServiceFlow = null;
        while (iterator.hasNext()) {
            Map map = (Map) iterator.next();
            systemServiceFlow = new SystemServiceFlow();
            SystemServiceFlow systemServiceFlow = new SystemServiceFlow();
            systemServiceFlow.setId((Integer) map.get("id"));
            systemServiceFlow.setCode((String) map.get("code"));
            systemServiceFlow.setName((String) map.get("name"));
            systemServiceFlow.setDescription((String) map.get("description"));
            systemServiceFlow.setPath((String) map.get("path"));
            systemServiceFlow.setChart((String) map.get("chart"));
            systemServiceFlow.setValid((Integer) map.get("valid"));
@ -37,8 +38,25 @@ public class BrokerDao {
        return systemServiceFlowList;
    }
    public List<SystemServiceEndpoint> getSystemServiceEndpointList() throws Exception {
        List<SystemServiceEndpoint> systemServieEndpointList = new ArrayList<>();;
        String sql = "select * from system_service_endpoint";
        List list = jdbcTemplate.queryForList(sql);
        Iterator iterator = list.iterator();
        while (iterator.hasNext()) {
            Map map = (Map) iterator.next();
            SystemServiceEndpoint systemServiceEndpoint = new SystemServiceEndpoint();
            systemServiceEndpoint.setId((String) map.get("id"));
            systemServiceEndpoint.setCode((String) map.get("code"));
            systemServiceEndpoint.setName((String) map.get("name"));
            systemServieEndpointList.add(systemServiceEndpoint);
        }
        return systemServieEndpointList;
    }
    public List<SystemServiceFlowClass> getSystemServiceFlowClassList() throws Exception {
        List<SystemServiceFlowClass> systemServiceFlowClassList = new ArrayList<SystemServiceFlowClass>();;
        List<SystemServiceFlowClass> systemServiceFlowClassList = new ArrayList<>();;
        String sql = "select * from system_service_flow_class";
        List list = jdbcTemplate.queryForList(sql);
        Iterator iterator = list.iterator();

+ 31 - 16
hos-broker/src/main/java/com/yihu/hos/common/listener/ApplicationStartListener.java

@ -62,14 +62,14 @@ public class ApplicationStartListener implements ApplicationListener<ContextRefr
        List<File> systemClassFlowPaths = new ArrayList<>();
        List<RouteBuilder> alreadyRouteBuilders = new ArrayList<>();
        Map<String, Boolean> isCorrectClassMap = new HashMap<>();
        for (SystemServiceFlow systemServiceFlow : systemServiceFlowList) {
            Integer flowId = systemServiceFlow.getId();
            String code = systemServiceFlow.getCode();
            //默认所有class均为正确
            isCorrectClassMap.put(code, true);
            // 这是system业务系统在本地存储class的根目录
            File systemClassFlowPath = new File(ClassLoader.getSystemResource("").getPath() + "/" + code);
            if (!systemClassFlowPaths.contains(systemClassFlowPath)) {
                systemClassFlowPaths.add(systemClassFlowPath);
            }
            List<SystemServiceFlowClass> processesClassList = systemServiceFlowClassGroupMap.get("processor" + flowId);
            List<SystemServiceFlowClass> routesClassList = systemServiceFlowClassGroupMap.get("route" + flowId);
@ -80,9 +80,13 @@ public class ApplicationStartListener implements ApplicationListener<ContextRefr
                    String packageName = processesClass.getPackageName();
                    String classPath = processesClass.getClassPath();
                    // 创建文件
                    ClassFileUtil.createClassfile(systemClassFlowPath.toURI().toURL(), packageName, className, classPath);
                    Boolean flag = ClassFileUtil.createClassfile(systemClassFlowPath.toURI().toURL(), packageName, className, classPath);
                    // 记录到工具类中,以便其它线程需要时进行取用
                    SystemClassMapping.getSystemClassNameMapping().put(code + BrokerConstant.PROCESSOR, code + CoreConstant.DOT + packageName + CoreConstant.DOT + className);
                    if (flag) {
                        SystemClassMapping.getSystemClassNameMapping().put(code + BrokerConstant.PROCESSOR, code + CoreConstant.DOT + packageName + CoreConstant.DOT + className);
                    } else {
                        isCorrectClassMap.put(code, flag);
                    }
                }
            }
            if (!CollectionUtil.isEmpty(routesClassList)) {
@ -92,22 +96,33 @@ public class ApplicationStartListener implements ApplicationListener<ContextRefr
                    String packageName = routesClass.getPackageName();
                    String classPath = routesClass.getClassPath();
                    // 创建文件
                    ClassFileUtil.createClassfile(systemClassFlowPath.toURI().toURL(), packageName, className, classPath);
                    Boolean flag =ClassFileUtil.createClassfile(systemClassFlowPath.toURI().toURL(), packageName, className, classPath);
                    // 记录到工具类中,以便其它线程需要时进行取用
                    SystemClassMapping.getSystemClassNameMapping().put(code + BrokerConstant.ROUTE, code + CoreConstant.DOT + packageName + CoreConstant.DOT + className);
                    ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
                    try {
                        Class<RouteBuilder> routeBuilderClass = (Class<RouteBuilder>) currentClassLoader.loadClass(SystemClassMapping.getSystemClassNameMapping().get(code + BrokerConstant.ROUTE));
                        if (routeBuilderClass != null) {
                            RouteBuilder routeBuilder = routeBuilderClass.newInstance();
                            alreadyRouteBuilders.add(routeBuilder);
                    if (flag) {
                        SystemClassMapping.getSystemClassNameMapping().put(code + BrokerConstant.ROUTE, code + CoreConstant.DOT + packageName + CoreConstant.DOT + className);
                    } else {
                        isCorrectClassMap.put(code, flag);
                    }
                    if (isCorrectClassMap.get(code)) {
                        ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
                        try {
                            Class<RouteBuilder> routeBuilderClass = (Class<RouteBuilder>) currentClassLoader.loadClass(SystemClassMapping.getSystemClassNameMapping().get(code + BrokerConstant.ROUTE));
                            if (routeBuilderClass != null) {
                                RouteBuilder routeBuilder = routeBuilderClass.newInstance();
                                alreadyRouteBuilders.add(routeBuilder);
                            }
                        } catch (Exception e) {
                            logger.info("缺少class文件:" + code);
                            continue;
                        }
                    } catch (Exception e) {
                        logger.info("缺少class文件:" + code);
                        continue;
                    }
                }
            }
            if (isCorrectClassMap.get(code)) {
                if (!systemClassFlowPaths.contains(systemClassFlowPath)) {
                    systemClassFlowPaths.add(systemClassFlowPath);
                }
            }
        }
        // 4、=============
        // 首先启动Apache Camel服务

+ 24 - 8
hos-broker/src/main/java/com/yihu/hos/common/scheduler/MonitorScheduler.java

@ -1,20 +1,24 @@
package com.yihu.hos.common.scheduler;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.yihu.hos.common.constants.MonitorConstant;
import com.yihu.hos.common.dao.BrokerDao;
import com.yihu.hos.common.util.MongodbUtil;
import com.yihu.hos.common.util.SigarUtil;
import com.yihu.hos.core.datatype.DateUtil;
import com.yihu.hos.core.log.Logger;
import com.yihu.hos.core.log.LoggerFactory;
import com.yihu.hos.models.SystemServiceEndpoint;
import com.yihu.hos.models.SystemServiceFlow;
import com.yihu.hos.services.ServiceMonitorService;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.bson.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -31,7 +35,8 @@ public class MonitorScheduler {
    private static String host = SigarUtil.getHost();
    @Resource(name = ServiceMonitorService.BEAN_ID)
    private ServiceMonitorService serviceMonitorService;
    @Autowired
    private BrokerDao brokerDao;
    @Scheduled(cron="0 0/1 * * * ?") //每分钟执行一次
    public void statusCheck() {
        System.out.println("每分钟执行一次。开始============================================");
@ -39,7 +44,7 @@ public class MonitorScheduler {
//        collectEnvHealth();
        try {
            collectServiceHealth();
        } catch (JsonProcessingException e) {
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("每分钟执行一次。结束。");
@ -83,15 +88,26 @@ public class MonitorScheduler {
        return "";
    }
    public void collectServiceHealth() throws JsonProcessingException {
    public void collectServiceHealth() throws Exception {
        Date now = new Date();
        Date beforeDate = new Date(now.getTime() - 60000);
        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);
        List<SystemServiceFlow> flowList = brokerDao.getSystemServiceFlowList();
        List<SystemServiceEndpoint> endpointList = brokerDao.getSystemServiceEndpointList();
        List<String> codeList = new ArrayList<>();
        for (SystemServiceFlow systemServiceFlow : flowList) {
            codeList.add(systemServiceFlow.getCode());
        }
        for (SystemServiceEndpoint systemServiceEndpoint : endpointList) {
            codeList.add(systemServiceEndpoint.getCode());
        }
        serviceMonitorService.bandwidth(beginTime, endTime, codeList);
        serviceMonitorService.qps(beginTime, endTime, codeList);
        serviceMonitorService.delay(beginTime, endTime, codeList);
        serviceMonitorService.usage(beginTime, endTime, codeList);
    }
//    @Scheduled(fixedRate=10000)

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

@ -21,6 +21,7 @@ public class BusinessLog {
    private String routeId;
    @Indexed
    private String breadcrumbId;
    private String order;
    private Integer totalServers;
    private String code;
    private String camelContextId;
@ -135,4 +136,12 @@ public class BusinessLog {
    public void setCode(String code) {
        this.code = code;
    }
    public String getOrder() {
        return order;
    }
    public void setOrder(String order) {
        this.order = order;
    }
}

+ 187 - 0
hos-broker/src/main/java/com/yihu/hos/models/SystemServiceEndpoint.java

@ -0,0 +1,187 @@
package com.yihu.hos.models;
/**
 *
 * @author HZY
 * @vsrsion 1.0
 * Created at 2016/8/16.
 */
public class SystemServiceEndpoint implements java.io.Serializable {
    private String id;
    private String code;
    private String name;
    private String appId;
    private String version;
    private String description;
    private String endpoint;
    private String requestProtocol;
    private String requestParameterList;
    private String requesModule;
    private String requestMethod;
    private String responeResult;
    private String responeError;
    private Integer healthReportType;
    private String healthEndpoint;
    private Integer metricsReportType;
    private String metricsEndpoint;
    private Integer valid;
    private String requestFormat;
    public SystemServiceEndpoint() {
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getVersion() {
        return version;
    }
    public void setVersion(String version) {
        this.version = version;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public String getEndpoint() {
        return endpoint;
    }
    public void setEndpoint(String endpoint) {
        this.endpoint = endpoint;
    }
    public String getRequestProtocol() {
        return requestProtocol;
    }
    public void setRequestProtocol(String requestProtocol) {
        this.requestProtocol = requestProtocol;
    }
    public String getRequestParameterList() {
        return requestParameterList;
    }
    public void setRequestParameterList(String requestParameterList) {
        this.requestParameterList = requestParameterList;
    }
    public String getRequesModule() {
        return requesModule;
    }
    public void setRequesModule(String requesModule) {
        this.requesModule = requesModule;
    }
    public String getRequestMethod() {
        return requestMethod;
    }
    public void setRequestMethod(String requestMethod) {
        this.requestMethod = requestMethod;
    }
    public String getResponeResult() {
        return responeResult;
    }
    public void setResponeResult(String responeResult) {
        this.responeResult = responeResult;
    }
    public String getResponeError() {
        return responeError;
    }
    public void setResponeError(String responeError) {
        this.responeError = responeError;
    }
    public Integer getHealthReportType() {
        return healthReportType;
    }
    public void setHealthReportType(Integer healthReportType) {
        this.healthReportType = healthReportType;
    }
    public String getHealthEndpoint() {
        return healthEndpoint;
    }
    public void setHealthEndpoint(String healthEndpoint) {
        this.healthEndpoint = healthEndpoint;
    }
    public Integer getMetricsReportType() {
        return metricsReportType;
    }
    public void setMetricsReportType(Integer metricsReportType) {
        this.metricsReportType = metricsReportType;
    }
    public String getMetricsEndpoint() {
        return metricsEndpoint;
    }
    public void setMetricsEndpoint(String metricsEndpoint) {
        this.metricsEndpoint = metricsEndpoint;
    }
    public Integer getValid() {
        return valid;
    }
    public void setValid(Integer valid) {
        this.valid = valid;
    }
    public String getRequestFormat() {
        return requestFormat;
    }
    public void setRequestFormat(String requestFormat) {
        this.requestFormat = requestFormat;
    }
    public String getAppId() {
        return appId;
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
}

+ 41 - 9
hos-broker/src/main/java/com/yihu/hos/models/SystemServiceFlow.java

@ -1,18 +1,42 @@
package com.yihu.hos.models;
import java.util.Date;
import java.util.List;
/**
 * Created by lingfeng on 2016/8/8.
 *  系统管理-服务流程
 * @author HZY
 * @vsrsion 1.0
 * Created at 2016/8/19.
 */
public class SystemServiceFlow {
    Integer id;
    String code;
    String name;
    String path;
    String chart;
    Integer valid;
    Date createDate;
public class SystemServiceFlow implements java.io.Serializable {
    private Integer id;
    private String code;
    private String name;
    private String path;//流程路径
    private String chart;//流程图路径
    private String description;
    private Integer valid;
    private Date createDate;
    private String flowClassList;
    private List<SystemServiceFlowClass> flowClassArray;
    public String getFlowClassList() {
        return flowClassList;
    }
    public void setFlowClassList(String flowClassList) {
        this.flowClassList = flowClassList;
    }
    public List<SystemServiceFlowClass> getFlowClassArray() {
        return flowClassArray;
    }
    public void setFlowClassArray(List<SystemServiceFlowClass> flowClassArray) {
        this.flowClassArray = flowClassArray;
    }
    public Integer getId() {
        return id;
@ -54,6 +78,14 @@ public class SystemServiceFlow {
        this.chart = chart;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public Integer getValid() {
        return valid;
    }

+ 22 - 8
hos-broker/src/main/java/com/yihu/hos/models/SystemServiceFlowClass.java

@ -1,15 +1,29 @@
package com.yihu.hos.models;
/**
 * Created by lingfeng on 2016/8/8.
 *  系统服务流程class
 * @author HZY
 * @vsrsion 1.0
 * Created at 2016/8/19.
 */
public class SystemServiceFlowClass {
    Integer id;
    String className;
    String packageName;
    String classPath;
    Integer flowId;
    String type;
public class SystemServiceFlowClass implements java.io.Serializable {
    private Integer id;
    private String className;
    private String packageName;
    private String classPath;
    private Integer flowId;
    private String type;
    //标识 是否有做文件上传
    private String isUpdate;
    public String getIsUpdate() {
        return isUpdate;
    }
    public void setIsUpdate(String isUpdate) {
        this.isUpdate = isUpdate;
    }
    public Integer getId() {
        return id;

+ 141 - 87
hos-broker/src/main/java/com/yihu/hos/services/ServiceMonitorService.java

@ -24,6 +24,7 @@ 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
@ -89,7 +90,7 @@ public class ServiceMonitorService {
        return businessLog;
    }
    public void bandwidth(String beginTime, String endTime) {
    public void bandwidth(String beginTime, String endTime, List<String> codeList) {
        DBObject match = getMatchFields(beginTime, endTime);
        DBObject flowGroup = getFlowGroupFields();
@ -98,43 +99,51 @@ public class ServiceMonitorService {
        // run aggregation
        AggregationOutput flowOutput = getBusinessLog().aggregate(match, flowGroup, sort);
       //流程带宽
        Integer flowCalls = 0;
        String routeId = "";
        Map<String, Integer> bandwidthMapF = new HashMap<>();
        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"));
            String code = StringUtil.toString(id.get("routeId"));
            if (count >= 2) {
                flowCalls++;
                if (bandwidthMapF.containsKey(code)) {
                    Integer flowCalls = bandwidthMapF.get(code);
                    bandwidthMapF.put(code, ++flowCalls);
                } else {
                    bandwidthMapF.put(code, 1);
                }
            }
        }
        long interval = getInterval(beginTime, endTime);
        BigDecimal flowBandwidth = NumberUtil.divideBigDecimal(BigDecimal.valueOf(flowCalls), BigDecimal.valueOf(interval));
        saveServiceMetrics(routeId, "bandwidth", flowBandwidth.toString(), endTime);
        //服务带宽
       //服务带宽
        // run aggregation
        AggregationOutput serviceOutput = getBusinessLog().aggregate(match, serviceGroup, sort);
        Map<String, Integer> bandwidthMap = new HashMap<>();
        Map<String, Integer> bandwidthMapS = new HashMap<>();
        for (DBObject dbObject : serviceOutput.results()) {
            BasicDBObject id = (BasicDBObject) dbObject.get("_id");
            String code = StringUtil.toString(id.get("code"));
            if (bandwidthMap.containsKey(code)) {
                Integer serviceCalls = bandwidthMap.get(code);
                bandwidthMap.put(code, ++serviceCalls);
            if (bandwidthMapS.containsKey(code)) {
                Integer serviceCalls = bandwidthMapS.get(code);
                bandwidthMapS.put(code, ++serviceCalls);
            } else {
                bandwidthMap.put(code, 1);
                bandwidthMapS.put(code, 1);
            }
        }
        for (String code : bandwidthMap.keySet()) {
            Integer serviceCalls = bandwidthMap.get(code)/2;
            BigDecimal serviceBandwidth = NumberUtil.divideBigDecimal(BigDecimal.valueOf(serviceCalls), BigDecimal.valueOf(interval));
            saveServiceMetrics(code, "bandwidth", serviceBandwidth.toString(), endTime);
        for (String code : codeList) {
            BigDecimal bandwidth = BigDecimal.ZERO;
            long interval = getInterval(beginTime, endTime);
            if (!StringUtil.isEmpty(bandwidthMapF.get(code))) {
                Integer flowCalls = bandwidthMapF.get(code);
                bandwidth = NumberUtil.divideBigDecimal(BigDecimal.valueOf(flowCalls), BigDecimal.valueOf(interval));
            } else if (!StringUtil.isEmpty(bandwidthMapS.get(code))) {
                Integer serviceCalls = bandwidthMapS.get(code)/2;
                bandwidth = NumberUtil.divideBigDecimal(BigDecimal.valueOf(serviceCalls), BigDecimal.valueOf(interval));
            }
            saveServiceMetrics(code, "bandwidth", bandwidth.toString(), endTime);
        }
    }
    public void qps(String beginTime, String endTime) {
    public void qps(String beginTime, String endTime, List<String> codeList) {
        DBObject match = getMatchFields(beginTime, endTime);
        DBObject flowGroup = getFlowGroupFields();
        DBObject sort = getSortFields();
@ -142,137 +151,169 @@ public class ServiceMonitorService {
        // run aggregation
        AggregationOutput flowOutput = getBusinessLog().aggregate(match, flowGroup, sort);
        //流程qps
        Integer flowCalls = 0;
        String routeId = "";
        Map<String, Integer> qpsMapF = new HashMap<>();
        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"));
            String code = StringUtil.toString(id.get("routeId"));
            if (count >= 2) {
                Integer total = Integer.parseInt(StringUtil.toString(dbObject.get("total")));
                if (total == count/2) {
                    flowCalls++;
                    if (qpsMapF.containsKey(code)) {
                        Integer flowCalls = qpsMapF.get(code);
                        qpsMapF.put(code, ++flowCalls);
                    } else {
                        qpsMapF.put(code, 1);
                    }
                }
            }
        }
        long interval = getInterval(beginTime, endTime);
        BigDecimal flowQps = NumberUtil.divideBigDecimal(BigDecimal.valueOf(flowCalls), BigDecimal.valueOf(interval));
        saveServiceMetrics(routeId, "qps", flowQps.toString(), endTime);
        //服务带宽
        // run aggregation
        AggregationOutput serviceOutput = getBusinessLog().aggregate(match, serviceGroup, sort);
        Map<String, Integer> qpsMap = new HashMap<>();
        Map<String, Integer> qpsMapS = new HashMap<>();
        for (DBObject dbObject : serviceOutput.results()) {
            BasicDBObject id = (BasicDBObject) dbObject.get("_id");
            String code = StringUtil.toString(id.get("code"));
            if (qpsMap.containsKey(code)) {
                Integer serviceCalls = qpsMap.get(code);
                qpsMap.put(code, ++serviceCalls);
            if (qpsMapS.containsKey(code)) {
                Integer serviceCalls = qpsMapS.get(code);
                qpsMapS.put(code, ++serviceCalls);
            } else {
                qpsMap.put(code, 1);
                qpsMapS.put(code, 1);
            }
        }
        for (String code : qpsMap.keySet()) {
            if (qpsMap.get(code) > 1) {
                Integer serviceCalls = qpsMap.get(code)/2;
                BigDecimal serviceBandwidth = NumberUtil.divideBigDecimal(BigDecimal.valueOf(serviceCalls), BigDecimal.valueOf(interval));
                saveServiceMetrics(code, "qps", serviceBandwidth.toString(), endTime);
        for (String code : codeList) {
            BigDecimal qps = BigDecimal.ZERO;
            long interval = getInterval(beginTime, endTime);
            if (!StringUtil.isEmpty(qpsMapF.get(code))) {
                Integer flowCalls = qpsMapF.get(code);
                qps = NumberUtil.divideBigDecimal(BigDecimal.valueOf(flowCalls), BigDecimal.valueOf(interval));
            } else if (!StringUtil.isEmpty(qpsMapS.get(code))) {
                Integer serviceCalls = qpsMapS.get(code)/2;
                qps = NumberUtil.divideBigDecimal(BigDecimal.valueOf(serviceCalls), BigDecimal.valueOf(interval));
            }
            saveServiceMetrics(code, "qps", qps.toString(), endTime);
        }
    }
    public void usage(String beginTime, String endTime) throws JsonProcessingException {
    public void usage(String beginTime, String endTime, List<String> codeList) throws JsonProcessingException {
        DBObject match = getMatchFields(beginTime, endTime);
        DBObject flowGroup = getFlowGroupFields();
        DBObject sort = getSortFields();
        // run aggregation
        AggregationOutput flowOutput = getBusinessLog().aggregate(match, flowGroup, sort);
        Integer successCountF = 0;
        Integer failureCountF = 0;
        String routeId = "";
        Map<String, Integer> usageMapSuccessF = new HashMap<>();
        Map<String, Integer> usageMapFailF = new HashMap<>();
        for (DBObject dbObject : flowOutput.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"));
            String code = StringUtil.toString(id.get("routeId"));
            if (total == count/2) {
                successCountF++;
                if (usageMapSuccessF.containsKey(code)) {
                    Integer countTemp = usageMapSuccessF.get(code);
                    usageMapSuccessF.put(code, ++countTemp);
                } else {
                    usageMapSuccessF.put(code, 1);
                }
            } else {
                failureCountF++;
                if (usageMapFailF.containsKey(code)) {
                    Integer countTemp = usageMapFailF.get(code);
                    usageMapFailF.put(code, ++countTemp);
                } else {
                    usageMapFailF.put(code, 1);
                }
            }
        }
        ObjectMapper objectMapper = new ObjectMapper();
        JSONObject resultF = new JSONObject();
        resultF.put("totalCount", successCountF + failureCountF);
        resultF.put("successCount", successCountF);
        resultF.put("failureCount", failureCountF);
        saveServiceMetrics(routeId, "usage", objectMapper.writeValueAsString(resultF.toString()), endTime);
        DBCursor serviceOutput = getBusinessLog().find(getQueryObject(beginTime, endTime));
        Map<String, Integer> usageMap = new HashMap<>();
        Map<String, Integer> usageFailMap = new HashMap<>();
        Map<String, DBObject> serviceMap = new HashMap<>();
        Map<String, Integer> usageMapSuccessS = new HashMap<>();
        Map<String, Integer> usageMapFailS = new HashMap<>();
        Map<String, String> serviceMap = new HashMap<>();
        for (DBObject dbObject : serviceOutput.toArray()) {
            String code = StringUtil.toString(dbObject.get("code"));
            if (!usageMap.containsKey(code)) {
                usageMap.put(code, 0);
            String order = StringUtil.toString(dbObject.get("order"));
            String breadcrumbId = StringUtil.toString(dbObject.get("breadcrumbId"));
            if (serviceMap.containsKey(code + breadcrumbId + order)) {
                serviceMap.remove(code + breadcrumbId + order);
                if (usageMapSuccessS.containsKey(code)) {
                    Integer countTemp = usageMapSuccessS.get(code);
                    usageMapSuccessS.put(code, ++countTemp);
                } else {
                    usageMapSuccessS.put(code, 1);
                }
            } else {
                serviceMap.put(code + breadcrumbId + order, code);
            }
            if (serviceMap.containsKey(code)) {
        }
                serviceMap.remove(code);
                Integer usageTemp = usageMap.get(code);
                usageMap.put(code, ++usageTemp);
                usageFailMap.put(code, 0);
        for (String key : serviceMap.keySet()) {
            String code = serviceMap.get(key);
            if (usageMapFailS.containsKey(code)) {
                Integer count = usageMapFailF.get(code);
                usageMapFailF.put(code, ++count);
            } else {
                serviceMap.put(code, dbObject);
                Integer usageTemp = usageMap.get(code);
                usageFailMap.put(code, ++usageTemp);
                usageMapFailF.put(code, 1);
            }
        }
        for (String code : usageMap.keySet()) {
            JSONObject resultS = new JSONObject();
            resultS.put("totalCount", usageMap.get(code) + usageFailMap.get(code));
            resultS.put("successCount", usageMap.get(code));
            resultS.put("failureCount", usageFailMap.get(code));
            saveServiceMetrics(code, "usage", objectMapper.writeValueAsString(resultS.toString()), endTime);
        for (String code : codeList) {
            JSONObject result = new JSONObject();
            Integer successCountF = isNull(usageMapSuccessF.get(code));
            Integer failureCountF = isNull(usageMapFailF.get(code));
            Integer successCountS= isNull(usageMapSuccessS.get(code));
            Integer failureCountS = isNull(usageMapFailS.get(code));
            if (successCountF > 0 || failureCountF > 0) {
                result.put("totalCount", successCountF + failureCountF);
                result.put("successCount", successCountF);
                result.put("failureCount",failureCountF);
            } else if (successCountS > 0 || failureCountS > 0) {
                result.put("totalCount", successCountS + failureCountS);
                result.put("successCount", successCountS);
                result.put("failureCount",failureCountS);
            } else {
                result.put("totalCount", 0);
                result.put("successCount", 0);
                result.put("failureCount",0);
            }
            ObjectMapper objectMapper = new ObjectMapper();
            saveServiceMetrics(code, "usage", objectMapper.writeValueAsString(result.toString()), endTime);
        }
    }
    public void delay(String beginTime, String endTime) {
    public void delay(String beginTime, String endTime, List<String> codeList) {
        DBObject match = getMatchFields(beginTime, endTime);
        DBObject flowGroup = getFlowGroupFields();
        DBObject sort = getSortFields();
        // run aggregation
        AggregationOutput flowOutput = getBusinessLog().aggregate(match, flowGroup, sort);
        BigDecimal flowDelay = BigDecimal.ZERO;
        String routeId = "";
        Map<String, BigDecimal> delayMapF = new HashMap<>();
        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"));
            String code = StringUtil.toString(id.get("routeId"));
            if (count >= 2) {
                String begin = StringUtil.toString(dbObject.get("beginTime"));
                String end = StringUtil.toString(dbObject.get("endTime"));
                long interval = getIntervalExact(begin, end);
                flowDelay = flowDelay.add(BigDecimal.valueOf(interval));
                if (delayMapF.containsKey(code)) {
                    BigDecimal flowDelay = delayMapF.get(code);
                    delayMapF.put(code, BigDecimal.valueOf(interval).add(flowDelay));
                } else {
                    delayMapF.put(code, BigDecimal.valueOf(interval));
                }
            }
        }
        saveServiceMetrics(routeId, "delay", flowDelay.toString(), endTime);
        DBCursor serviceOutput = getBusinessLog().find(getQueryObject(beginTime, endTime));
        Map<String, BigDecimal> delayMap = new HashMap<>();
        Map<String, BigDecimal> delayMapS = new HashMap<>();
        Map<String, DBObject> serviceMap = new HashMap<>();
        for (DBObject dbObject : serviceOutput.toArray()) {
            String code = StringUtil.toString(dbObject.get("code"));
@ -281,18 +322,24 @@ public class ServiceMonitorService {
                String begin = StringUtil.toString(dbObjectTemp.get("fireTimeSource"));
                String end = StringUtil.toString(dbObject.get("fireTimeSource"));
                long interval = getIntervalExact(begin, end);
                if (delayMap.containsKey(code)) {
                    BigDecimal delayTemp = delayMap.get(code);
                    delayMap.put(code, delayTemp.add(BigDecimal.valueOf(interval)));
                if (delayMapS.containsKey(code)) {
                    BigDecimal delayTemp = delayMapS.get(code);
                    delayMapS.put(code, delayTemp.add(BigDecimal.valueOf(interval)));
                } else {
                    delayMap.put(code, BigDecimal.valueOf(interval));
                    delayMapS.put(code, BigDecimal.valueOf(interval));
                }
            } else {
                serviceMap.put(code, dbObject);
            }
        }
        for (String code : delayMap.keySet()) {
            saveServiceMetrics(code, "delay", delayMap.get(code).toString(), endTime);
        for (String code : codeList) {
            BigDecimal delay = BigDecimal.ZERO;
            if (delayMapF.containsKey(code)) {
                delay = delayMapF.get(code);
            } else if (delayMapS.containsKey(code)) {
                delay = delayMapS.get(code);
            }
            saveServiceMetrics(code, "delay", delay.toString(), endTime);
        }
    }
@ -364,4 +411,11 @@ public class ServiceMonitorService {
        serviceMetrics.setCreateTime(createTime);
        mongoOperations.save(serviceMetrics);
    }
    public Integer isNull(Integer count) {
        if (count == null) {
            count = 0;
        }
        return count;
    }
}

+ 1 - 7
hos-camel/pom.xml

@ -7,6 +7,7 @@
    <groupId>hos-camel</groupId>
    <artifactId>hos-camel</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>net.sf.json-lib</groupId>
@ -26,11 +27,4 @@
        <version>1.1.1-SNAPSHOT</version>
        <relativePath>../hos-web-camel-dependencies</relativePath> <!-- lookup parent from repository -->
    </parent>
    <dependencies>
        <dependency>
            <groupId>com.yihu.hos</groupId>
            <artifactId>hos-web-framework</artifactId>
            <version>1.1.1-SNAPSHOT</version>
        </dependency>
    </dependencies>
</project>

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

@ -9,17 +9,16 @@ import qlc.processor.Processor2;
/**
 * Created by lingfeng on 2016/7/25.
 */
@Component
public class QlcRouteBulider extends RouteBuilder {
    @Override
    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")).log("servers: 3,code: 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")).log("servers: 3,code: 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")).log("servers: 3,code: patient")
                .to("http4://192.168.131.101:8088/crawler/patient").log("servers: 3,code: patient").to("stream:out"); // 2. 为路由配置组件或终端节点.
                .process(new Processor1()).setHeader(Exchange.HTTP_METHOD, constant("POST")).log("servers: 3,code: queryUserInfo,order: 1")
                .to("http4://192.168.131.101:8088/api/v1.0/qlc/queryUserInfo").log("servers: 3,code: queryUserInfo,order: 1")
                .process(new Processor2()).setHeader(Exchange.HTTP_METHOD, constant("POST")).log("servers: 3,code: patientInformation,order: 1")
                .to("http4://192.168.131.101:8088/api/v1.0/qlc/patientInformation").log("servers: 3,code: patientInformation,order: 1")
                .process(new Processor2()).setHeader(Exchange.HTTP_METHOD, constant("POST")).log("servers: 3,code: patient,order: 1")
                .to("http4://192.168.131.101:8088/crawler/patient").log("servers: 3,code: patient,order: 1").to("stream:out"); // 2. 为路由配置组件或终端节点.
    }
}

+ 9 - 6
hos-core/src/main/java/com/yihu/hos/core/datatype/ClassFileUtil.java

@ -23,7 +23,7 @@ public class ClassFileUtil {
     * @param className     class文件的类名信息
     * @param path          class文件的路径
     */
    public static void createClassfile(URL systemFlowURL, String packageName, String className, String path) {
    public static Boolean createClassfile(URL systemFlowURL, String packageName, String className, String path) {
        // 开始输出文件内容
        try {
            FileInputStream in = new FileInputStream(new File(path));
@ -50,12 +50,13 @@ public class ClassFileUtil {
            }
            out.close();
            in.close();
            return true;
        } catch (Exception e) {
            return;
            return false;
        }
    }
    public static void updateClassfile(String classPath, String path) {
    public static Boolean updateClassfile(String classPath, String path) {
        // 开始输出文件内容
        try {
            FileInputStream in = new FileInputStream(new File(path));
@ -73,20 +74,22 @@ public class ClassFileUtil {
            }
            out.close();
            in.close();
            return false;
        } catch (Exception e) {
            return;
            return true;
        }
    }
    public static void deleteClassfile(String classPath) {
    public static Boolean deleteClassfile(String classPath) {
        // 开始输出文件内容
        try {
            File file = new File(classPath);
            if (file.isFile() && file.exists()) {
                file.delete();
            }
            return false;
        } catch (Exception e) {
            return;
            return true;
        }
    }
}

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

@ -41,11 +41,11 @@ public class ServiceMonitorController {
    @ApiOperation(value = "获取服务指标", produces = "application/json", notes = "获取服务指标")
    public Result metrics(
            @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);
            @RequestParam(value = "id") String id,
            @ApiParam(name = "beginTime", value = "开始时间", required = true)
            @RequestParam(value = "beginTime") String beginTime,
            @ApiParam(name = "endTime", value = "结束时间", required = true)
            @RequestParam(value = "endTime") String endTime) {
        try {
            return monitorService.metrics(id, beginTime, endTime);
        } catch (Exception e) {

+ 0 - 138
src/main/java/com/yihu/hos/monitor/model/BusinessLog.java

@ -1,138 +0,0 @@
package com.yihu.hos.monitor.model;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.Date;
/**
 * @created Airhead 2016/8/8.
 */
@Document(collection = "businessLog")
public class BusinessLog {
    @Id
    private String id;
    @Indexed
    private String exchangeId;
    private String correlationId;
    private String transactionKey;
    @Indexed
    private String routeId;
    @Indexed
    private String breadcrumbId;
    private Integer totalServers;
    private String serverName;
    private String camelContextId;
    private String body;
    private Integer bodyLength;
    private String fireTimeSource;
    //@Indexed(name = "fireTime_1", expireAfterSeconds = 30)
    @Indexed
    private Date fireTime;  //后期建议转成TTL
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getExchangeId() {
        return exchangeId;
    }
    public void setExchangeId(String exchangeId) {
        this.exchangeId = exchangeId;
    }
    public String getCorrelationId() {
        return correlationId;
    }
    public void setCorrelationId(String correlationId) {
        this.correlationId = correlationId;
    }
    public String getTransactionKey() {
        return transactionKey;
    }
    public void setTransactionKey(String transactionKey) {
        this.transactionKey = transactionKey;
    }
    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 getCamelContextId() {
        return camelContextId;
    }
    public void setCamelContextId(String camelContextId) {
        this.camelContextId = camelContextId;
    }
    public String getBody() {
        return body;
    }
    public void setBody(String body) {
        this.body = body;
    }
    public Date getFireTime() {
        return fireTime;
    }
    public void setFireTime(Date fireTime) {
        this.fireTime = fireTime;
    }
    public Integer getBodyLength() {
        return bodyLength;
    }
    public void setBodyLength(Integer bodyLength) {
        this.bodyLength = bodyLength;
    }
    public String getFireTimeSource() {
        return fireTimeSource;
    }
    public void setFireTimeSource(String fireTimeSource) {
        this.fireTimeSource = fireTimeSource;
    }
    public Integer getTotalServers() {
        return totalServers;
    }
    public void setTotalServers(Integer totalServers) {
        this.totalServers = totalServers;
    }
    public String getServerName() {
        return serverName;
    }
    public void setServerName(String serverName) {
        this.serverName = serverName;
    }
}

+ 0 - 57
src/main/java/com/yihu/hos/monitor/service/ServiceMonitorService.java

@ -38,63 +38,6 @@ public class ServiceMonitorService {
    @Autowired
    private ServiceMonitorDao serviceMonitorDao;
//    public Result mapReduce(String beginTime, String endTime) {
//        DBCollection businessLogDB = mongoOperations.getCollection(mongoOperations
//                .getCollectionName(BusinessLog.class));
//
//        String map = "function(){emit(this.breadcrumbId, this.fireTime);}";
//        String reduce = "function(key, values){ return values[0];}";
//        String out = reduceTableName;
//        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)))});
//
//        MapReduceOutput mapReduceOutput = businessLogDB.mapReduce(map,
//                reduce.toString(), out, queryObject);
//        DBCollection resultColl = mapReduceOutput.getOutputCollection();
//        DBCursor cursor = resultColl.find();
//        String result = "";
//
//        while (cursor.hasNext()) {
//            result += cursor.next();
//        }
//        return Result.success(result);
//    }
//
//    public JSONObject aggregate(String beginTime, String endTime) {
//        DBCollection reduceDB = mongoOperations.getCollection(mongoOperations
//                .getCollectionName(ReduceResult.class));
//        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
//                new BasicDBObject[]{
//                        new BasicDBObject().append("value",
//                                new BasicDBObject().append(QueryOperators.GTE, DateUtil.toTimestamp(beginTime))),
//                        new BasicDBObject().append("value",
//                                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("$minute", "$value"));
//        groupFields.put("pv", new BasicDBObject( "$sum", 1));
//        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 = reduceDB.aggregate(match, group, sort);
//        String result = "";
//        for (DBObject dbObject : output.results()) {
//            result += dbObject.toString();
//        }
//        JSONObject jsonObject = new JSONObject(result);
//        return jsonObject;
//    }
    public Result metrics(String id, String beginTime, String endTime) throws Exception {
        String name;
        String code;

+ 4 - 3
src/main/java/com/yihu/hos/system/model/SystemServiceFlow.java

@ -1,5 +1,6 @@
package com.yihu.hos.system.model;
import java.util.Date;
import java.util.List;
/**
@ -16,7 +17,7 @@ public class SystemServiceFlow implements java.io.Serializable {
    private String chart;//流程图路径
    private String description;
    private Integer valid;
    private String createDate;
    private Date createDate;
    private String flowClassList;
    private List<SystemServiceFlowClass> flowClassArray;
@ -93,11 +94,11 @@ public class SystemServiceFlow implements java.io.Serializable {
        this.valid = valid;
    }
    public String getCreateDate() {
    public Date getCreateDate() {
        return createDate;
    }
    public void setCreateDate(String createDate) {
    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }
}

+ 16 - 0
src/main/webapp/WEB-INF/ehr/jsp/monitor/service/sEnvManage.jsp

@ -26,6 +26,7 @@
        <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;">
        <input id="selectId" style="display: none"/>
        <!-- ####### 查询条件部分 ####### -->
        <div class="m-form-inline" data-role-form>
            <div class="m-form-group">
@ -36,6 +37,21 @@
                    <label id="serviceDescription" style="width: 200px;text-align: left;width: 500px"></label>
                </div>
            </div>
            <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" />
                </div>
                <div class="m-form-control">
                    <div id="btnSearch" class="l-button">
                        <span>搜索</span>
                    </div>
                </div>
            </div>
            <%-- echarts 数据--%>
            <div id="main1" style="width: 500px;margin-left:50px;height:250px;border: solid deepskyblue 1px;"></div>
            <%-- echarts 数据--%>

+ 42 - 5
src/main/webapp/WEB-INF/ehr/jsp/monitor/service/sEnvManageJs.jsp

@ -12,6 +12,38 @@
            isLeftCollapse: false,//左边区域初始化不可以隐藏
            allowLeftCollapse: false//左边区域不可以隐藏
        });
        /*初始化时间控件-start*/
        $("#repeatStartTime").ligerDateEditor({
            width: 240,
            showTime: true
        });
        $("#repeatEndTime").ligerDateEditor({
            width: 240,
            showTime: true
        });
        $("#repeatStartTime").ligerDateEditor("setValue",prevDate());
        $("#repeatEndTime").ligerDateEditor("setValue",nowDate());
        /*初始化时间控件-end*/
        //搜索按钮事件
        $(".m-form-control").on("click","#btnSearch",function(){
            var beginTime = $("#repeatStartTime").ligerDateEditor("getValue");
            var endTime = $("#repeatEndTime").ligerDateEditor("getValue");
            if(beginTime=="" && $endTime=="")
            {
                $.ligerDialog.error("请选择起始结束时间!");
                return false;
            }
            if(beginTime > endTime)
            {
                $.ligerDialog.error("开始时间不能大于结束时间!");
                return false;
            }
            //获取服务器监控数据
            getServerInfo(id,beginTime,endTime);
        });
        //初始化树
        getServiceTree();
    });
@ -33,26 +65,31 @@
                        parentIDFieldName: 'pid',
                        isExpand: false,
                        onClick: function (obj) {
                            $("#selectId").val(obj.data.id);
                            var beginTime = $("#repeatStartTime").ligerDateEditor("getValue");
                            var endTime = $("#repeatEndTime").ligerDateEditor("getValue");
                            //初始化图表
                            debugger;
                             getServiceInfo(obj.data.id);
                            getServiceInfo(obj.data.id, beginTime, endTime);
                        },
                        onSuccess: function (data) {
                        }
                    });
                    getServiceInfo(message[0].id);
                    $("#selectId").val(message[0].id);
                    var beginTime = $("#repeatStartTime").ligerDateEditor("getValue");
                    var endTime = $("#repeatEndTime").ligerDateEditor("getValue");
                    getServiceInfo(message[0].id, beginTime, endTime);
                }
            }
        });
    }
    function getServiceInfo(id){
    function getServiceInfo(id, beginTime, endTime){
        $.ajax({
            type: "GET",
            url : "${contextRoot}/monitor/service/metrics",
            dataType : "json",
            data:{id:id},
            data:{id:id,beginTime:beginTime, endTime:endTime},
            cache:false,
            success :function(re){
                debugger;