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()
if 'folders' in d:
d = d['folders']
index = len(d) -1
d = d[index]
else:
d = []

@ -357,8 +357,14 @@ monitor.folders.init = function () {
var httpclient = HttpClient.instance()
httpclient.get('/folders', function (x) {
var r = JSON.parse(x.responseText)
r = r[0]
monitor.folders.render.init(r)
var data = []
for (var id in r) {
var item = r[id]
item.id = id
data = data.concat(item)
}
monitor.folders.render.init(data)
})
}
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
//
@ -450,6 +458,7 @@ monitor.folders.render.details = function (folder,data) {
}
monitor.folders.render.summary = function (data) {
jx.dom.set.value('gridfolders', '')
var options = {
width: $('#gridfolders').width(), height:'auto'
@ -470,6 +479,7 @@ monitor.folders.render.summary = function (data) {
}
options.rowClick = function(args){
var item = args.item
age = jx.utils.patterns.visitor(item.details.age, function (row) {
return {y:row[0],x:row[1]}
})
@ -477,13 +487,14 @@ monitor.folders.render.summary = function (data) {
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
options.autoload = true
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.count", type: "number", title: "File Count", type: "number", headercss: "small bold" }

@ -285,8 +285,10 @@ class FileWatch(Analysis):
if os.path.exists(folder):
xo_raw = self.evaluate(folder)
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["name"] = name
xo['day'] = now.day
xo['month'] = now.month
xo['year'] = now.year

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

@ -169,6 +169,7 @@ class FileWatchWorker(BasicWorker):
def run(self):
TIME_ELAPSED = 60 * 10
handler = monitor.FileWatch()
ml_handler = ML()
while self.quit == False :
r = []
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
#
xo_age = [row['age'] for row in xo[0]['details']]
xo_size= [row['size'] for row in xo[0]['details']]
xo[0]['details'] = {"id":id, "age":ML.distribution(xo_age,self.lock),"size":ML.distribution(xo_size,self.lock)}
xrow = {}
xrow[id] = []
for xo_row in xo:
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
#
self.lock.acquire()
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()
if 'MONITOR_CONFIG_PATH' in os.environ:
#

Loading…
Cancel
Save