diff --git a/Bench4Q-Web/src/main/java/org/bench4q/web/api/Main.java b/Bench4Q-Web/src/main/java/org/bench4q/web/api/Main.java index a82708d8..9a30c3cb 100644 --- a/Bench4Q-Web/src/main/java/org/bench4q/web/api/Main.java +++ b/Bench4Q-Web/src/main/java/org/bench4q/web/api/Main.java @@ -4,34 +4,37 @@ import java.io.FileOutputStream; import java.io.OutputStream; import java.util.LinkedList; import java.util.List; + import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; + import org.bench4q.web.model.ResultInfoModel; import org.bench4q.web.model.TestResult; public class Main { public static void main(String[] args) throws JAXBException { - Main main=new Main(); + Main main = new Main(); try { TestResult testResult = new TestResult(); List results = new LinkedList(); results.add(main.createCpuResult()); results.add(main.createMemoryResult()); + results.add(main.createPhyResult()); + results.add(main.createNetResult()); testResult.setResultInfoModels(results); OutputStream os = new FileOutputStream("sut.xml"); Marshaller marshaller = JAXBContext.newInstance(TestResult.class) .createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(testResult, os); - - + results.clear(); results.add(main.createScriptResult()); testResult.setResultInfoModels(results); OutputStream os1 = new FileOutputStream("script.xml"); - + marshaller.marshal(testResult, os1); } catch (Exception e) { @@ -74,15 +77,14 @@ public class Main { } } - private ResultInfoModel createCpuResult() { ResultInfoModel resultInfoModel = new ResultInfoModel(); resultInfoModel.setName("cpu"); resultInfoModel.setValue("cpu"); List cpuItems = new LinkedList(); - cpuItems.add(new ResultInfoModel( "使用率","processorTimePercent")); - cpuItems.add(new ResultInfoModel( "系统使用率","privilegedTimePercent")); - cpuItems.add(new ResultInfoModel( "用户使用率","userTimePercent")); + cpuItems.add(new ResultInfoModel("使用率", "processorTimePercent")); + cpuItems.add(new ResultInfoModel("系统使用率", "privilegedTimePercent")); + cpuItems.add(new ResultInfoModel("用户使用率", "userTimePercent")); resultInfoModel.setChildren(cpuItems); return resultInfoModel; @@ -91,17 +93,50 @@ public class Main { private ResultInfoModel createMemoryResult() { ResultInfoModel resultInfoModel = new ResultInfoModel(); resultInfoModel.setName("内存"); - resultInfoModel.setValue("mem"); + resultInfoModel.setValue("memory"); List memItems = new LinkedList(); - memItems.add(new ResultInfoModel("页速率","pagesPerSecond" )); - memItems.add(new ResultInfoModel("读页速率","pagesInputPerSecond")); - memItems.add(new ResultInfoModel("写页速率","pagesOutputPerSecond" )); - memItems.add(new ResultInfoModel("可用内存(kb)","availableKiloBytes")); - memItems.add(new ResultInfoModel( "总容量(kb)","totalKiloBytes")); - memItems.add(new ResultInfoModel( "使用率","memoryUsedPercent")); - memItems.add(new ResultInfoModel( "交换内存(kb)","swapKiloBytes")); + memItems.add(new ResultInfoModel("页速率", "pagesPerSecond")); + memItems.add(new ResultInfoModel("读页速率", "pagesInputPerSecond")); + memItems.add(new ResultInfoModel("写页速率", "pagesOutputPerSecond")); + memItems.add(new ResultInfoModel("可用内存(KB)", "availableKiloBytes")); + memItems.add(new ResultInfoModel("总容量(KB)", "totalKiloBytes")); + memItems.add(new ResultInfoModel("使用率", "memoryUsedPercent")); + memItems.add(new ResultInfoModel("交换内存(KB)", "swapKiloBytes")); resultInfoModel.setChildren(memItems); return resultInfoModel; } + private ResultInfoModel createPhyResult() { + ResultInfoModel resultInfoModel = new ResultInfoModel(); + resultInfoModel.setName("磁盘"); + resultInfoModel.setValue("physicalDisk"); + List phyInfoModels = new LinkedList(); + phyInfoModels.add(new ResultInfoModel("读速率(KB/S)", "diskReadKBytesRate")); + phyInfoModels + .add(new ResultInfoModel("写速率(KB/S)", "diskWriteKBytesRate")); + phyInfoModels + .add(new ResultInfoModel("总速率(KB)", "diskTotalKBytesRate")); + phyInfoModels.add(new ResultInfoModel("等待队列", "curDiskQueLength")); + phyInfoModels.add(new ResultInfoModel("总容量(GB)", "totalGB")); + phyInfoModels.add(new ResultInfoModel("占用量(GB)", "usedGB")); + phyInfoModels.add(new ResultInfoModel("使用率", "usedPercent")); + resultInfoModel.setChildren(phyInfoModels); + return resultInfoModel; + } + + private ResultInfoModel createNetResult() { + ResultInfoModel resultInfoModel = new ResultInfoModel(); + resultInfoModel.setName("网络"); + resultInfoModel.setValue("network"); + List phyInfoModels = new LinkedList(); + phyInfoModels.add(new ResultInfoModel("总速率(KB/S)", + "kiloBytesTotalPerSecond")); + phyInfoModels.add(new ResultInfoModel("接收速率(KB/S)", + "kiloBytesReceivedPerSecond")); + phyInfoModels.add(new ResultInfoModel("发送率(KB/S)", + "kiloBytesSentPerSecond")); + resultInfoModel.setChildren(phyInfoModels); + return resultInfoModel; + } + } diff --git a/Bench4Q-Web/src/main/java/org/bench4q/web/api/MonitorController.java b/Bench4Q-Web/src/main/java/org/bench4q/web/api/MonitorController.java index 01a16418..dac60f93 100644 --- a/Bench4Q-Web/src/main/java/org/bench4q/web/api/MonitorController.java +++ b/Bench4Q-Web/src/main/java/org/bench4q/web/api/MonitorController.java @@ -3,8 +3,9 @@ package org.bench4q.web.api; import java.util.HashMap; import java.util.List; import java.util.Map; - import org.bench4q.share.models.master.MonitorMemoryResponseModel; +import org.bench4q.share.models.master.MonitorNetworkReponseModel; +import org.bench4q.share.models.master.MonitorPhysicalDiskResponseModel; import org.bench4q.share.models.master.MonitorProcessorResponseModel; import org.bench4q.web.masterMessager.MonitorMessager; import org.bench4q.web.model.ResultModel; @@ -43,7 +44,7 @@ public class MonitorController extends BaseController { this.monitorService = monitorService; } - @RequestMapping("/{testPlanId}/{ip}/Cpu/{fieldName}/{startTime}") + @RequestMapping("/{testPlanId}/{ip}/cpu/{fieldName}/{startTime}") @ResponseBody public Map getCpuResult( @ModelAttribute("accessToken") String accessToken, @@ -59,7 +60,7 @@ public class MonitorController extends BaseController { } List resultModels = this.getMonitorService() - .extractCpuResult( + .extractMonitorResult( monitorProcessorResponseModel.getProcessorModels(), fieldName); @@ -72,37 +73,37 @@ public class MonitorController extends BaseController { } } - @RequestMapping("/{testPlanId}/SUT/{ip}/cpu/{cpuInstance}/{fieldName}/{startTime}") - @ResponseBody - public Map getCpuResult( - @ModelAttribute("accessToken") String accessToken, - @PathVariable("testPlanId") String testplanId, - @PathVariable String ip, @PathVariable String port, - @PathVariable String cpuInstance, @PathVariable String fieldName, - @PathVariable String startTime) { - Map map = new HashMap(); - MonitorProcessorResponseModel monitorProcessorResponseModel = this - .getMonitorMessager().porcessor(accessToken, testplanId, ip, - port, startTime); - if (monitorProcessorResponseModel == null) { - return fail(map, SERVER_ERROR); - } + // @RequestMapping("/{testPlanId}/SUT/{ip}/cpu/{cpuInstance}/{fieldName}/{startTime}") + // @ResponseBody + // public Map getCpuResult( + // @ModelAttribute("accessToken") String accessToken, + // @PathVariable("testPlanId") String testplanId, + // @PathVariable String ip, @PathVariable String port, + // @PathVariable String cpuInstance, @PathVariable String fieldName, + // @PathVariable String startTime) { + // Map map = new HashMap(); + // MonitorProcessorResponseModel monitorProcessorResponseModel = this + // .getMonitorMessager().porcessor(accessToken, testplanId, ip, + // port, startTime); + // if (monitorProcessorResponseModel == null) { + // return fail(map, SERVER_ERROR); + // } + // + // List resultModels = this.getMonitorService() + // .extractCpuResultModelList( + // monitorProcessorResponseModel.getProcessorModels(), + // cpuInstance, fieldName); + // if (resultModels == null) { + // return fail(map, SERVER_ERROR); + // } else { + // success(map); + // map.put("result", resultModels); + // return map; + // } + // + // } - List resultModels = this.getMonitorService() - .extractCpuResultModelList( - monitorProcessorResponseModel.getProcessorModels(), - cpuInstance, fieldName); - if (resultModels == null) { - return fail(map, SERVER_ERROR); - } else { - success(map); - map.put("result", resultModels); - return map; - } - - } - - @RequestMapping("/{testPlanId}/{ip}/Memory/{fieldName}/{startTime}") + @RequestMapping("/{testPlanId}/{ip}/memory/{fieldName}/{startTime}") @ResponseBody public Map getMemoryStatus( @ModelAttribute("accessToken") String accessToken, @@ -119,7 +120,7 @@ public class MonitorController extends BaseController { } List resultModels = this .getMonitorService() - .extractResultModelList( + .extractMonitorResult( monitorMemoryResponseModel.getMemoryModels(), fieldName); if (resultModels == null) { return fail(map, SERVER_ERROR); @@ -128,18 +129,62 @@ public class MonitorController extends BaseController { map.put("result", resultModels); return map; } + } + + @RequestMapping("/{testPlanId}/{ip}/physicalDisk/{fieldName}/{startTime}") + @ResponseBody + public Map getPhysicalDisk( + @ModelAttribute("accessToken") String accessToken, + @PathVariable("testPlanId") String testPlanId, + @PathVariable String ip, @PathVariable String fieldName, + @PathVariable String startTime) { + Map map = new HashMap<>(); + MonitorPhysicalDiskResponseModel monitorPhysicalDiskResponseModel = this + .getMonitorMessager().physicalDisk(accessToken, testPlanId, ip, + port, startTime); + if (monitorPhysicalDiskResponseModel == null) { + return fail(map, SERVER_ERROR); + } + List resultModels = this + .getMonitorService() + .extractMonitorResult( + monitorPhysicalDiskResponseModel + .getPhysicalDiskModels(), + fieldName); + if (resultModels == null) { + return fail(map, ""); + } else { + map = success(map); + map.put("result", resultModels); + return map; + } + } + + @RequestMapping("/{testPlanId}/{ip}/network/{fieldName}/{startTime}") + @ResponseBody + public Map getNetworkStaus( + @ModelAttribute("accessToken") String accessToken, + @PathVariable("testPlanId") String testPlanId, + @PathVariable String ip, @PathVariable String fieldName, + @PathVariable String startTime) { + Map map = new HashMap<>(); + MonitorNetworkReponseModel monitorNetworkReponseModel = this + .getMonitorMessager().network(accessToken, testPlanId, ip, + port, startTime); + + if (monitorNetworkReponseModel == null) { + return fail(map, SERVER_ERROR); + } + List resultModels = this.getMonitorService() + .extractMonitorResult(monitorNetworkReponseModel.getModels(), + fieldName); + if (resultModels == null) { + return fail(map, SERVER_ERROR); + } else { + map = success(map); + map.put("result", resultModels); + return map; + } } - - @RequestMapping("/{testPlanId}/SUT/{ip}/network/result/{fieldName}/{startTime}") - @ResponseBody - public Map getNetworkStaus( - @ModelAttribute("accessToken") String accessToken, - @PathVariable("testPlanId") String testPlanId, - @PathVariable String ip, @PathVariable String port, - @PathVariable String fieldName, @PathVariable String startTime) { - Map map = new HashMap<>(); - return map; - - } } diff --git a/Bench4Q-Web/src/main/java/org/bench4q/web/init/TestResultHandle.java b/Bench4Q-Web/src/main/java/org/bench4q/web/init/TestResultHandle.java index 963c3d24..99168f48 100644 --- a/Bench4Q-Web/src/main/java/org/bench4q/web/init/TestResultHandle.java +++ b/Bench4Q-Web/src/main/java/org/bench4q/web/init/TestResultHandle.java @@ -7,9 +7,11 @@ import java.io.IOException; import java.io.InputStreamReader; import java.net.URISyntaxException; import java.util.List; + import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; + import org.bench4q.web.model.ResultInfoModel; import org.bench4q.web.model.TestResult; diff --git a/Bench4Q-Web/src/main/java/org/bench4q/web/masterMessager/MonitorMessager.java b/Bench4Q-Web/src/main/java/org/bench4q/web/masterMessager/MonitorMessager.java index d985de6e..16fbfe9d 100644 --- a/Bench4Q-Web/src/main/java/org/bench4q/web/masterMessager/MonitorMessager.java +++ b/Bench4Q-Web/src/main/java/org/bench4q/web/masterMessager/MonitorMessager.java @@ -3,12 +3,12 @@ package org.bench4q.web.masterMessager; import java.io.IOException; import java.util.HashMap; import java.util.Map; - import javax.xml.bind.JAXBException; - import org.bench4q.share.communication.HttpRequester.HttpResponse; import org.bench4q.share.helper.MarshalHelper; import org.bench4q.share.models.master.MonitorMemoryResponseModel; +import org.bench4q.share.models.master.MonitorNetworkReponseModel; +import org.bench4q.share.models.master.MonitorPhysicalDiskResponseModel; import org.bench4q.share.models.master.MonitorProcessorResponseModel; import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.RequestMapping; @@ -59,11 +59,11 @@ public class MonitorMessager extends MasterMessager { try { httpResponse = this.getHttpRequester().sendGet(url, params, makeAccessTockenMap(accessToken)); - if (!validateHttpResponse(httpResponse)){ + if (!validateHttpResponse(httpResponse)) { return null; } - MonitorProcessorResponseModel monitorProcessorResponseModel = (MonitorProcessorResponseModel) MarshalHelper + MonitorProcessorResponseModel monitorProcessorResponseModel = (MonitorProcessorResponseModel) MarshalHelper .unmarshal(MonitorProcessorResponseModel.class, httpResponse.getContent()); return monitorProcessorResponseModel; @@ -73,6 +73,55 @@ public class MonitorMessager extends MasterMessager { } } + public MonitorNetworkReponseModel network(String accessToken, + String testPlanRunId, String hostName, String port, + String duationBegin) { + String url = this.baseUrl + "/networkInfo"; + Map params = createParmsMap(testPlanRunId, hostName, + port, duationBegin); + HttpResponse httpResponse = null; + try { + httpResponse = this.getHttpRequester().sendGet(url, params, + makeAccessTockenMap(accessToken)); + if (!validateHttpResponse(httpResponse)) { + handleInvalidatedResponse(url); + return null; + } + MonitorNetworkReponseModel networkInterfaceModel = (MonitorNetworkReponseModel) MarshalHelper + .unmarshal(MonitorNetworkReponseModel.class, + httpResponse.getContent()); + return networkInterfaceModel; + + } catch (Exception e) { + this.handleException(httpResponse, e); + return null; + } + } + + public MonitorPhysicalDiskResponseModel physicalDisk(String accessToken, + String testPlanRunId, String hostName, String port, + String duationBegin) { + String url = this.baseUrl + "/logicDiskMonitorSUTInfo" + "/" + + testPlanRunId + "/" + hostName + "/" + port + "/" + + duationBegin; + HttpResponse httpResponse = null; + try { + httpResponse = this.getHttpRequester().sendGet(url, null, + makeAccessTockenMap(accessToken)); + if (!validateHttpResponse(httpResponse)) { + this.handleInvalidatedResponse(url); + return null; + } + MonitorPhysicalDiskResponseModel monitorPhysicalDiskResponseModel = (MonitorPhysicalDiskResponseModel) MarshalHelper + .unmarshal(MonitorPhysicalDiskResponseModel.class, + httpResponse.getContent()); + return monitorPhysicalDiskResponseModel; + } catch (Exception e) { + this.handleException(httpResponse, e); + return null; + } + } + private Map createParmsMap(String testPlanRunId, String hostName, String port, String duationBegin) { Map params = new HashMap(); diff --git a/Bench4Q-Web/src/main/java/org/bench4q/web/service/MonitorService.java b/Bench4Q-Web/src/main/java/org/bench4q/web/service/MonitorService.java index 3fad404d..49160604 100644 --- a/Bench4Q-Web/src/main/java/org/bench4q/web/service/MonitorService.java +++ b/Bench4Q-Web/src/main/java/org/bench4q/web/service/MonitorService.java @@ -1,78 +1,33 @@ package org.bench4q.web.service; import java.util.ArrayList; -import java.util.LinkedList; import java.util.List; - import org.apache.log4j.Logger; import org.bench4q.share.helper.ExceptionLog; -import org.bench4q.share.models.master.MonitorProcessorResponseModel; -import org.bench4q.share.models.monitor.MemoryModel; -import org.bench4q.share.models.monitor.ProcessorModel; -import org.bench4q.share.models.monitor.ProcessorModelChild; -import org.bench4q.web.masterMessager.MonitorMessager; +import org.bench4q.share.models.master.statistics.SampleModel; import org.bench4q.web.model.ResultModel; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestParam; @Component public class MonitorService { - private MonitorMessager monitorMessager; - - private MonitorMessager getMonitorMessager() { - return monitorMessager; - } - - @Autowired - private void setMonitorMessager(MonitorMessager monitorMessager) { - this.monitorMessager = monitorMessager; - } private Logger logger = Logger.getLogger(MonitorService.class); - public List extractCpuResultModelList( - List processorModels, String instance, + public List extractMonitorResult(List list, String fieldName) { - if (processorModels == null) { - return null; - } - List resultModels = new ArrayList(); - for (ProcessorModel processorModel : processorModels) { - if (processorModel != null) { - ResultModel resultModel; - try { - resultModel = extractResultModel(processorModel, instance, - fieldName); - if (resultModel != null) - resultModels.add(resultModel); - } catch (NoSuchFieldException | IllegalArgumentException e) { - // TODO Auto-generated catch block - logger.info(ExceptionLog.getStackTrace(e)); - } - - } - - } - return resultModels; - } - - public List extractCpuResult( - List processorModels,String fieldName) { - if (processorModels == null) + if (list == null) return null; List resultModels = new ArrayList(); List fieldNames = new ArrayList(); fieldNames.add(fieldName); - for (ProcessorModel processorModel : processorModels) { - if (processorModel != null) { + for (SampleModel sampleModel : list) { + if (sampleModel != null) { ResultModel resultModel; try { resultModel = ChangeToResultModel.getResultModel( - processorModel, fieldNames); - resultModel.setTime(processorModel.getSamplingTime()); - resultModel.setFinished(processorModel.isFinished()); + sampleModel, fieldNames); + resultModel.setTime(sampleModel.getSamplingTime()); + resultModel.setFinished(sampleModel.isFinished()); resultModels.add(resultModel); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block @@ -84,92 +39,144 @@ public class MonitorService { return resultModels; } - public List extractResultModelList( - List memoryModels, String fieldName) { - if (memoryModels == null) - return null; - List resultModels = new ArrayList(); - List fieldNames = new ArrayList(); - fieldNames.add(fieldName); - for (MemoryModel memoryModel : memoryModels) { - if (memoryModel != null) { - ResultModel resultModel; - try { - resultModel = ChangeToResultModel.getResultModel( - memoryModel, fieldNames); - resultModel.setTime(memoryModel.getSamplingTime()); - resultModel.setFinished(memoryModel.isFinished()); - resultModels.add(resultModel); - } catch (NoSuchFieldException e) { - // TODO Auto-generated catch block - logger.info(ExceptionLog.getStackTrace(e)); - } - - } - } - return resultModels; - } - - private ResultModel extractResultModel(ProcessorModel processorModel, - String instance, String fieldName) throws NoSuchFieldException, - IllegalArgumentException { - List fieldNames = new ArrayList(); - fieldNames.add(fieldName); - if (processorModel.getProcessorModelList() == null) { - return null; - } - for (ProcessorModelChild processorModelChild : processorModel - .getProcessorModelList()) { - if (processorModelChild.getInstance().equalsIgnoreCase(instance)) { - ResultModel resultModel = ChangeToResultModel.getResultModel( - processorModelChild, fieldNames); - resultModel.setFinished(false); - resultModel.setTime(processorModel.getSamplingTime()); - return resultModel; - } - } - logger.info("no such cpu instance"); - return null; - } - - public List getCpuList( - @ModelAttribute("accessToken") String accessToken, - @RequestParam("testPlanId") String testPlanId, - @RequestParam String ip, String port) { - try { - MonitorProcessorResponseModel monitorProcessorResponseModel = getCpus( - accessToken, testPlanId, ip, port, "0"); - - ProcessorModel processorModel = null; - List processorModels = monitorProcessorResponseModel - .getProcessorModels(); - if (processorModels.size() > 0) { - processorModel = processorModels.get(0); - } - - else { - return new ArrayList(); - } - - List cpuList = new ArrayList(); - for (ProcessorModelChild processorModelChild : processorModel - .getProcessorModelList()) { - cpuList.add(processorModelChild.getInstance()); - } - return cpuList; - } catch (NullPointerException e) { - logger.info(ExceptionLog.getStackTrace(e)); - return new LinkedList(); - } - } - - public MonitorProcessorResponseModel getCpus( - @ModelAttribute("accessToken") String accessToken, - String testPlanId, String ip, String port, String startTime) { - MonitorProcessorResponseModel model = this.getMonitorMessager() - .porcessor(accessToken, testPlanId, ip, port, startTime); - return model; - - } + // public List extractCpuResultModelList( + // List processorModels, String instance, + // String fieldName) { + // if (processorModels == null) { + // return null; + // } + // List resultModels = new ArrayList(); + // for (ProcessorModel processorModel : processorModels) { + // if (processorModel != null) { + // ResultModel resultModel; + // try { + // resultModel = extractResultModel(processorModel, instance, + // fieldName); + // if (resultModel != null) + // resultModels.add(resultModel); + // } catch (NoSuchFieldException | IllegalArgumentException e) { + // // TODO Auto-generated catch block + // logger.info(ExceptionLog.getStackTrace(e)); + // } + // + // } + // + // } + // return resultModels; + // } + // + // public List extractCpuResult( + // List processorModels, String fieldName) { + // if (processorModels == null) + // return null; + // List resultModels = new ArrayList(); + // List fieldNames = new ArrayList(); + // fieldNames.add(fieldName); + // for (ProcessorModel processorModel : processorModels) { + // if (processorModel != null) { + // ResultModel resultModel; + // try { + // resultModel = ChangeToResultModel.getResultModel( + // processorModel, fieldNames); + // resultModel.setTime(processorModel.getSamplingTime()); + // resultModel.setFinished(processorModel.isFinished()); + // resultModels.add(resultModel); + // } catch (NoSuchFieldException e) { + // // TODO Auto-generated catch block + // logger.info(ExceptionLog.getStackTrace(e)); + // } + // + // } + // } + // return resultModels; + // } + // + // public List extractResultModelList( + // List memoryModels, String fieldName) { + // if (memoryModels == null) + // return null; + // List resultModels = new ArrayList(); + // List fieldNames = new ArrayList(); + // fieldNames.add(fieldName); + // for (MemoryModel memoryModel : memoryModels) { + // if (memoryModel != null) { + // ResultModel resultModel; + // try { + // resultModel = ChangeToResultModel.getResultModel( + // memoryModel, fieldNames); + // resultModel.setTime(memoryModel.getSamplingTime()); + // resultModel.setFinished(memoryModel.isFinished()); + // resultModels.add(resultModel); + // } catch (NoSuchFieldException e) { + // // TODO Auto-generated catch block + // logger.info(ExceptionLog.getStackTrace(e)); + // } + // + // } + // } + // return resultModels; + // } + // + // private ResultModel extractResultModel(ProcessorModel processorModel, + // String instance, String fieldName) throws NoSuchFieldException, + // IllegalArgumentException { + // List fieldNames = new ArrayList(); + // fieldNames.add(fieldName); + // if (processorModel.getProcessorModelList() == null) { + // return null; + // } + // for (ProcessorModelChild processorModelChild : processorModel + // .getProcessorModelList()) { + // if (processorModelChild.getInstance().equalsIgnoreCase(instance)) { + // ResultModel resultModel = ChangeToResultModel.getResultModel( + // processorModelChild, fieldNames); + // resultModel.setFinished(false); + // resultModel.setTime(processorModel.getSamplingTime()); + // return resultModel; + // } + // } + // logger.info("no such cpu instance"); + // return null; + // } + // + // public List getCpuList( + // @ModelAttribute("accessToken") String accessToken, + // @RequestParam("testPlanId") String testPlanId, + // @RequestParam String ip, String port) { + // try { + // MonitorProcessorResponseModel monitorProcessorResponseModel = getCpus( + // accessToken, testPlanId, ip, port, "0"); + // + // ProcessorModel processorModel = null; + // List processorModels = monitorProcessorResponseModel + // .getProcessorModels(); + // if (processorModels.size() > 0) { + // processorModel = processorModels.get(0); + // } + // + // else { + // return new ArrayList(); + // } + // + // List cpuList = new ArrayList(); + // for (ProcessorModelChild processorModelChild : processorModel + // .getProcessorModelList()) { + // cpuList.add(processorModelChild.getInstance()); + // } + // return cpuList; + // } catch (NullPointerException e) { + // logger.info(ExceptionLog.getStackTrace(e)); + // return new LinkedList(); + // } + // } + // + // public MonitorProcessorResponseModel getCpus( + // @ModelAttribute("accessToken") String accessToken, + // String testPlanId, String ip, String port, String startTime) { + // MonitorProcessorResponseModel model = this.getMonitorMessager() + // .porcessor(accessToken, testPlanId, ip, port, startTime); + // return model; + // + // } } diff --git a/Bench4Q-Web/src/main/resources/SUT_result.xml b/Bench4Q-Web/src/main/resources/SUT_result.xml index 3c4c49ae..f282b1fa 100644 --- a/Bench4Q-Web/src/main/resources/SUT_result.xml +++ b/Bench4Q-Web/src/main/resources/SUT_result.xml @@ -15,7 +15,7 @@ userTimePercent cpu - Cpu + cpu @@ -31,11 +31,11 @@ pagesOutputPerSecond - 可用内存(kb) + 可用内存(KB) availableKiloBytes - 总容量(kb) + 总容量(KB) totalKiloBytes @@ -43,11 +43,59 @@ memoryUsedPercent - 交换内存(kb) + 交换内存(KB) swapKiloBytes 内存 - Memory + memory + + + + 读速率(KB/S) + diskReadKBytesRate + + + 写速率(KB/S) + diskWriteKBytesRate + + + 总速率(KB) + diskTotalKBytesRate + + + 等待队列 + curDiskQueLength + + + 总容量(GB) + totalGB + + + 占用量(GB) + usedGB + + + 使用率 + usedPercent + + 磁盘 + physicalDisk + + + + 总速率(KB/S) + kiloBytesTotalPerSecond + + + 接收速率(KB/S) + kiloBytesReceivedPerSecond + + + 发送率(KB/S) + kiloBytesSentPerSecond + + 网络 + network diff --git a/Bench4Q-Web/src/main/webapp/script/testResult/resultNew.js b/Bench4Q-Web/src/main/webapp/script/testResult/resultNew.js index 02627bf4..a813a9f7 100644 --- a/Bench4Q-Web/src/main/webapp/script/testResult/resultNew.js +++ b/Bench4Q-Web/src/main/webapp/script/testResult/resultNew.js @@ -20,8 +20,8 @@ $(function() { // behaviorResult.getResult(testPlanId, getScriptList(testPlanId)); // // var pageResult = new PageResult(); // pageResult.getResult(testPlanId, getScriptList(testPlanId)); - var urlContentTypeDistribution = new UrlContentTypeDistribution( - "url-distribution", testPlanId); +// var urlContentTypeDistribution = new UrlContentTypeDistribution( +// "url-distribution", testPlanId); }); function getTestInfo(testPlanId) { var testPlan; diff --git a/Bench4Q-Web/src/test/java/org/bench4q/web/test/masterMessager/TestPlanMessageTest.java b/Bench4Q-Web/src/test/java/org/bench4q/web/test/masterMessager/TestPlanMessageTest.java index af187f97..d8de2f0a 100644 --- a/Bench4Q-Web/src/test/java/org/bench4q/web/test/masterMessager/TestPlanMessageTest.java +++ b/Bench4Q-Web/src/test/java/org/bench4q/web/test/masterMessager/TestPlanMessageTest.java @@ -7,7 +7,6 @@ import static org.junit.Assert.*; import org.bench4q.share.helper.MarshalHelper; import org.bench4q.share.models.master.TestPlanResponseModel; import org.bench4q.share.models.master.TestPlanResultModel; -import org.bench4q.share.models.master.TestPlanScriptBriefResultModel; import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel; import org.bench4q.web.masterMessager.TestPlanMessager; @@ -27,7 +26,6 @@ public class TestPlanMessageTest extends MessagerTestBase { private String baseUrl = "/testPlan"; private String testPlanId = "testPlanId"; private String scriptId = "scriptId"; - private String duationBegin = "duationBegin"; public TestPlanMessager getTestPlanMessager() { return testPlanMessager;