1
0
mirror of https://github.com/newnius/YAO-portal.git synced 2025-12-13 00:56:44 +00:00

update UI, add pool status

This commit is contained in:
2019-04-29 21:04:19 +08:00
parent 75657a7d6d
commit e80f1c8480
4 changed files with 153 additions and 83 deletions

View File

@@ -99,6 +99,10 @@ switch ($action) {
$res = summary_get();
break;
case 'summary_get_pool_history':
$res = summary_get_pool_history();
break;
case 'task_logs':
$task = new CRObject();
$task->set('job', cr_get_GET('job'));

View File

@@ -171,6 +171,28 @@ function summary_get()
return $res;
}
function summary_get_pool_history()
{
if (!AccessController::hasAccess(Session::get('role', 'visitor'), 'system.summary')) {
$res['errno'] = Code::NO_PRIVILEGE;
return $res;
}
$spider = new Spider();
$spider->doGet(YAO_SCHEDULER_ADDR . '?action=pool_status_history');
$msg = json_decode($spider->getBody(), true);
if ($msg['code'] !== 0) {
$res['errno'] = $msg['code'] !== null ? $msg['code'] : Code::UNKNOWN_ERROR;
$res['msg'] = $msg['error'];
return $res;
}
$res['data'] = $msg['data'];
$res['errno'] = Code::SUCCESS;
return $res;
}
function task_logs(CRObject $job)
{
if (!AccessController::hasAccess(Session::get('role', 'visitor'), 'job.list')) {

View File

@@ -72,8 +72,8 @@ function resourceResponseHandler(res) {
$.each(res["resources"], function (i, node) {
var item = {
'host': node.host,
'CPU': '-',
'MEM': '-',
'CPU': node.cpu_num,
'MEM': node.mem_available + ' / ' + node.mem_total + ' (GB)',
'GPU': node.status.length,
'status': node.status
};

View File

@@ -21,32 +21,6 @@ function summary_render() {
$("#modal-msg").modal('show');
}
/* CPU Load */
ctx_cpu.canvas.height = 200;
new Chart(ctx_cpu, {
"type": "line",
"data": {
"labels": ["January", "February", "March", "April", "May", "June", "July"],
"datasets": [{
"label": "My First Data set",
"data": [2, 0.5, 1.5, 0.81, 1.56, 1.55, 1.40],
"fill": true,
"borderColor": "rgb(75, 192, 192)",
"lineTension": 0.1
}]
},
"options": {
title: {
display: true,
text: 'GPU Load'
},
legend: {
display: false
},
maintainAspectRatio: false
}
});
/* Jobs */
var data = {
@@ -72,58 +46,6 @@ function summary_render() {
}
});
/* Mem Using */
ctx_mem.canvas.height = 200;
new Chart(ctx_mem, {
"type": "line",
"data": {
"labels": ["January", "February", "March", "April", "May", "June", "July"],
"datasets": [{
"label": "My First Data set",
"data": [2, 0.5, 1.5, 0.81, 1.56, 1.55, 1.40],
"fill": true,
"borderColor": "rgb(75, 192, 192)",
"lineTension": 0.1
}]
},
"options": {
title: {
display: true,
text: 'MEM Using'
},
legend: {
display: false
},
maintainAspectRatio: false
}
});
/* GPU Util */
ctx_gpu_util.canvas.height = 200;
new Chart(ctx_gpu_util, {
"type": "line",
"data": {
"labels": ["January", "February", "March", "April", "May", "June", "July"],
"datasets": [{
"label": "My First Data set",
"data": [2, 0.5, 1.5, 0.81, 1.56, 1.55, 1.40],
"fill": true,
"borderColor": "rgb(75, 192, 192)",
"lineTension": 0.1
}]
},
"options": {
title: {
display: true,
text: 'GPU Utilization'
},
legend: {
display: false
},
maintainAspectRatio: false
}
});
/* GPUs */
var data2 = {
datasets: [{
@@ -148,16 +70,138 @@ function summary_render() {
}
});
});
ajax.fail(function (jqXHR, textStatus) {
$("#modal-msg-content").html("Request failed : " + jqXHR.statusText);
$("#modal-msg").modal('show');
});
var ajax_pool = $.ajax({
url: window.config.BASE_URL + "/service?action=summary_get_pool_history",
type: 'GET',
data: {}
});
ajax_pool.done(function (res) {
if (res["errno"] !== 0) {
$("#modal-msg-content").html(res["msg"]);
$("#modal-msg").modal('show');
}
var cpu_util = [];
var cpu_total = [];
var mem_available = [];
var mem_total = [];
var mem_using = [];
var gpu_util = [];
var gpu_total = [];
var gpu_mem_available = [];
var gpu_mem_total = [];
var gpu_mem_using = [];
var timestamps = [];
$.each(res["data"], function (i, item) {
cpu_util.push(item['cpu_util'].toFixed(2));
cpu_total.push(item['cpu_total']);
mem_available.push(item['mem_available']);
mem_total.push(item['mem_total']);
mem_using.push(item['mem_total'] - item['mem_available']);
gpu_util.push(item['gpu_util']);
gpu_total.push(item['gpu_total']);
gpu_mem_available.push(item['gpu_mem_available']);
gpu_mem_total.push(item['gpu_mem_total']);
gpu_mem_using.push(item['gpu_mem_total'] - item['gpu_mem_available']);
timestamps.push(item['ts']);
});
/* CPU Load */
ctx_cpu.canvas.height = 200;
new Chart(ctx_cpu, {
"type": "line",
"data": {
"labels": timestamps,
"datasets": [{
"label": "My First Data set",
"data": cpu_util,
"fill": true,
"borderColor": "rgb(75, 192, 192)",
"lineTension": 0.1
}]
},
"options": {
title: {
display: true,
text: 'CPU Load'
},
legend: {
display: false
},
maintainAspectRatio: false
}
});
/* Mem Using */
ctx_mem.canvas.height = 200;
new Chart(ctx_mem, {
"type": "line",
"data": {
"labels": timestamps,
"datasets": [{
"label": "My First Data set",
"data": mem_using,
"fill": true,
"borderColor": "rgb(75, 192, 192)",
"lineTension": 0.1
}]
},
"options": {
title: {
display: true,
text: 'MEM Using'
},
legend: {
display: false
},
maintainAspectRatio: false
}
});
/* GPU Util */
ctx_gpu_util.canvas.height = 200;
new Chart(ctx_gpu_util, {
"type": "line",
"data": {
"labels": timestamps,
"datasets": [{
"label": "My First Data set",
"data": gpu_util,
"fill": true,
"borderColor": "rgb(75, 192, 192)",
"lineTension": 0.1
}]
},
"options": {
title: {
display: true,
text: 'GPU Utilization'
},
legend: {
display: false
},
maintainAspectRatio: false
}
});
/* GPU Mem Using */
ctx_gpu_mem.canvas.height = 200;
new Chart(ctx_gpu_mem, {
"type": "line",
"data": {
"labels": ["January", "February", "March", "April", "May", "June", "July"],
"labels": timestamps,
"datasets": [{
"label": "My First Data set",
"data": [2, 0.5, 1.5, 0.81, 1.56, 1.55, 1.40],
"data": gpu_mem_using,
"fill": true,
"borderColor": "rgb(75, 192, 192)",
"lineTension": 0.1
@@ -175,7 +219,7 @@ function summary_render() {
}
});
});
ajax.fail(function (jqXHR, textStatus) {
ajax_pool.fail(function (jqXHR, textStatus) {
$("#modal-msg-content").html("Request failed : " + jqXHR.statusText);
$("#modal-msg").modal('show');
});