add monitor result
This commit is contained in:
parent
b70bb4aa3d
commit
614bd80e39
|
@ -4,21 +4,25 @@ import java.io.FileOutputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBContext;
|
import javax.xml.bind.JAXBContext;
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
import javax.xml.bind.Marshaller;
|
import javax.xml.bind.Marshaller;
|
||||||
|
|
||||||
import org.bench4q.web.model.ResultInfoModel;
|
import org.bench4q.web.model.ResultInfoModel;
|
||||||
import org.bench4q.web.model.TestResult;
|
import org.bench4q.web.model.TestResult;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) throws JAXBException {
|
public static void main(String[] args) throws JAXBException {
|
||||||
Main main=new Main();
|
Main main = new Main();
|
||||||
try {
|
try {
|
||||||
TestResult testResult = new TestResult();
|
TestResult testResult = new TestResult();
|
||||||
List<ResultInfoModel> results = new LinkedList<ResultInfoModel>();
|
List<ResultInfoModel> results = new LinkedList<ResultInfoModel>();
|
||||||
results.add(main.createCpuResult());
|
results.add(main.createCpuResult());
|
||||||
results.add(main.createMemoryResult());
|
results.add(main.createMemoryResult());
|
||||||
|
results.add(main.createPhyResult());
|
||||||
|
results.add(main.createNetResult());
|
||||||
testResult.setResultInfoModels(results);
|
testResult.setResultInfoModels(results);
|
||||||
OutputStream os = new FileOutputStream("sut.xml");
|
OutputStream os = new FileOutputStream("sut.xml");
|
||||||
Marshaller marshaller = JAXBContext.newInstance(TestResult.class)
|
Marshaller marshaller = JAXBContext.newInstance(TestResult.class)
|
||||||
|
@ -26,7 +30,6 @@ public class Main {
|
||||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
|
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
|
||||||
marshaller.marshal(testResult, os);
|
marshaller.marshal(testResult, os);
|
||||||
|
|
||||||
|
|
||||||
results.clear();
|
results.clear();
|
||||||
results.add(main.createScriptResult());
|
results.add(main.createScriptResult());
|
||||||
testResult.setResultInfoModels(results);
|
testResult.setResultInfoModels(results);
|
||||||
|
@ -74,15 +77,14 @@ public class Main {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private ResultInfoModel createCpuResult() {
|
private ResultInfoModel createCpuResult() {
|
||||||
ResultInfoModel resultInfoModel = new ResultInfoModel();
|
ResultInfoModel resultInfoModel = new ResultInfoModel();
|
||||||
resultInfoModel.setName("cpu");
|
resultInfoModel.setName("cpu");
|
||||||
resultInfoModel.setValue("cpu");
|
resultInfoModel.setValue("cpu");
|
||||||
List<ResultInfoModel> cpuItems = new LinkedList<ResultInfoModel>();
|
List<ResultInfoModel> cpuItems = new LinkedList<ResultInfoModel>();
|
||||||
cpuItems.add(new ResultInfoModel( "使用率","processorTimePercent"));
|
cpuItems.add(new ResultInfoModel("使用率", "processorTimePercent"));
|
||||||
cpuItems.add(new ResultInfoModel( "系统使用率","privilegedTimePercent"));
|
cpuItems.add(new ResultInfoModel("系统使用率", "privilegedTimePercent"));
|
||||||
cpuItems.add(new ResultInfoModel( "用户使用率","userTimePercent"));
|
cpuItems.add(new ResultInfoModel("用户使用率", "userTimePercent"));
|
||||||
resultInfoModel.setChildren(cpuItems);
|
resultInfoModel.setChildren(cpuItems);
|
||||||
return resultInfoModel;
|
return resultInfoModel;
|
||||||
|
|
||||||
|
@ -91,17 +93,50 @@ public class Main {
|
||||||
private ResultInfoModel createMemoryResult() {
|
private ResultInfoModel createMemoryResult() {
|
||||||
ResultInfoModel resultInfoModel = new ResultInfoModel();
|
ResultInfoModel resultInfoModel = new ResultInfoModel();
|
||||||
resultInfoModel.setName("内存");
|
resultInfoModel.setName("内存");
|
||||||
resultInfoModel.setValue("mem");
|
resultInfoModel.setValue("memory");
|
||||||
List<ResultInfoModel> memItems = new LinkedList<ResultInfoModel>();
|
List<ResultInfoModel> memItems = new LinkedList<ResultInfoModel>();
|
||||||
memItems.add(new ResultInfoModel("页速率","pagesPerSecond" ));
|
memItems.add(new ResultInfoModel("页速率", "pagesPerSecond"));
|
||||||
memItems.add(new ResultInfoModel("读页速率","pagesInputPerSecond"));
|
memItems.add(new ResultInfoModel("读页速率", "pagesInputPerSecond"));
|
||||||
memItems.add(new ResultInfoModel("写页速率","pagesOutputPerSecond" ));
|
memItems.add(new ResultInfoModel("写页速率", "pagesOutputPerSecond"));
|
||||||
memItems.add(new ResultInfoModel("可用内存(kb)","availableKiloBytes"));
|
memItems.add(new ResultInfoModel("可用内存(KB)", "availableKiloBytes"));
|
||||||
memItems.add(new ResultInfoModel( "总容量(kb)","totalKiloBytes"));
|
memItems.add(new ResultInfoModel("总容量(KB)", "totalKiloBytes"));
|
||||||
memItems.add(new ResultInfoModel( "使用率","memoryUsedPercent"));
|
memItems.add(new ResultInfoModel("使用率", "memoryUsedPercent"));
|
||||||
memItems.add(new ResultInfoModel( "交换内存(kb)","swapKiloBytes"));
|
memItems.add(new ResultInfoModel("交换内存(KB)", "swapKiloBytes"));
|
||||||
resultInfoModel.setChildren(memItems);
|
resultInfoModel.setChildren(memItems);
|
||||||
return resultInfoModel;
|
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.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bench4q.share.models.master.MonitorMemoryResponseModel;
|
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.share.models.master.MonitorProcessorResponseModel;
|
||||||
import org.bench4q.web.masterMessager.MonitorMessager;
|
import org.bench4q.web.masterMessager.MonitorMessager;
|
||||||
import org.bench4q.web.model.ResultModel;
|
import org.bench4q.web.model.ResultModel;
|
||||||
|
@ -43,7 +44,7 @@ public class MonitorController extends BaseController {
|
||||||
this.monitorService = monitorService;
|
this.monitorService = monitorService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/{testPlanId}/{ip}/Cpu/{fieldName}/{startTime}")
|
@RequestMapping("/{testPlanId}/{ip}/cpu/{fieldName}/{startTime}")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Map<String, Object> getCpuResult(
|
public Map<String, Object> getCpuResult(
|
||||||
@ModelAttribute("accessToken") String accessToken,
|
@ModelAttribute("accessToken") String accessToken,
|
||||||
|
@ -59,7 +60,7 @@ public class MonitorController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ResultModel> resultModels = this.getMonitorService()
|
List<ResultModel> resultModels = this.getMonitorService()
|
||||||
.extractCpuResult(
|
.extractMonitorResult(
|
||||||
monitorProcessorResponseModel.getProcessorModels(),
|
monitorProcessorResponseModel.getProcessorModels(),
|
||||||
fieldName);
|
fieldName);
|
||||||
|
|
||||||
|
@ -72,37 +73,37 @@ public class MonitorController extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/{testPlanId}/SUT/{ip}/cpu/{cpuInstance}/{fieldName}/{startTime}")
|
// @RequestMapping("/{testPlanId}/SUT/{ip}/cpu/{cpuInstance}/{fieldName}/{startTime}")
|
||||||
@ResponseBody
|
// @ResponseBody
|
||||||
public Map<String, Object> getCpuResult(
|
// public Map<String, Object> getCpuResult(
|
||||||
@ModelAttribute("accessToken") String accessToken,
|
// @ModelAttribute("accessToken") String accessToken,
|
||||||
@PathVariable("testPlanId") String testplanId,
|
// @PathVariable("testPlanId") String testplanId,
|
||||||
@PathVariable String ip, @PathVariable String port,
|
// @PathVariable String ip, @PathVariable String port,
|
||||||
@PathVariable String cpuInstance, @PathVariable String fieldName,
|
// @PathVariable String cpuInstance, @PathVariable String fieldName,
|
||||||
@PathVariable String startTime) {
|
// @PathVariable String startTime) {
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
// Map<String, Object> map = new HashMap<String, Object>();
|
||||||
MonitorProcessorResponseModel monitorProcessorResponseModel = this
|
// MonitorProcessorResponseModel monitorProcessorResponseModel = this
|
||||||
.getMonitorMessager().porcessor(accessToken, testplanId, ip,
|
// .getMonitorMessager().porcessor(accessToken, testplanId, ip,
|
||||||
port, startTime);
|
// port, startTime);
|
||||||
if (monitorProcessorResponseModel == null) {
|
// if (monitorProcessorResponseModel == null) {
|
||||||
return fail(map, SERVER_ERROR);
|
// 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()
|
@RequestMapping("/{testPlanId}/{ip}/memory/{fieldName}/{startTime}")
|
||||||
.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}")
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Map<String, Object> getMemoryStatus(
|
public Map<String, Object> getMemoryStatus(
|
||||||
@ModelAttribute("accessToken") String accessToken,
|
@ModelAttribute("accessToken") String accessToken,
|
||||||
|
@ -119,7 +120,7 @@ public class MonitorController extends BaseController {
|
||||||
}
|
}
|
||||||
List<ResultModel> resultModels = this
|
List<ResultModel> resultModels = this
|
||||||
.getMonitorService()
|
.getMonitorService()
|
||||||
.extractResultModelList(
|
.extractMonitorResult(
|
||||||
monitorMemoryResponseModel.getMemoryModels(), fieldName);
|
monitorMemoryResponseModel.getMemoryModels(), fieldName);
|
||||||
if (resultModels == null) {
|
if (resultModels == null) {
|
||||||
return fail(map, SERVER_ERROR);
|
return fail(map, SERVER_ERROR);
|
||||||
|
@ -128,18 +129,62 @@ public class MonitorController extends BaseController {
|
||||||
map.put("result", resultModels);
|
map.put("result", resultModels);
|
||||||
return map;
|
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.io.InputStreamReader;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBContext;
|
import javax.xml.bind.JAXBContext;
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
import javax.xml.bind.Unmarshaller;
|
import javax.xml.bind.Unmarshaller;
|
||||||
|
|
||||||
import org.bench4q.web.model.ResultInfoModel;
|
import org.bench4q.web.model.ResultInfoModel;
|
||||||
import org.bench4q.web.model.TestResult;
|
import org.bench4q.web.model.TestResult;
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,12 @@ package org.bench4q.web.masterMessager;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
|
|
||||||
import org.bench4q.share.communication.HttpRequester.HttpResponse;
|
import org.bench4q.share.communication.HttpRequester.HttpResponse;
|
||||||
import org.bench4q.share.helper.MarshalHelper;
|
import org.bench4q.share.helper.MarshalHelper;
|
||||||
import org.bench4q.share.models.master.MonitorMemoryResponseModel;
|
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.share.models.master.MonitorProcessorResponseModel;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
@ -59,7 +59,7 @@ public class MonitorMessager extends MasterMessager {
|
||||||
try {
|
try {
|
||||||
httpResponse = this.getHttpRequester().sendGet(url, params,
|
httpResponse = this.getHttpRequester().sendGet(url, params,
|
||||||
makeAccessTockenMap(accessToken));
|
makeAccessTockenMap(accessToken));
|
||||||
if (!validateHttpResponse(httpResponse)){
|
if (!validateHttpResponse(httpResponse)) {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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,
|
private Map<String, String> createParmsMap(String testPlanRunId,
|
||||||
String hostName, String port, String duationBegin) {
|
String hostName, String port, String duationBegin) {
|
||||||
Map<String, String> params = new HashMap<String, String>();
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
|
|
|
@ -1,78 +1,33 @@
|
||||||
package org.bench4q.web.service;
|
package org.bench4q.web.service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.bench4q.share.helper.ExceptionLog;
|
import org.bench4q.share.helper.ExceptionLog;
|
||||||
import org.bench4q.share.models.master.MonitorProcessorResponseModel;
|
import org.bench4q.share.models.master.statistics.SampleModel;
|
||||||
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.web.model.ResultModel;
|
import org.bench4q.web.model.ResultModel;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class MonitorService {
|
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);
|
private Logger logger = Logger.getLogger(MonitorService.class);
|
||||||
|
|
||||||
public List<ResultModel> extractCpuResultModelList(
|
public List<ResultModel> extractMonitorResult(List<? extends SampleModel> list,
|
||||||
List<ProcessorModel> processorModels, String instance,
|
|
||||||
String fieldName) {
|
String fieldName) {
|
||||||
if (processorModels == null) {
|
if (list == 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;
|
return null;
|
||||||
List<ResultModel> resultModels = new ArrayList<ResultModel>();
|
List<ResultModel> resultModels = new ArrayList<ResultModel>();
|
||||||
List<String> fieldNames = new ArrayList<String>();
|
List<String> fieldNames = new ArrayList<String>();
|
||||||
fieldNames.add(fieldName);
|
fieldNames.add(fieldName);
|
||||||
for (ProcessorModel processorModel : processorModels) {
|
for (SampleModel sampleModel : list) {
|
||||||
if (processorModel != null) {
|
if (sampleModel != null) {
|
||||||
ResultModel resultModel;
|
ResultModel resultModel;
|
||||||
try {
|
try {
|
||||||
resultModel = ChangeToResultModel.getResultModel(
|
resultModel = ChangeToResultModel.getResultModel(
|
||||||
processorModel, fieldNames);
|
sampleModel, fieldNames);
|
||||||
resultModel.setTime(processorModel.getSamplingTime());
|
resultModel.setTime(sampleModel.getSamplingTime());
|
||||||
resultModel.setFinished(processorModel.isFinished());
|
resultModel.setFinished(sampleModel.isFinished());
|
||||||
resultModels.add(resultModel);
|
resultModels.add(resultModel);
|
||||||
} catch (NoSuchFieldException e) {
|
} catch (NoSuchFieldException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
|
@ -84,92 +39,144 @@ public class MonitorService {
|
||||||
return resultModels;
|
return resultModels;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ResultModel> extractResultModelList(
|
// public List<ResultModel> extractCpuResultModelList(
|
||||||
List<MemoryModel> memoryModels, String fieldName) {
|
// List<ProcessorModel> processorModels, String instance,
|
||||||
if (memoryModels == null)
|
// String fieldName) {
|
||||||
return null;
|
// if (processorModels == null) {
|
||||||
List<ResultModel> resultModels = new ArrayList<ResultModel>();
|
// return null;
|
||||||
List<String> fieldNames = new ArrayList<String>();
|
// }
|
||||||
fieldNames.add(fieldName);
|
// List<ResultModel> resultModels = new ArrayList<ResultModel>();
|
||||||
for (MemoryModel memoryModel : memoryModels) {
|
// for (ProcessorModel processorModel : processorModels) {
|
||||||
if (memoryModel != null) {
|
// if (processorModel != null) {
|
||||||
ResultModel resultModel;
|
// ResultModel resultModel;
|
||||||
try {
|
// try {
|
||||||
resultModel = ChangeToResultModel.getResultModel(
|
// resultModel = extractResultModel(processorModel, instance,
|
||||||
memoryModel, fieldNames);
|
// fieldName);
|
||||||
resultModel.setTime(memoryModel.getSamplingTime());
|
// if (resultModel != null)
|
||||||
resultModel.setFinished(memoryModel.isFinished());
|
// resultModels.add(resultModel);
|
||||||
resultModels.add(resultModel);
|
// } catch (NoSuchFieldException | IllegalArgumentException e) {
|
||||||
} catch (NoSuchFieldException e) {
|
// // TODO Auto-generated catch block
|
||||||
// TODO Auto-generated catch block
|
// logger.info(ExceptionLog.getStackTrace(e));
|
||||||
logger.info(ExceptionLog.getStackTrace(e));
|
// }
|
||||||
}
|
//
|
||||||
|
// }
|
||||||
}
|
//
|
||||||
}
|
// }
|
||||||
return resultModels;
|
// return resultModels;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private ResultModel extractResultModel(ProcessorModel processorModel,
|
// public List<ResultModel> extractCpuResult(
|
||||||
String instance, String fieldName) throws NoSuchFieldException,
|
// List<ProcessorModel> processorModels, String fieldName) {
|
||||||
IllegalArgumentException {
|
// if (processorModels == null)
|
||||||
List<String> fieldNames = new ArrayList<String>();
|
// return null;
|
||||||
fieldNames.add(fieldName);
|
// List<ResultModel> resultModels = new ArrayList<ResultModel>();
|
||||||
if (processorModel.getProcessorModelList() == null) {
|
// List<String> fieldNames = new ArrayList<String>();
|
||||||
return null;
|
// fieldNames.add(fieldName);
|
||||||
}
|
// for (ProcessorModel processorModel : processorModels) {
|
||||||
for (ProcessorModelChild processorModelChild : processorModel
|
// if (processorModel != null) {
|
||||||
.getProcessorModelList()) {
|
// ResultModel resultModel;
|
||||||
if (processorModelChild.getInstance().equalsIgnoreCase(instance)) {
|
// try {
|
||||||
ResultModel resultModel = ChangeToResultModel.getResultModel(
|
// resultModel = ChangeToResultModel.getResultModel(
|
||||||
processorModelChild, fieldNames);
|
// processorModel, fieldNames);
|
||||||
resultModel.setFinished(false);
|
// resultModel.setTime(processorModel.getSamplingTime());
|
||||||
resultModel.setTime(processorModel.getSamplingTime());
|
// resultModel.setFinished(processorModel.isFinished());
|
||||||
return resultModel;
|
// resultModels.add(resultModel);
|
||||||
}
|
// } catch (NoSuchFieldException e) {
|
||||||
}
|
// // TODO Auto-generated catch block
|
||||||
logger.info("no such cpu instance");
|
// logger.info(ExceptionLog.getStackTrace(e));
|
||||||
return null;
|
// }
|
||||||
}
|
//
|
||||||
|
// }
|
||||||
public List<String> getCpuList(
|
// }
|
||||||
@ModelAttribute("accessToken") String accessToken,
|
// return resultModels;
|
||||||
@RequestParam("testPlanId") String testPlanId,
|
// }
|
||||||
@RequestParam String ip, String port) {
|
//
|
||||||
try {
|
// public List<ResultModel> extractResultModelList(
|
||||||
MonitorProcessorResponseModel monitorProcessorResponseModel = getCpus(
|
// List<MemoryModel> memoryModels, String fieldName) {
|
||||||
accessToken, testPlanId, ip, port, "0");
|
// if (memoryModels == null)
|
||||||
|
// return null;
|
||||||
ProcessorModel processorModel = null;
|
// List<ResultModel> resultModels = new ArrayList<ResultModel>();
|
||||||
List<ProcessorModel> processorModels = monitorProcessorResponseModel
|
// List<String> fieldNames = new ArrayList<String>();
|
||||||
.getProcessorModels();
|
// fieldNames.add(fieldName);
|
||||||
if (processorModels.size() > 0) {
|
// for (MemoryModel memoryModel : memoryModels) {
|
||||||
processorModel = processorModels.get(0);
|
// if (memoryModel != null) {
|
||||||
}
|
// ResultModel resultModel;
|
||||||
|
// try {
|
||||||
else {
|
// resultModel = ChangeToResultModel.getResultModel(
|
||||||
return new ArrayList<String>();
|
// memoryModel, fieldNames);
|
||||||
}
|
// resultModel.setTime(memoryModel.getSamplingTime());
|
||||||
|
// resultModel.setFinished(memoryModel.isFinished());
|
||||||
List<String> cpuList = new ArrayList<String>();
|
// resultModels.add(resultModel);
|
||||||
for (ProcessorModelChild processorModelChild : processorModel
|
// } catch (NoSuchFieldException e) {
|
||||||
.getProcessorModelList()) {
|
// // TODO Auto-generated catch block
|
||||||
cpuList.add(processorModelChild.getInstance());
|
// logger.info(ExceptionLog.getStackTrace(e));
|
||||||
}
|
// }
|
||||||
return cpuList;
|
//
|
||||||
} catch (NullPointerException e) {
|
// }
|
||||||
logger.info(ExceptionLog.getStackTrace(e));
|
// }
|
||||||
return new LinkedList<String>();
|
// return resultModels;
|
||||||
}
|
// }
|
||||||
}
|
//
|
||||||
|
// private ResultModel extractResultModel(ProcessorModel processorModel,
|
||||||
public MonitorProcessorResponseModel getCpus(
|
// String instance, String fieldName) throws NoSuchFieldException,
|
||||||
@ModelAttribute("accessToken") String accessToken,
|
// IllegalArgumentException {
|
||||||
String testPlanId, String ip, String port, String startTime) {
|
// List<String> fieldNames = new ArrayList<String>();
|
||||||
MonitorProcessorResponseModel model = this.getMonitorMessager()
|
// fieldNames.add(fieldName);
|
||||||
.porcessor(accessToken, testPlanId, ip, port, startTime);
|
// if (processorModel.getProcessorModelList() == null) {
|
||||||
return model;
|
// 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>
|
<value>userTimePercent</value>
|
||||||
</children>
|
</children>
|
||||||
<name>cpu</name>
|
<name>cpu</name>
|
||||||
<value>Cpu</value>
|
<value>cpu</value>
|
||||||
</result>
|
</result>
|
||||||
<result>
|
<result>
|
||||||
<children>
|
<children>
|
||||||
|
@ -31,11 +31,11 @@
|
||||||
<value>pagesOutputPerSecond</value>
|
<value>pagesOutputPerSecond</value>
|
||||||
</children>
|
</children>
|
||||||
<children>
|
<children>
|
||||||
<name>可用内存(kb)</name>
|
<name>可用内存(KB)</name>
|
||||||
<value>availableKiloBytes</value>
|
<value>availableKiloBytes</value>
|
||||||
</children>
|
</children>
|
||||||
<children>
|
<children>
|
||||||
<name>总容量(kb)</name>
|
<name>总容量(KB)</name>
|
||||||
<value>totalKiloBytes</value>
|
<value>totalKiloBytes</value>
|
||||||
</children>
|
</children>
|
||||||
<children>
|
<children>
|
||||||
|
@ -43,11 +43,59 @@
|
||||||
<value>memoryUsedPercent</value>
|
<value>memoryUsedPercent</value>
|
||||||
</children>
|
</children>
|
||||||
<children>
|
<children>
|
||||||
<name>交换内存(kb)</name>
|
<name>交换内存(KB)</name>
|
||||||
<value>swapKiloBytes</value>
|
<value>swapKiloBytes</value>
|
||||||
</children>
|
</children>
|
||||||
<name>内存</name>
|
<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>
|
</result>
|
||||||
</results>
|
</results>
|
||||||
</testResult>
|
</testResult>
|
||||||
|
|
|
@ -20,8 +20,8 @@ $(function() {
|
||||||
// behaviorResult.getResult(testPlanId, getScriptList(testPlanId));
|
// behaviorResult.getResult(testPlanId, getScriptList(testPlanId));
|
||||||
// // var pageResult = new PageResult();
|
// // var pageResult = new PageResult();
|
||||||
// pageResult.getResult(testPlanId, getScriptList(testPlanId));
|
// pageResult.getResult(testPlanId, getScriptList(testPlanId));
|
||||||
var urlContentTypeDistribution = new UrlContentTypeDistribution(
|
// var urlContentTypeDistribution = new UrlContentTypeDistribution(
|
||||||
"url-distribution", testPlanId);
|
// "url-distribution", testPlanId);
|
||||||
});
|
});
|
||||||
function getTestInfo(testPlanId) {
|
function getTestInfo(testPlanId) {
|
||||||
var testPlan;
|
var testPlan;
|
||||||
|
|
|
@ -7,7 +7,6 @@ import static org.junit.Assert.*;
|
||||||
import org.bench4q.share.helper.MarshalHelper;
|
import org.bench4q.share.helper.MarshalHelper;
|
||||||
import org.bench4q.share.models.master.TestPlanResponseModel;
|
import org.bench4q.share.models.master.TestPlanResponseModel;
|
||||||
import org.bench4q.share.models.master.TestPlanResultModel;
|
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.share.models.master.statistics.ScriptBehaviorsBriefModel;
|
||||||
import org.bench4q.web.masterMessager.TestPlanMessager;
|
import org.bench4q.web.masterMessager.TestPlanMessager;
|
||||||
|
|
||||||
|
@ -27,7 +26,6 @@ public class TestPlanMessageTest extends MessagerTestBase {
|
||||||
private String baseUrl = "/testPlan";
|
private String baseUrl = "/testPlan";
|
||||||
private String testPlanId = "testPlanId";
|
private String testPlanId = "testPlanId";
|
||||||
private String scriptId = "scriptId";
|
private String scriptId = "scriptId";
|
||||||
private String duationBegin = "duationBegin";
|
|
||||||
|
|
||||||
public TestPlanMessager getTestPlanMessager() {
|
public TestPlanMessager getTestPlanMessager() {
|
||||||
return testPlanMessager;
|
return testPlanMessager;
|
||||||
|
|
Loading…
Reference in New Issue