Merge branch 'pieChart' of steve/monitor into community

community
Steve L. Nyemba 7 years ago committed by Gogs
commit af80dd6e16

@ -1,4 +1,3 @@
type = ['','info','success','warning','danger']; type = ['','info','success','warning','danger'];
dashboard = { dashboard = {
@ -22,31 +21,7 @@ dashboard = {
getData.done(function(results) { getData.done(function(results) {
var data = JSON.parse(results) var data = JSON.parse(results)
var app = data['Chrome']; var app = data['Chrome'];
console.log('data...',data)
function getCpuUsage (app){
cpu_usage = []
for (var i in app){
cpu_usage.push(app[i].cpu_usage)
}
return cpu_usage
}
function getMemoryUsage (app){
memory_usage = []
for (var i in app){
memory_usage.push(app[i].memory_usage)
}
return memory_usage
}
function getStatus (app){
statusList = []
for (var i in app){
statusList.push(app[i].status)
}
return statusList
}
// monitoring apps chart // monitoring apps chart
var dataChart = { var dataChart = {
@ -110,64 +85,18 @@ dashboard = {
Chartist.Line('#chartActivity', data, options, responsiveOptions); Chartist.Line('#chartActivity', data, options, responsiveOptions);
status = getStatus(app) var getStatus = $.get('1/get/summary/app_status');
statusList = status.split(','); getStatus.done(function(results) {
var data = JSON.parse(results)
statusByNum = getStatusByType(statusList) let getStatusList = []
getStatusList.push(data.idle)
function getStatusByType(statusList){ getStatusList.push(data.crash)
running = 0; getStatusList.push(data.running)
idle = 0; Chartist.Pie('#chartPreferences', {
crash = 0; labels: getStatusList,
series: getStatusList
for (var n in statusList){ });
if (statusList[n] == 'running'){ }) /// end getStatus
running += 1;
};
if (statusList[n] == 'idle'){
idle += 1;
};
if (statusList[n] == 'crash'){
crash += 1;
};
}
statusList = [running, idle, crash];
return statusList
}
percentage = getStatusPercent(statusByNum);
function getStatusPercent(statusByNum){
let total = 0
for (var i in statusByNum){
total += statusByNum[i];
}
percent = []
for (var i in statusByNum){
percent.push(total / statusByNum[i])
}
total = 100
let percentage = []
for (var i in percent){
percentage.push(total/percent[i])
}
for (var i in percentage){
if (percentage[i] == 0){
percentage.pop(percentage[i]);
}
}
return percentage
}
for (i in percentage){
percentage[i] = percentage[i].toString()+'%';
}
Chartist.Pie('#chartPreferences', {
labels: [1,1,1],
series: [1,2,3]
});
}) })
}, },
// End chartist function // End chartist function
@ -230,8 +159,6 @@ g.summary.factory = function (url,pointer) {
object.callback = function (r) { object.callback = function (r) {
r = JSON.parse(r.responseText) r = JSON.parse(r.responseText)
pointer(r) pointer(r)
console.log(r)
//monitorStatus(r.idle, r.crash, r.running)
//observer.notify() //observer.notify()

Loading…
Cancel
Save