From b3f3d38ef91f21a7e82873082fe51751259a8895 Mon Sep 17 00:00:00 2001 From: "Steve L. Nyemba" Date: Wed, 8 Feb 2017 07:22:38 -0600 Subject: [PATCH] ui for forlder monitoring --- src/api/static/js/dashboard.js | 4 +++- src/api/templates/dashboard.html | 2 +- src/monitor.py | 5 +++-- src/utils/ml.py | 7 ++++++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/api/static/js/dashboard.js b/src/api/static/js/dashboard.js index 8070446..e75b727 100644 --- a/src/api/static/js/dashboard.js +++ b/src/api/static/js/dashboard.js @@ -423,6 +423,8 @@ monitor.folders.render.summary = function (data) { } options.rowClick = function(args){ var item = args.item + var yu = jx.math.mean(jx.utils.vector('0', item.details.age)) + var yr = jx.math.sd(jx.utils.vector('0', item.details.age)) age = jx.utils.patterns.visitor(item.details.age, function (row) { return {y:row[0],x:row[1]} }) @@ -436,7 +438,7 @@ monitor.folders.render.summary = function (data) { options.autoload = true options.fields = [ { name: 'label', type: 'text', title: "Folder Name", headercss: "small bold", css: "small"}, - { name: "summary.age", type: "number", title: "Oldest File (Days)", headercss: "small bold" , width:'64px'}, + { 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.count", type: "number", title: "File Count", type: "number", headercss: "small bold" } ] diff --git a/src/api/templates/dashboard.html b/src/api/templates/dashboard.html index 8e6a957..8dfbad8 100644 --- a/src/api/templates/dashboard.html +++ b/src/api/templates/dashboard.html @@ -19,7 +19,7 @@ iMonitor diff --git a/src/monitor.py b/src/monitor.py index 606628a..632934d 100755 --- a/src/monitor.py +++ b/src/monitor.py @@ -284,8 +284,9 @@ class FileWatch(Analysis): for folder in self.folders: if os.path.exists(folder): xo_raw = self.evaluate(folder) - xo = np.array(ML.Extract(['size','age'],xo_raw)) - xo = {"label":folder,"details":xo_raw,"summary":{"size":round(np.sum(xo[:,0]),2),"age":np.max(xo[:,1]),"count":len(xo[:,1])}} + xo = np.array(ML.Extract(['size','age'],xo_raw)) + + xo = {"label":folder,"details":xo_raw,"summary":{"size":round(np.mean(xo[:,0]),2),"age":round(np.mean(xo[:,1]),2),"count":len(xo[:,1])}} xo['day'] = now.day xo['month'] = now.month xo['year'] = now.year diff --git a/src/utils/ml.py b/src/utils/ml.py index 6cec1b3..747e6d7 100644 --- a/src/utils/ml.py +++ b/src/utils/ml.py @@ -47,12 +47,17 @@ class ML: def CleanupName(value) : return value.replace('$','').replace('.+','') @staticmethod - def distribution(xo,lock) : + def distribution(xo,lock,scale=False) : lock.acquire() d = [] m = {} + if scale : + xu = np.mean(xo) + sd = np.sqrt(np.var(xo)) for xi in xo : value = round(xi,2) + if scale : + value = round((value - xu)/sd,2) id = str(value) if id in m : index = m[id]