bug fix for several files and context for ui

master
Steve L. Nyemba 8 years ago
parent 37aa0485c1
commit 1e531c07b5

@ -253,6 +253,8 @@ def get_folders():
d = gReader.read() d = gReader.read()
if 'folders' in d: if 'folders' in d:
d = d['folders'] d = d['folders']
index = len(d) -1
d = d[index]
else: else:
d = [] d = []

@ -357,8 +357,14 @@ monitor.folders.init = function () {
var httpclient = HttpClient.instance() var httpclient = HttpClient.instance()
httpclient.get('/folders', function (x) { httpclient.get('/folders', function (x) {
var r = JSON.parse(x.responseText) var r = JSON.parse(x.responseText)
r = r[0] var data = []
monitor.folders.render.init(r) for (var id in r) {
var item = r[id]
item.id = id
data = data.concat(item)
}
monitor.folders.render.init(data)
}) })
} }
monitor.folders.render = {} monitor.folders.render = {}
@ -426,7 +432,9 @@ monitor.folders.render.details = function (folder,data) {
} }
} }
if (isNaN(mean)) {
mean = 0
}
// //
// We need to assess the outliars i.e too old, too large // We need to assess the outliars i.e too old, too large
// //
@ -450,6 +458,7 @@ monitor.folders.render.details = function (folder,data) {
} }
monitor.folders.render.summary = function (data) { monitor.folders.render.summary = function (data) {
jx.dom.set.value('gridfolders', '') jx.dom.set.value('gridfolders', '')
var options = { var options = {
width: $('#gridfolders').width(), height:'auto' width: $('#gridfolders').width(), height:'auto'
@ -470,6 +479,7 @@ monitor.folders.render.summary = function (data) {
} }
options.rowClick = function(args){ options.rowClick = function(args){
var item = args.item var item = args.item
age = jx.utils.patterns.visitor(item.details.age, function (row) { age = jx.utils.patterns.visitor(item.details.age, function (row) {
return {y:row[0],x:row[1]} return {y:row[0],x:row[1]}
}) })
@ -477,13 +487,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(item.label,{age:age,size:size}) monitor.folders.render.details(item.name,{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: 'id', type: 'text', title: "Context", headercss: "small bold", css: "small"},
{ name: 'name', type: 'text', title: "Folder Name", headercss: "small bold", css: "small"},
{ 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" }

@ -285,8 +285,10 @@ class FileWatch(Analysis):
if os.path.exists(folder): if os.path.exists(folder):
xo_raw = self.evaluate(folder) xo_raw = self.evaluate(folder)
xo = np.array(ML.Extract(['size','age'],xo_raw)) xo = np.array(ML.Extract(['size','age'],xo_raw))
name = re.findall("([a-z,A-Z,0-9]+$)",folder)
name = name[0]
xo = {"label":folder,"details":xo_raw,"summary":{"size":round(np.sum(xo[:,0]),2),"age":round(np.mean(xo[:,1]),2),"count":len(xo[:,1])}} xo = {"label":folder,"details":xo_raw,"summary":{"size":round(np.sum(xo[:,0]),2),"age":round(np.mean(xo[:,1]),2),"count":len(xo[:,1])}}
xo["name"] = name
xo['day'] = now.day xo['day'] = now.day
xo['month'] = now.month xo['month'] = now.month
xo['year'] = now.year xo['year'] = now.year

@ -48,7 +48,7 @@ class ML:
return value.replace('$','').replace('.+','') return value.replace('$','').replace('.+','')
@staticmethod @staticmethod
def distribution(xo,lock,scale=False) : def distribution(xo,lock,scale=False) :
lock.acquire()
d = [] d = []
m = {} m = {}
if scale : if scale :
@ -59,6 +59,7 @@ class ML:
if scale : if scale :
value = round((value - xu)/sd,2) value = round((value - xu)/sd,2)
id = str(value) id = str(value)
lock.acquire()
if id in m : if id in m :
index = m[id] index = m[id]
d[index][1] += 1 d[index][1] += 1

@ -169,6 +169,7 @@ class FileWatchWorker(BasicWorker):
def run(self): def run(self):
TIME_ELAPSED = 60 * 10 TIME_ELAPSED = 60 * 10
handler = monitor.FileWatch() handler = monitor.FileWatch()
ml_handler = ML()
while self.quit == False : while self.quit == False :
r = [] r = []
print ' ** ',self.name,datetime.datetime.today() print ' ** ',self.name,datetime.datetime.today()
@ -179,17 +180,21 @@ class FileWatchWorker(BasicWorker):
# #
# We should perform a distribution analysis of the details in order to have usable data # We should perform a distribution analysis of the details in order to have usable data
# #
xrow = {}
xo_age = [row['age'] for row in xo[0]['details']] xrow[id] = []
xo_size= [row['size'] for row in xo[0]['details']] for xo_row in xo:
xo[0]['details'] = {"id":id, "age":ML.distribution(xo_age,self.lock),"size":ML.distribution(xo_size,self.lock)} xo_age = [row['age'] for row in xo_row['details']]
xo_size= [row['size'] for row in xo_row['details']]
xo_row['details'] = {"age":ML.distribution(xo_age,self.lock),"size":ML.distribution(xo_size,self.lock)}
xo_row['id'] = id
xrow[id].append(xo_row)
# #
# Now we can save the file # Now we can save the file
# #
self.lock.acquire() self.lock.acquire()
writer = self.factory.instance(type=self.write_class,args=self.rw_args) writer = self.factory.instance(type=self.write_class,args=self.rw_args)
writer.write(label='folders',row=xo) writer.write(label='folders',row=xrow)
self.lock.release() self.lock.release()
if 'MONITOR_CONFIG_PATH' in os.environ: if 'MONITOR_CONFIG_PATH' in os.environ:
# #

Loading…
Cancel
Save