add monitor result
This commit is contained in:
parent
b70bb4aa3d
commit
614bd80e39
|
@ -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<ResultInfoModel> results = new LinkedList<ResultInfoModel>();
|
||||
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<ResultInfoModel> cpuItems = new LinkedList<ResultInfoModel>();
|
||||
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<ResultInfoModel> memItems = new LinkedList<ResultInfoModel>();
|
||||
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<ResultInfoModel> phyInfoModels = new LinkedList<ResultInfoModel>();
|
||||
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<ResultInfoModel> phyInfoModels = new LinkedList<ResultInfoModel>();
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<String, Object> getCpuResult(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
|
@ -59,7 +60,7 @@ public class MonitorController extends BaseController {
|
|||
}
|
||||
|
||||
List<ResultModel> 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<String, Object> 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<String, Object> map = new HashMap<String, Object>();
|
||||
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<String, Object> 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<String, Object> map = new HashMap<String, Object>();
|
||||
// MonitorProcessorResponseModel monitorProcessorResponseModel = this
|
||||
// .getMonitorMessager().porcessor(accessToken, testplanId, ip,
|
||||
// port, startTime);
|
||||
// if (monitorProcessorResponseModel == null) {
|
||||
// return fail(map, SERVER_ERROR);
|
||||
// }
|
||||
//
|
||||
// List<ResultModel> 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<ResultModel> 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<String, Object> getMemoryStatus(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
|
@ -119,7 +120,7 @@ public class MonitorController extends BaseController {
|
|||
}
|
||||
List<ResultModel> 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<String, Object> getPhysicalDisk(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@PathVariable("testPlanId") String testPlanId,
|
||||
@PathVariable String ip, @PathVariable String fieldName,
|
||||
@PathVariable String startTime) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
MonitorPhysicalDiskResponseModel monitorPhysicalDiskResponseModel = this
|
||||
.getMonitorMessager().physicalDisk(accessToken, testPlanId, ip,
|
||||
port, startTime);
|
||||
if (monitorPhysicalDiskResponseModel == null) {
|
||||
return fail(map, SERVER_ERROR);
|
||||
}
|
||||
List<ResultModel> 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<String, Object> getNetworkStaus(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@PathVariable("testPlanId") String testPlanId,
|
||||
@PathVariable String ip, @PathVariable String fieldName,
|
||||
@PathVariable String startTime) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
MonitorNetworkReponseModel monitorNetworkReponseModel = this
|
||||
.getMonitorMessager().network(accessToken, testPlanId, ip,
|
||||
port, startTime);
|
||||
|
||||
if (monitorNetworkReponseModel == null) {
|
||||
return fail(map, SERVER_ERROR);
|
||||
}
|
||||
List<ResultModel> 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<String, String> getNetworkStaus(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@PathVariable("testPlanId") String testPlanId,
|
||||
@PathVariable String ip, @PathVariable String port,
|
||||
@PathVariable String fieldName, @PathVariable String startTime) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
return map;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<String, String> 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<String, String> createParmsMap(String testPlanRunId,
|
||||
String hostName, String port, String duationBegin) {
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
|
|
|
@ -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<ResultModel> extractCpuResultModelList(
|
||||
List<ProcessorModel> processorModels, String instance,
|
||||
public List<ResultModel> extractMonitorResult(List<? extends SampleModel> list,
|
||||
String fieldName) {
|
||||
if (processorModels == null) {
|
||||
return null;
|
||||
}
|
||||
List<ResultModel> resultModels = new ArrayList<ResultModel>();
|
||||
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<ResultModel> extractCpuResult(
|
||||
List<ProcessorModel> processorModels,String fieldName) {
|
||||
if (processorModels == null)
|
||||
if (list == null)
|
||||
return null;
|
||||
List<ResultModel> resultModels = new ArrayList<ResultModel>();
|
||||
List<String> fieldNames = new ArrayList<String>();
|
||||
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<ResultModel> extractResultModelList(
|
||||
List<MemoryModel> memoryModels, String fieldName) {
|
||||
if (memoryModels == null)
|
||||
return null;
|
||||
List<ResultModel> resultModels = new ArrayList<ResultModel>();
|
||||
List<String> fieldNames = new ArrayList<String>();
|
||||
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<String> fieldNames = new ArrayList<String>();
|
||||
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<String> 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<ProcessorModel> processorModels = monitorProcessorResponseModel
|
||||
.getProcessorModels();
|
||||
if (processorModels.size() > 0) {
|
||||
processorModel = processorModels.get(0);
|
||||
}
|
||||
|
||||
else {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
List<String> cpuList = new ArrayList<String>();
|
||||
for (ProcessorModelChild processorModelChild : processorModel
|
||||
.getProcessorModelList()) {
|
||||
cpuList.add(processorModelChild.getInstance());
|
||||
}
|
||||
return cpuList;
|
||||
} catch (NullPointerException e) {
|
||||
logger.info(ExceptionLog.getStackTrace(e));
|
||||
return new LinkedList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
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<ResultModel> extractCpuResultModelList(
|
||||
// List<ProcessorModel> processorModels, String instance,
|
||||
// String fieldName) {
|
||||
// if (processorModels == null) {
|
||||
// return null;
|
||||
// }
|
||||
// List<ResultModel> resultModels = new ArrayList<ResultModel>();
|
||||
// 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<ResultModel> extractCpuResult(
|
||||
// List<ProcessorModel> processorModels, String fieldName) {
|
||||
// if (processorModels == null)
|
||||
// return null;
|
||||
// List<ResultModel> resultModels = new ArrayList<ResultModel>();
|
||||
// List<String> fieldNames = new ArrayList<String>();
|
||||
// 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<ResultModel> extractResultModelList(
|
||||
// List<MemoryModel> memoryModels, String fieldName) {
|
||||
// if (memoryModels == null)
|
||||
// return null;
|
||||
// List<ResultModel> resultModels = new ArrayList<ResultModel>();
|
||||
// List<String> fieldNames = new ArrayList<String>();
|
||||
// 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<String> fieldNames = new ArrayList<String>();
|
||||
// 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<String> 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<ProcessorModel> processorModels = monitorProcessorResponseModel
|
||||
// .getProcessorModels();
|
||||
// if (processorModels.size() > 0) {
|
||||
// processorModel = processorModels.get(0);
|
||||
// }
|
||||
//
|
||||
// else {
|
||||
// return new ArrayList<String>();
|
||||
// }
|
||||
//
|
||||
// List<String> cpuList = new ArrayList<String>();
|
||||
// for (ProcessorModelChild processorModelChild : processorModel
|
||||
// .getProcessorModelList()) {
|
||||
// cpuList.add(processorModelChild.getInstance());
|
||||
// }
|
||||
// return cpuList;
|
||||
// } catch (NullPointerException e) {
|
||||
// logger.info(ExceptionLog.getStackTrace(e));
|
||||
// return new LinkedList<String>();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// 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;
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<value>userTimePercent</value>
|
||||
</children>
|
||||
<name>cpu</name>
|
||||
<value>Cpu</value>
|
||||
<value>cpu</value>
|
||||
</result>
|
||||
<result>
|
||||
<children>
|
||||
|
@ -31,11 +31,11 @@
|
|||
<value>pagesOutputPerSecond</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>可用内存(kb)</name>
|
||||
<name>可用内存(KB)</name>
|
||||
<value>availableKiloBytes</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>总容量(kb)</name>
|
||||
<name>总容量(KB)</name>
|
||||
<value>totalKiloBytes</value>
|
||||
</children>
|
||||
<children>
|
||||
|
@ -43,11 +43,59 @@
|
|||
<value>memoryUsedPercent</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>交换内存(kb)</name>
|
||||
<name>交换内存(KB)</name>
|
||||
<value>swapKiloBytes</value>
|
||||
</children>
|
||||
<name>内存</name>
|
||||
<value>Memory</value>
|
||||
<value>memory</value>
|
||||
</result>
|
||||
<result>
|
||||
<children>
|
||||
<name>读速率(KB/S)</name>
|
||||
<value>diskReadKBytesRate</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>写速率(KB/S)</name>
|
||||
<value>diskWriteKBytesRate</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>总速率(KB)</name>
|
||||
<value>diskTotalKBytesRate</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>等待队列</name>
|
||||
<value>curDiskQueLength</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>总容量(GB)</name>
|
||||
<value>totalGB</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>占用量(GB)</name>
|
||||
<value>usedGB</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>使用率</name>
|
||||
<value>usedPercent</value>
|
||||
</children>
|
||||
<name>磁盘</name>
|
||||
<value>physicalDisk</value>
|
||||
</result>
|
||||
<result>
|
||||
<children>
|
||||
<name>总速率(KB/S)</name>
|
||||
<value>kiloBytesTotalPerSecond</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>接收速率(KB/S)</name>
|
||||
<value>kiloBytesReceivedPerSecond</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>发送率(KB/S)</name>
|
||||
<value>kiloBytesSentPerSecond</value>
|
||||
</children>
|
||||
<name>网络</name>
|
||||
<value>network</value>
|
||||
</result>
|
||||
</results>
|
||||
</testResult>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue