finish che chart of processor
This commit is contained in:
parent
4cf6fa5182
commit
d161aa0b9f
|
@ -40,7 +40,7 @@ public class MonitorController extends BaseControllerService {
|
|||
HttpResponse httpResponse = null;
|
||||
MonitorProcessorResponseModel monitorProcessorResponseModel;
|
||||
try {
|
||||
httpResponse = this.getHttpRequester().sendGet(this.getBaseUrl()+"//processorSUTInfo",
|
||||
httpResponse = this.getHttpRequester().sendGet(this.getBaseUrl()+"/processorSUTInfo",
|
||||
makeParamsMap(request, testplanID),
|
||||
this.makeAccessTockenMap(accessToken));
|
||||
if (httpResponse == null)
|
||||
|
|
|
@ -184,6 +184,7 @@ public class TestPlanActionController extends BaseControllerService {
|
|||
RunningScriptModel runningScriptModel = itr.next();
|
||||
ScriptIndexModel scriptIndexModel = new ScriptIndexModel();
|
||||
scriptIndexModel.setScriptId(runningScriptModel.getScriptId());
|
||||
System.out.println(runningScriptModel.getScriptId());
|
||||
String scriptName = this.getScriptService()
|
||||
.queryScript(runningScriptModel.getScriptId(), accessToken)
|
||||
.getName();
|
||||
|
|
|
@ -201,7 +201,9 @@ padding:10px;
|
|||
}
|
||||
.dataText{
|
||||
margin-top:50px;
|
||||
margin-right:50px;
|
||||
margin-right:auto;
|
||||
margin-left:30;
|
||||
|
||||
|
||||
}
|
||||
.btn-round{
|
||||
|
|
|
@ -1,73 +1,83 @@
|
|||
$(document).ready(
|
||||
function() {
|
||||
$("#testresult").treeview({});
|
||||
var scriptId;
|
||||
var scriptName;
|
||||
var ip;
|
||||
$.ajax({
|
||||
url : "getRunningInfo",
|
||||
type : "GET",
|
||||
cache : false,
|
||||
dataType : "json",
|
||||
success : function(data, status) {
|
||||
if (data != null) {
|
||||
scripts = data.scriptIndexModels;
|
||||
monitor = data.monitorModels;
|
||||
for ( var i = 0; i < scripts.length; i++) {
|
||||
$(document)
|
||||
.ready(
|
||||
function() {
|
||||
$("#testresult").treeview({});
|
||||
var scriptId;
|
||||
var scriptName;
|
||||
var ip;
|
||||
$
|
||||
.ajax({
|
||||
url : "getRunningInfo",
|
||||
type : "GET",
|
||||
cache : false,
|
||||
dataType : "json",
|
||||
success : function(data, status) {
|
||||
if (data != null) {
|
||||
scripts = data.scriptIndexModels;
|
||||
monitor = data.monitorModels;
|
||||
for ( var i = 0; i < scripts.length; i++) {
|
||||
scriptId = scripts[i].scriptId;
|
||||
scriptName = scripts[i].scriptName;
|
||||
addNodeToTree(scriptName,
|
||||
scriptName, "scripts");
|
||||
addContainer(scriptName);
|
||||
}
|
||||
for (i = 0; i < monitor.length; i++) {
|
||||
ip = monitor[i].hostName;
|
||||
port = monitor[i].port;
|
||||
|
||||
scriptId = scripts[i].scriptId;
|
||||
scriptName = scripts[i].scriptName;
|
||||
addNodeToTree(scriptName, scriptName, "scripts");
|
||||
addContainer(scriptName);
|
||||
}
|
||||
for (i = 0; i < monitor.length; i++) {
|
||||
ip = monitor[i].hostName;
|
||||
port = monitor[i].port;
|
||||
var ip_change = changeIpName(ip);
|
||||
addNodeToTree(ip_change, ip, "sut");
|
||||
addContainer(ip_change + "cpu");
|
||||
addContainer(ip_change + "memory");
|
||||
addContainer(ip_change + "network");
|
||||
}
|
||||
for ( var i = 0; i < scripts.length; i++) {
|
||||
scriptId = scripts[i].scriptId;
|
||||
scriptName = scripts[i].scriptName;
|
||||
scriptCharts[i] = new Highcharts.Chart(
|
||||
getChartOptions(scriptId, scriptName,
|
||||
"averageResponseTime"));
|
||||
}
|
||||
for ( var i = 0; i < monitor.length; i++) {
|
||||
|
||||
ip = monitor[i].hostName;
|
||||
var ip_change = changeIpName(ip);
|
||||
getCpuInstances();
|
||||
sutCharts[i] = new Highcharts.Chart(
|
||||
getChartOptions(monitor[i], ip_change
|
||||
+ "cpu", "processorTimePercent"));
|
||||
sutCharts[i] = new Highcharts.Chart(
|
||||
getChartOptions(monitor[i], ip_change
|
||||
+ "memory", ""));
|
||||
sutCharts[i] = new Highcharts.Chart(
|
||||
getChartOptions(monitor[i],ip_change
|
||||
+ "network", ""));
|
||||
}
|
||||
}
|
||||
processorList = getProcessorList(
|
||||
ip, port);
|
||||
sut_processorList[i] = processorList;
|
||||
var ip_change = changeIpName(ip);
|
||||
addNodeToTree(ip_change, ip, "sut");
|
||||
for ( var j = 0; j < processorList.length; j++) {
|
||||
addContainer(ip_change
|
||||
+ "cpu_"
|
||||
+ processorList[j].instance);
|
||||
}
|
||||
addContainer(ip_change + "memory");
|
||||
addContainer(ip_change + "network");
|
||||
}
|
||||
for ( var i = 0; i < scripts.length; i++) {
|
||||
scriptId = scripts[i].scriptId;
|
||||
scriptName = scripts[i].scriptName;
|
||||
new Highcharts.Chart(
|
||||
getChartOptions(scriptId,
|
||||
scriptName,
|
||||
"averageResponseTime"));
|
||||
}
|
||||
for ( var i = 0; i < monitor.length; i++) {
|
||||
ip = monitor[i].hostName;
|
||||
var ip_change = changeIpName(ip);
|
||||
var j;
|
||||
for (j = 0; j < sut_processorList[i].length; j++) {
|
||||
new Highcharts.Chart(
|
||||
getChartOptions(
|
||||
monitor[i],
|
||||
ip_change
|
||||
+ "cpu_"
|
||||
+ sut_processorList[i][j].instance,
|
||||
sut_processorList[i][j].instance
|
||||
+ ":processorTimePercent"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
error : function(request, status, error) {
|
||||
alert("An error occurred while loading the sut data:"
|
||||
+ error);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
error : function(request, status, error) {
|
||||
alert("An error occurred while loading the sut data:"
|
||||
+ error);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var scripts;
|
||||
var monitor;
|
||||
var finish_all = false;
|
||||
var scriptFinishCount = 0;
|
||||
var scriptCharts = [];
|
||||
var sutCharts = [];
|
||||
var cpuInstances = [];
|
||||
var sut_processorList = [];
|
||||
function addNodeToTree(name, name_show, treeNode) {
|
||||
var branches;
|
||||
branches = $(
|
||||
|
@ -84,27 +94,48 @@ function scriptClick(obj) {
|
|||
|
||||
for ( var i = 0; i < scripts.length; i++) {
|
||||
var chart = scripts[i].scriptName;
|
||||
$('#' + chart).hide();
|
||||
$('#text' + chart).hide();
|
||||
if(chart==chartName){
|
||||
$('#' + chartName).show();
|
||||
$('#text' + chartName).show();
|
||||
}
|
||||
else{
|
||||
$('#' + chart).hide();
|
||||
$('#text' + chart).hide();
|
||||
}
|
||||
}
|
||||
for ( var i = 0; i < monitor.length; i++) {
|
||||
|
||||
var chart = monitor[i].hostName;
|
||||
chart = changeIpName(chart);
|
||||
$('#' + chart).hide();
|
||||
$('#text' + chart).hide();
|
||||
var ip = monitor[i].hostName;
|
||||
ip = changeIpName(ip);
|
||||
if(ip==chartName)
|
||||
{
|
||||
for ( var j = 0; j < sut_processorList[i].length; j++) {
|
||||
var chart=ip;
|
||||
chart = chart + "cpu_" + sut_processorList[i][j].instance;
|
||||
$('#' + chart).show();
|
||||
$('#text' + chart).show();
|
||||
}
|
||||
}
|
||||
else{
|
||||
//chart = chart + "memory";
|
||||
for ( var j = 0; j < sut_processorList[i].length; j++) {
|
||||
var chart=ip;
|
||||
chart = chart + "cpu_" + sut_processorList[i][j].instance;
|
||||
$('#' + chart).hide();
|
||||
$('#text' + chart).hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$('#' + chartName).show();
|
||||
$('#text' + chartName).show();
|
||||
|
||||
}
|
||||
|
||||
function changeIpName(ip) {
|
||||
for ( var i = 0; i <= 3; i++)
|
||||
for(var i=0;i<3;i++)
|
||||
ip = ip.replace(".", "_");
|
||||
return ip;
|
||||
}
|
||||
function getChartOptions(params,containerName, title) {
|
||||
function getChartOptions(params, containerName, title) {
|
||||
var options = {
|
||||
chart : {
|
||||
renderTo : containerName,
|
||||
|
@ -166,9 +197,6 @@ function getChartOptions(params,containerName, title) {
|
|||
return options;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function scriptLoadFunction(scriptId, containerName, series) {
|
||||
var finish = false;
|
||||
var intervalId = null;
|
||||
|
@ -204,42 +232,38 @@ function scriptLoadFunction(scriptId, containerName, series) {
|
|||
}, 2000);
|
||||
}
|
||||
|
||||
function getCpuInstances(ip,port){
|
||||
|
||||
function getProcessorList(ip, port) {
|
||||
|
||||
var processorList = null;
|
||||
$.ajax({
|
||||
url : "getProcessorStatus",
|
||||
data : "ip=" + ip + "&port=" + port,
|
||||
type : "GET",
|
||||
async : false,
|
||||
cache : false,
|
||||
dataType : "json",
|
||||
success : function(data, status) {
|
||||
processorList = data.processorModelList;
|
||||
for ( var i = 0; i < processorList.length; i++) {
|
||||
cpuInsances[i] = processorList[i].instance;
|
||||
}
|
||||
},
|
||||
error : function(request, status, error) {
|
||||
alert("get the info about the instance of processor is wrong:"
|
||||
+ error);
|
||||
}
|
||||
});
|
||||
return processorList;
|
||||
}
|
||||
function sutLoadFunction(params, containerName, series) {
|
||||
|
||||
var ip = params.hostName;
|
||||
var port = params.port;
|
||||
var intervalId = null;
|
||||
var processorList = null;
|
||||
intervalId = setInterval(function() {
|
||||
|
||||
var intervalId = setInterval(function() {
|
||||
$.ajax({
|
||||
url : "getProcessorStatus",
|
||||
data : "ip=" + ip + "&port=" + port,
|
||||
data : "ip=" + params.hostName + "&port=" + params.port,
|
||||
type : "GET",
|
||||
cache : false,
|
||||
dataType : "json",
|
||||
success : function(data, status) {
|
||||
// alter(data)
|
||||
var processorList = null;
|
||||
processorList = data.processorModelList;
|
||||
for ( var i = 0; i < processorList.length; i++) {
|
||||
var processorModelChild = processorList[i];
|
||||
|
@ -250,6 +274,7 @@ function sutLoadFunction(params, containerName, series) {
|
|||
* parseFloat(processorModelChild.processorTimePercent);
|
||||
*/
|
||||
series.addPoint([ x, y ], true, false);
|
||||
outputProcessorBrief(containerName, processorModelChild);
|
||||
}
|
||||
if (finish_all == true)
|
||||
clearInterval(intervalId);
|
||||
|
@ -260,18 +285,6 @@ function sutLoadFunction(params, containerName, series) {
|
|||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* $.post("getProcessorStatus", { ip:ip, port:port }, function(data) {
|
||||
* if(data!=null){ $(data).find('processorModelChild').each(function(i){ var
|
||||
* instance=$(this).children('instance').text(); var
|
||||
* privilegedTimePercent=$(this).children('privilegedTimePercent').text();
|
||||
* var processorTimePercent=$(this).children('processorTimePercent').text();
|
||||
* var userTimePercent=$(this).children('userTimePercent').text(); var x =
|
||||
* (new Date()).getTime(); // current time if(processorTimePercent!=="NaN")
|
||||
* var y = parseFloat(processorTimePercent); else var y=0; alert(y);
|
||||
* series.addPoint([ x, y ], true, false); }); }
|
||||
*/
|
||||
// outputSciptBrief(containerName,jsonObject);
|
||||
, 2000);
|
||||
}
|
||||
|
||||
|
@ -289,12 +302,25 @@ function outputSciptBrief(containerName, jsonObject) {
|
|||
$('#text' + containerName).html(scriptBrief);
|
||||
}
|
||||
|
||||
function addContainer(scriptName) {
|
||||
|
||||
var html = "<div class='div-left' id=" + scriptName
|
||||
function outputProcessorBrief(containerName, jsonObject) {
|
||||
var name = "sut";
|
||||
if (containerName != name)
|
||||
var scriptBrief = "userTimePercent: "
|
||||
+ jsonObject.userTimePercent + "<br/>" + "privilegedTimePercent:"
|
||||
+ jsonObject.privilegedTimePercent + "<br/>" ;
|
||||
$('#text' + containerName).html(scriptBrief);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function addContainer(containerName) {
|
||||
|
||||
var html = "<div class='div-left' id=" + containerName
|
||||
+ " style='width: 600px; height: 300px;display:none'></div>"
|
||||
+ "<div class='div-right' ><div class='dataText' id=" + "text"
|
||||
+ scriptName + " style='display:none'></div></div>"
|
||||
+ containerName + " style='display:none'></div></div>"
|
||||
+ "<div style='clear:both;'></div>";
|
||||
$("#container").html($("#container").html() + html);
|
||||
}
|
Loading…
Reference in New Issue