|
|
@ -30,14 +30,17 @@ class TestML(unittest.TestCase):
|
|
|
|
#
|
|
|
|
#
|
|
|
|
app = CONFIG['monitor']['processes']['config']['apps'][0]
|
|
|
|
app = CONFIG['monitor']['processes']['config']['apps'][0]
|
|
|
|
x = ML.Filter('label',app,r)
|
|
|
|
x = ML.Filter('label',app,r)
|
|
|
|
for row in x:
|
|
|
|
app = ML.CleanupName(app)
|
|
|
|
|
|
|
|
for row in x:
|
|
|
|
self.assertTrue(row['label'] == app)
|
|
|
|
self.assertTrue(row['label'] == app)
|
|
|
|
def test_Extract(self):
|
|
|
|
def test_Extract(self):
|
|
|
|
r = self.greader.read()
|
|
|
|
r = self.greader.read()
|
|
|
|
r = r['apps']
|
|
|
|
r = r['apps']
|
|
|
|
app = CONFIG['monitor']['processes']['config']['apps'][0]
|
|
|
|
app = CONFIG['monitor']['processes']['config']['apps'][0]
|
|
|
|
x = ML.Filter('label',app,r)
|
|
|
|
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_))
|
|
|
|
self.assertTrue (len (x) == len(x_))
|
|
|
|
pass
|
|
|
|
pass
|
|
|
@ -49,9 +52,11 @@ class TestML(unittest.TestCase):
|
|
|
|
data = greader.read()
|
|
|
|
data = greader.read()
|
|
|
|
|
|
|
|
|
|
|
|
data = data['apps']
|
|
|
|
data = data['apps']
|
|
|
|
app = CONFIG['monitor']['processes']['config']['apps'][1]
|
|
|
|
app = CONFIG['monitor']['processes']['config']['apps'][0]
|
|
|
|
lhandler = AnomalyDetection()
|
|
|
|
lhandler = AnomalyDetection()
|
|
|
|
features = CONFIG['learner']['anomalies']['features']
|
|
|
|
features = CONFIG['learner']['anomalies']['features']
|
|
|
|
|
|
|
|
print features
|
|
|
|
|
|
|
|
print app
|
|
|
|
label = CONFIG['learner']['anomalies']['label']
|
|
|
|
label = CONFIG['learner']['anomalies']['label']
|
|
|
|
x = lhandler.learn(data,'label',app,features,label)
|
|
|
|
x = lhandler.learn(data,'label',app,features,label)
|
|
|
|
print x
|
|
|
|
print x
|
|
|
|