|
|
@ -365,91 +365,86 @@ monitor.folders.render = {}
|
|
|
|
monitor.folders.render.init = function (data) {
|
|
|
|
monitor.folders.render.init = function (data) {
|
|
|
|
monitor.folders.render.summary(data)
|
|
|
|
monitor.folders.render.summary(data)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
monitor.folders.render.details = function (data) {
|
|
|
|
monitor.folders.show = {}
|
|
|
|
//
|
|
|
|
monitor.folders.show.plan = function () {
|
|
|
|
// We need to normalize the data at this point so as to be able to show it all in the same chart
|
|
|
|
$('#folder_summary').slideUp(function () {
|
|
|
|
// jx.math.scale
|
|
|
|
$('#folder_plan').slideDown()
|
|
|
|
//
|
|
|
|
})
|
|
|
|
var m = jx.utils.vector(['x','y'],data.age)
|
|
|
|
|
|
|
|
var x_max_age = jx.math.max(m[0])
|
|
|
|
|
|
|
|
var y_max_age = jx.math.max(m[1])
|
|
|
|
|
|
|
|
m = jx.math.scale(m)
|
|
|
|
|
|
|
|
data.age = jx.utils.patterns.visitor(m,function(row){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {x:parseFloat(row[0].toFixed(3)),y:parseFloat(row[1].toFixed(3))}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var m = jx.utils.vector(['x','y'],data.size)
|
|
|
|
|
|
|
|
var x_max_size = jx.math.max(m[0])
|
|
|
|
|
|
|
|
var y_max_size = jx.math.max(m[1])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m = jx.math.scale(m)
|
|
|
|
|
|
|
|
data.size = jx.utils.patterns.visitor(m,function(row){
|
|
|
|
|
|
|
|
return {x:parseFloat(row[0].toFixed(3)),y:parseFloat(row[1].toFixed(3))}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
}
|
|
|
|
// The datasets need to be sorted by x ...
|
|
|
|
monitor.folders.show.grid = function () {
|
|
|
|
//
|
|
|
|
$('#folder_plan').slideUp(function () {
|
|
|
|
var Fn = function(a,b){
|
|
|
|
$('#folder_summary').slideDown()
|
|
|
|
return a.x - b.x
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
data.age = data.age.sort(Fn)
|
|
|
|
}
|
|
|
|
data.size= data.size.sort(Fn)
|
|
|
|
/***
|
|
|
|
|
|
|
|
* This function is designed to establish a folder clean up strategy i.e :
|
|
|
|
// data.size = data.size.splice(0,data.age.length)
|
|
|
|
* - We will look for anomalies given age,file size
|
|
|
|
|
|
|
|
* - We will also look for where most of the data is distributed (mode)
|
|
|
|
var context = jx.dom.get.instance('CANVAS')
|
|
|
|
*/
|
|
|
|
var frame = $('#chartfolder')
|
|
|
|
monitor.folders.render.details = function (folder,data) {
|
|
|
|
jx.dom.set.value('chartfolder', '')
|
|
|
|
//
|
|
|
|
context.width = $(frame).width()
|
|
|
|
// We need to normalize the data at this point so as to be able to show it all in the same chart
|
|
|
|
context.height= $(frame).height()
|
|
|
|
// jx.math.scale x: counts, y: measure ment
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
var r = [data.age, data.size]
|
|
|
|
|
|
|
|
var plans = []
|
|
|
|
|
|
|
|
for (var i in r) {
|
|
|
|
|
|
|
|
var xy = r[i]
|
|
|
|
|
|
|
|
var mode = jx.math.mode(jx.utils.vector('x', xy))
|
|
|
|
|
|
|
|
var yvalues = jx.utils.patterns.visitor(xy, function (row) {
|
|
|
|
|
|
|
|
if (row.x == mode) {
|
|
|
|
|
|
|
|
return row.y
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
var sd = jx.math.sd(yvalues)
|
|
|
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
|
|
|
prefix = 'age'
|
|
|
|
|
|
|
|
var mean = jx.math.mean(yvalues)
|
|
|
|
|
|
|
|
var max = (mean + (1.5 * sd))
|
|
|
|
|
|
|
|
if (mean > 30 && mean < 365) {
|
|
|
|
|
|
|
|
divide_by = 30
|
|
|
|
|
|
|
|
units = 'MONTHS'
|
|
|
|
|
|
|
|
} else if (mean > 365) {
|
|
|
|
|
|
|
|
divide_by=365
|
|
|
|
|
|
|
|
units = 'YEARS'
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
divide_by = 1
|
|
|
|
|
|
|
|
units = 'DAYS'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
prefix = 'size'
|
|
|
|
|
|
|
|
var mean = jx.math.sum(yvalues)
|
|
|
|
|
|
|
|
var max = 0// (mean + (1.5 * sd))
|
|
|
|
|
|
|
|
if (mean > 1000) {
|
|
|
|
|
|
|
|
divide_by = 1000
|
|
|
|
|
|
|
|
units = 'GB'
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
divide_by = 1
|
|
|
|
|
|
|
|
units = 'MB'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var conf = { type: 'line',responsive:true }
|
|
|
|
}
|
|
|
|
conf.data = {}
|
|
|
|
|
|
|
|
conf.options = { legend: { position: 'bottom' } }
|
|
|
|
|
|
|
|
conf.options.scales = {}
|
|
|
|
|
|
|
|
conf.options.scales.yAxes = [
|
|
|
|
|
|
|
|
{id:'0',scaleLabel:{display:true,labelString:'% DAYS/MB'},ticks:{min:0,beginAtZero:true},gridLines: {display:false}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]
|
|
|
|
//
|
|
|
|
conf.options.scales.xAxes = [{ ticks:{min:0,max:1},gridLines: {display:false}}]
|
|
|
|
// We need to assess the outliars i.e too old, too large
|
|
|
|
conf.options.tooltips = {}
|
|
|
|
//
|
|
|
|
conf.options.tooltips.callbacks = {}
|
|
|
|
y = jx.utils.vector('y', xy)
|
|
|
|
conf.options.tooltips.callbacks.label = function(item,rec){
|
|
|
|
var _mean = jx.math.mean(y)
|
|
|
|
|
|
|
|
var _sd = jx.math.sd(y)
|
|
|
|
// var r = data.datasets[item.datasetIndex].data[item.index]
|
|
|
|
var outlier = _mean < mean || max > (_mean + (1.5 * _sd))
|
|
|
|
if(item.datasetIndex == 0){
|
|
|
|
|
|
|
|
|
|
|
|
plans.push({ 'label': prefix, 'max': max, 'sd': sd, 'mean': mean, 'count': yvalues.length, 'outlier': outlier })
|
|
|
|
r = data.age[item.index]
|
|
|
|
jx.dom.set.value(prefix + '_count', yvalues.length)
|
|
|
|
xmax = x_max_age
|
|
|
|
jx.dom.set.value(prefix + '_value', (mean/divide_by).toFixed(2))
|
|
|
|
ymax = y_max_age
|
|
|
|
jx.dom.set.value(prefix+'_units',units)
|
|
|
|
units = "DAYS"
|
|
|
|
monitor.folders.show.plan()
|
|
|
|
}else{
|
|
|
|
|
|
|
|
r = data.size[item.index]
|
|
|
|
}
|
|
|
|
xmax = x_max_size
|
|
|
|
|
|
|
|
ymax = y_max_size
|
|
|
|
|
|
|
|
units = "MB"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(r)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 'WTF'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var age = {yAxisID:'0', label: 'File Age (Days)', data:data.age ,borderColor:COLORS[187],fill:true,borderWidth:1}
|
|
|
|
|
|
|
|
var size = {yAxisID:'0',label : 'File Size (MB)',data:data.size,borderColor:COLORS[32],fill:true,borderWidth:1}
|
|
|
|
|
|
|
|
// // age.data = [{ x: 10, y: 30 }, {x:20,y:60}]
|
|
|
|
|
|
|
|
// size.data= data.size
|
|
|
|
|
|
|
|
age.data = data.age
|
|
|
|
|
|
|
|
x_ = jx.utils.vector('x', age.data)
|
|
|
|
|
|
|
|
z_ = jx.utils.vector('x',size.data)
|
|
|
|
|
|
|
|
conf.data.labels = jx.utils.unique(jx.math.sets.union(x_,z_)).sort()
|
|
|
|
|
|
|
|
conf.data.datasets = [age,size]//,age]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jx.dom.set.value('folder_name', folder)
|
|
|
|
|
|
|
|
|
|
|
|
jx.dom.append('chartfolder',context)
|
|
|
|
|
|
|
|
var chart = new Chart(context,conf)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -482,14 +477,14 @@ monitor.folders.render.summary = function (data) {
|
|
|
|
return {y:row[0],x:row[1]}
|
|
|
|
return {y:row[0],x:row[1]}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
monitor.folders.render.details({age:age,size:size})
|
|
|
|
monitor.folders.render.details(item.label,{age:age,size:size})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// @TODO Add the units in days just in case
|
|
|
|
// @TODO Add the units in days just in case
|
|
|
|
options.autoload = true
|
|
|
|
options.autoload = true
|
|
|
|
options.fields = [
|
|
|
|
options.fields = [
|
|
|
|
{ name: 'label', type: 'text', title: "Folder Name", headercss: "small bold", css: "small"},
|
|
|
|
{ name: 'label', type: 'text', title: "Folder Name", headercss: "small bold", css: "small"},
|
|
|
|
{ name: "summary.age", type: "number", title: "Age (DAYS)", headercss: "small bold" , width:'64px'},
|
|
|
|
|
|
|
|
{ name: "summary.size", type: "number", title: "Size (MB)", type: "number", headercss: "small bold" },
|
|
|
|
{ name: "summary.size", type: "number", title: "Size (MB)", type: "number", headercss: "small bold" },
|
|
|
|
{ name: "summary.count", type: "number", title: "File Count", type: "number", headercss: "small bold" }
|
|
|
|
{ name: "summary.count", type: "number", title: "File Count", type: "number", headercss: "small bold" }
|
|
|
|
]
|
|
|
|
]
|
|
|
|