From aed107107b172a02f466879b634d454b078c996d Mon Sep 17 00:00:00 2001 From: "Steve L. Nyemba" Date: Sun, 29 Jan 2017 23:25:44 -0600 Subject: [PATCH] fix ui and api minor bugs --- src/api/index.py | 35 +++++++++++++++++++++++++++----- src/api/static/css/default.css | 4 ++-- src/api/static/js/dashboard.js | 7 ++++++- src/api/templates/dashboard.html | 33 +++++------------------------- 4 files changed, 43 insertions(+), 36 deletions(-) diff --git a/src/api/index.py b/src/api/index.py index b60a9ba..3df2bc1 100644 --- a/src/api/index.py +++ b/src/api/index.py @@ -50,13 +50,37 @@ atexit.register(ThreadManager.stop) def procs(id): try: gReader = factory.instance(type=class_read,args=p) - d = gReader.read() - + data = gReader.read() + ahandler = AnomalyDetection() + learn = {} + for row in data['learn'] : + label = row['label'] + learn[label] = row r = {} - for label in d : + for label in data : if label not in ['learn'] : - index = len(d[label]) - 1 - r[label] = d[label][index] + index = len(data[label]) - 1 + row = data[label][index] + r[label] = row + # + # Let us determine if this is a normal operation or not + # We will update the status of the information ... + # + for row in r[label] : + + if row['label'] in learn: + id = row['label'] + px = ahandler.predict([row],learn[id]) + if px : + px = px[0] + row['anomaly'] = px[1]==1 + print row + # + # @TODO: + # Compile a report here that will be sent to the mailing list + # + if row['status'] == 'crash' : + print row['label'],' *** ',row['status'] #for row in r[label] : #yo = ML.Extract(['status'],row) #xo = ML.Extract(['cpu_usage','memory_usage'],row) @@ -64,6 +88,7 @@ def procs(id): except Exception, e: print e r = [] + return json.dumps(r) """ diff --git a/src/api/static/css/default.css b/src/api/static/css/default.css index 438959f..073a4be 100644 --- a/src/api/static/css/default.css +++ b/src/api/static/css/default.css @@ -86,7 +86,7 @@ input[type=text]:focus{ .info { margin:4px; - width:40%; + width:43%; } @@ -96,5 +96,5 @@ input[type=text]:focus{ .bad { color:maroon} .good{ color:green} -.warning{color:orange} +.fa-warning, .warning{color:orange} .number {font-size:42px; font-weight:lighter; padding:2px; margin:2px;} \ No newline at end of file diff --git a/src/api/static/js/dashboard.js b/src/api/static/js/dashboard.js index e8f832c..430dc61 100644 --- a/src/api/static/js/dashboard.js +++ b/src/api/static/js/dashboard.js @@ -78,7 +78,12 @@ monitor.processes.render = function(label,data) { var item = args.item var id = jx.dom.get.value('latest_processes_label') var app = item.label - monitor.processes.trend.init(id,app) + monitor.processes.trend.init(id, app) + if (item.anomaly == true) { + jx.dom.show('has_anomaly') + } else { + jx.dom.hide('has_anomaly') + } } options.autoload = true diff --git a/src/api/templates/dashboard.html b/src/api/templates/dashboard.html index 37f197c..eae59e5 100644 --- a/src/api/templates/dashboard.html +++ b/src/api/templates/dashboard.html @@ -22,41 +22,17 @@ }) -
- +
-
-
-
Process Predictions
-
Anomaly Detection
-
-
-
-
-
00
-
F-Score
-
-
-
00
-
Recall
-
-
-
00
-
Precision
-
- -
-
+
Monitoring
-
Predict
+
@@ -81,7 +57,8 @@
-
CPU & Memory Usage Trend for +
CPU & Memory Usage Trend for +
Anomaly Detected