zhenglingfeng 8 лет назад
Родитель
Сommit
cd4880071f

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

@ -86,8 +86,8 @@ public class MonitorScheduler {
    public void collectServiceHealth() throws JsonProcessingException {
        Date now = new Date();
        Date beforeDate = new Date(now.getTime() - 60000);
        String beginTime = DateUtil.toString(beforeDate, DateUtil.DEFAULT_TIMESTAMP_FORMAT);
        String endTime = DateUtil.toString(now, DateUtil.DEFAULT_TIMESTAMP_FORMAT);
        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);

+ 11 - 4
hos-broker/src/main/java/com/yihu/hos/services/ServiceMonitorService.java

@ -171,10 +171,10 @@ public class ServiceMonitorService {
    public void usage(String beginTime, String endTime) throws JsonProcessingException {
        DBObject match = getMatchFields(beginTime, endTime);
        DBObject group = getFlowGroupFields();
        DBObject flowGroup = getFlowGroupFields();
        DBObject sort = getSortFields();
        // run aggregation
        AggregationOutput flowOutput = getBusinessLog().aggregate(match, group, sort);
        AggregationOutput flowOutput = getBusinessLog().aggregate(match, flowGroup, sort);
        Integer successCountF = 0;
        Integer failureCountF = 0;
        String routeId = "";
@ -247,7 +247,7 @@ public class ServiceMonitorService {
            if (count >= 2) {
                String begin = StringUtil.toString(dbObject.get("beginTime"));
                String end = StringUtil.toString(dbObject.get("endTime"));
                long interval = getInterval(begin, end);
                long interval = getIntervalExact(begin, end);
                flowDelay = flowDelay.add(BigDecimal.valueOf(interval));
            }
        }
@ -264,7 +264,7 @@ public class ServiceMonitorService {
                DBObject dbObjectTemp = serviceMap.remove(code);
                String begin = StringUtil.toString(dbObjectTemp.get("fireTime"));
                String end = StringUtil.toString(dbObject.get("fireTime"));
                long interval = getInterval(begin, end);
                long interval = getIntervalExact(begin, end);
                if (delayMap.containsKey(code)) {
                    BigDecimal delayTemp = delayMap.get(code);
                    delayMap.put(code, delayTemp.add(BigDecimal.valueOf(interval)));
@ -327,6 +327,13 @@ public class ServiceMonitorService {
    }
    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 long getIntervalExact(String beginTime, String endTime) {
        Date from = DateUtil.toTimestamp(beginTime, DateUtil.DEFAULT_TIMESTAMP_FORMAT);
        Date to = DateUtil.toTimestamp(endTime, DateUtil.DEFAULT_TIMESTAMP_FORMAT);
        long interval = (to.getTime() - from.getTime())/1000;

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

@ -30,10 +30,10 @@
        <div class="m-form-inline" data-role-form>
            <div class="m-form-group">
                <div class="m-form-control">
                    <label stype="" id="serviceName"></label>
                    <label style="font-weight: 900;" id="serviceName"></label>
                </div>
                <div class="m-form-control">
                    <label id="serviceDescription"></label>
                <div class="m-form-control" style="    margin-top: 30px;margin-left: -30px; font-size: 15px;">
                    <label id="serviceDescription" style="width: 200px;text-align: left;width: 500px"></label>
                </div>
            </div>
            <%-- echarts 数据--%>

+ 3 - 1
src/main/webapp/WEB-INF/ehr/jsp/monitor/service/sEnvManageJs.jsp

@ -34,7 +34,8 @@
                        isExpand: false,
                        onClick: function (obj) {
                            //初始化图表
                             getServiceInfo(obj.id);
                            debugger;
                             getServiceInfo(obj.data.id);
                        },
                        onSuccess: function (data) {
@ -248,6 +249,7 @@
        usage:function(data){
            // 基于准备好的dom,初始化echarts实例
            var myChart = echarts.init(document.getElementById('main4'));
            debugger;
            if(data!=null && data.length>0)
            {
                var x = [];