|
|
|
@ -25,7 +25,7 @@ monitor.processes.init = function(x){
|
|
|
|
|
frame.className = 'menu-item'
|
|
|
|
|
frame.onclick = function () {
|
|
|
|
|
monitor.processes.render(this.label, this.data);
|
|
|
|
|
monitor.processes.trend.init(this.label)
|
|
|
|
|
//monitor.processes.trend.init(this.label)
|
|
|
|
|
}
|
|
|
|
|
jx.dom.append('menu',frame)
|
|
|
|
|
})
|
|
|
|
@ -50,6 +50,12 @@ monitor.processes.render = function(label,data) {
|
|
|
|
|
|
|
|
|
|
return 'small'
|
|
|
|
|
}
|
|
|
|
|
options.rowClick = function(args){
|
|
|
|
|
var item = args.item
|
|
|
|
|
var id = jx.dom.get.value('latest_processes_label')
|
|
|
|
|
var app = item.label
|
|
|
|
|
monitor.processes.trend.init(id,app)
|
|
|
|
|
}
|
|
|
|
|
options.autoload = true
|
|
|
|
|
options.fields = [{name:'label',type:'text',title:"Process",headercss:"small bold",css:"small"},{name:"cpu_usage",type:"number",title:"CPU", headercss:"small bold"},{name:"memory_usage",type:"text",title:"Mem. Used",type:"number",headercss:"small bold"},{name:"memory_available",type:"number",title:"Mem. Avail",headercss:"small bold"},
|
|
|
|
|
{name:"status",type:"text",title:"Status",headercss:"small bold",align:"center"}
|
|
|
|
@ -60,68 +66,61 @@ monitor.processes.render = function(label,data) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
monitor.processes.trend = {}
|
|
|
|
|
monitor.processes.trend.init = function (label) {
|
|
|
|
|
monitor.processes.trend.init = function (label,app) {
|
|
|
|
|
var httpclient = HttpClient.instance()
|
|
|
|
|
var uri = '/trends?id='+label
|
|
|
|
|
var uri = '/trends?id='+label+'&app='+encodeURIComponent(app)
|
|
|
|
|
httpclient.get(uri, function (x) {
|
|
|
|
|
var logs = JSON.parse(x.responseText)
|
|
|
|
|
console.log(logs)
|
|
|
|
|
|
|
|
|
|
// jx.dom.set.attribute(label,'logs',logs)
|
|
|
|
|
monitor.processes.trend.render(logs)
|
|
|
|
|
monitor.processes.trend.render(logs,null,app)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
monitor.processes.trend.render = function (logs, key) {
|
|
|
|
|
monitor.processes.trend.render = function (logs, key,label) {
|
|
|
|
|
if (key == null) {
|
|
|
|
|
key = 'memory_usage'
|
|
|
|
|
}
|
|
|
|
|
var context = $('#trends_chart')
|
|
|
|
|
var conf = { type: 'line' }
|
|
|
|
|
var conf = { type: 'line',responsive:true,maintainAspectRatio:true }
|
|
|
|
|
conf.data = {}
|
|
|
|
|
conf.options = { legend: { position: 'bottom' } }
|
|
|
|
|
conf.options.scales = {}
|
|
|
|
|
conf.options.scales.yAxes = [{ title: {display:true,text:key},gridLines: {display:false}}]
|
|
|
|
|
conf.options.scales.yAxes = [ {ticks:{min:0,beginAtZero:true},gridLines: {display:false}}]
|
|
|
|
|
conf.options.scales.xAxes = [
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
type: 'time',
|
|
|
|
|
gridLines: {display:false},
|
|
|
|
|
unitStepSize:25,
|
|
|
|
|
time: {
|
|
|
|
|
format:'dd-MMM HH:mm'
|
|
|
|
|
format:'DD-MMM HH:mm'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
]
|
|
|
|
|
// conf.data.labels = x_axis
|
|
|
|
|
var p = jx.utils.keys(logs)
|
|
|
|
|
conf.data.datasets = [ ]
|
|
|
|
|
var labels = []
|
|
|
|
|
var i = 0;
|
|
|
|
|
|
|
|
|
|
for (id in logs) {
|
|
|
|
|
var serie = {}
|
|
|
|
|
serie.label = id
|
|
|
|
|
serie.data = jx.utils.patterns.visitor(logs[id], function (item) {
|
|
|
|
|
// x = parseFloat(item['hour'] + '.' + item['minute']).toFixed(2)
|
|
|
|
|
x = new Date(item.year,item.month-1,item.day,item.hour,item.minute)
|
|
|
|
|
y = item[key]
|
|
|
|
|
labels.push(x)
|
|
|
|
|
console.log([item.day,item.hour,item.minute])
|
|
|
|
|
return {x:x,y:y}
|
|
|
|
|
})
|
|
|
|
|
var x_axis = []
|
|
|
|
|
var values = jx.utils.patterns.visitor(logs,function(item){
|
|
|
|
|
x = new Date(item.year,item.month-1,item.day,item.hour,item.minute)
|
|
|
|
|
y = item[key]
|
|
|
|
|
x_axis.push(x)
|
|
|
|
|
|
|
|
|
|
serie.backgroundColor = ['#ffffff']
|
|
|
|
|
serie.borderColor = COLORS[i]
|
|
|
|
|
serie.borderWidth = 1
|
|
|
|
|
++i
|
|
|
|
|
conf.data.datasets.push(serie)
|
|
|
|
|
return {x:x,y:y}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
var serie = {label:label,data:values}
|
|
|
|
|
i = parseInt(Math.random() * (COLORS.length - 1))
|
|
|
|
|
serie.backgroundColor = 'transparent'
|
|
|
|
|
serie.borderColor = COLORS[i]
|
|
|
|
|
serie.borderWidth = 1
|
|
|
|
|
serie.type = 'line'
|
|
|
|
|
conf.data.datasets.push(serie)
|
|
|
|
|
|
|
|
|
|
x_axis = jx.utils.unique(x_axis)
|
|
|
|
|
|
|
|
|
|
labels = jx.utils.unique(labels)
|
|
|
|
|
console.log(labels)
|
|
|
|
|
conf.data.labels = labels
|
|
|
|
|
conf.data.labels = x_axis
|
|
|
|
|
// console.log(conf)
|
|
|
|
|
var chart = new Chart(context,conf)
|
|
|
|
|
|
|
|
|
|