Added status interface updated testcases

master
Steve L. Nyemba 8 years ago
parent 0afbb1c072
commit 6619c75e33

@ -189,14 +189,33 @@ def learn():
return json.dumps(r)
"""
This function returns anomalies for a given context or group of processes
The information returned is around precision/recall and f-score and parameters
"""
@app.route('/anomalies/status')
def anomalies_status():
pass
global CONFIG
p = CONFIG['store']['args']
class_read = CONFIG['store']['class']['read']
gReader = factory.instance(type=class_read,args=p)
d = gReader.read()
if 'learn' in d :
info = d['learn']
del d['learn']
else :
info = []
print info
r = []
if 'id' in request.args:
id = request.args['id']
r = info
return json.dumps(r)
if __name__== '__main__':
ThreadManager.start(CONFIG)
# ThreadManager.start(CONFIG)
app.run(host='0.0.0.0',debug=True,threaded=True)

@ -30,6 +30,7 @@ class TestML(unittest.TestCase):
#
app = CONFIG['monitor']['processes']['config']['apps'][0]
x = ML.Filter('label',app,r)
app = ML.CleanupName(app)
for row in x:
self.assertTrue(row['label'] == app)
def test_Extract(self):
@ -37,7 +38,9 @@ class TestML(unittest.TestCase):
r = r['apps']
app = CONFIG['monitor']['processes']['config']['apps'][0]
x = ML.Filter('label',app,r)
x_ = ML.Extract(['cpu_usage','memory_usage'], x)
features = CONFIG['learner']['anomalies']['features']
self.assertTrue(features)
x_ = ML.Extract(features, x)
self.assertTrue (len (x) == len(x_))
pass
@ -49,9 +52,11 @@ class TestML(unittest.TestCase):
data = greader.read()
data = data['apps']
app = CONFIG['monitor']['processes']['config']['apps'][1]
app = CONFIG['monitor']['processes']['config']['apps'][0]
lhandler = AnomalyDetection()
features = CONFIG['learner']['anomalies']['features']
print features
print app
label = CONFIG['learner']['anomalies']['label']
x = lhandler.learn(data,'label',app,features,label)
print x

Loading…
Cancel
Save