|
|
@ -50,12 +50,14 @@ class Env(Analysis):
|
|
|
|
r = [ self.evaluate(id) for id in self.values] ;
|
|
|
|
r = [ self.evaluate(id) for id in self.values] ;
|
|
|
|
N = len(r)
|
|
|
|
N = len(r)
|
|
|
|
n = sum(r)
|
|
|
|
n = sum(r)
|
|
|
|
return n/N
|
|
|
|
value = n/N
|
|
|
|
|
|
|
|
missing = [self.values[i] for i in range(0,N) if r[i] == 0]
|
|
|
|
|
|
|
|
return {"value":value,"missing":missing}
|
|
|
|
|
|
|
|
|
|
|
|
class Sandbox(Analysis):
|
|
|
|
class Sandbox(Analysis):
|
|
|
|
def __init__(self,conf):
|
|
|
|
def __init__(self,conf):
|
|
|
|
Analysis.__init__(self)
|
|
|
|
Analysis.__init__(self)
|
|
|
|
self.sandbox_path = conf['path']
|
|
|
|
self.sandbox_path = conf['sandbox']
|
|
|
|
self.requirements_path = conf['requirements']
|
|
|
|
self.requirements_path = conf['requirements']
|
|
|
|
def get_requirements (self):
|
|
|
|
def get_requirements (self):
|
|
|
|
f = open(self.requirements_path)
|
|
|
|
f = open(self.requirements_path)
|
|
|
@ -78,9 +80,11 @@ class Sandbox(Analysis):
|
|
|
|
def composite(self):
|
|
|
|
def composite(self):
|
|
|
|
required_modules= self.get_requirements()
|
|
|
|
required_modules= self.get_requirements()
|
|
|
|
sandbox_modules = self.get_sandbox_requirements()
|
|
|
|
sandbox_modules = self.get_sandbox_requirements()
|
|
|
|
N = len(requirements)
|
|
|
|
N = len(required_modules)
|
|
|
|
n = len(Set(required_modules) - Set(sandbox_modules))
|
|
|
|
n = len(Set(required_modules) - Set(sandbox_modules))
|
|
|
|
return n/N
|
|
|
|
value = 1 - (n/N)
|
|
|
|
|
|
|
|
missing = list(Set(required_modules) - Set(sandbox_modules))
|
|
|
|
|
|
|
|
return {"value":value,"missing":missing}
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
This class performs the analysis of a list of processes and determines
|
|
|
|
This class performs the analysis of a list of processes and determines
|
|
|
@ -113,16 +117,30 @@ class DetailProcess(Analysis):
|
|
|
|
def evaluate(self,name) :
|
|
|
|
def evaluate(self,name) :
|
|
|
|
cmd = "ps -eo pmem,pcpu,vsize,comm|grep :app$"
|
|
|
|
cmd = "ps -eo pmem,pcpu,vsize,comm|grep :app$"
|
|
|
|
handler = subprocess.Popen(cmd.replace(":app",name),shell=True,stdout=subprocess.PIPE)
|
|
|
|
handler = subprocess.Popen(cmd.replace(":app",name),shell=True,stdout=subprocess.PIPE)
|
|
|
|
ostream = handler.communicate()[0].split(' ')
|
|
|
|
ostream = handler.communicate()[0].split('\n')
|
|
|
|
return [float(value) for value in ostream if value.strip() not in ['',name]] +[name]
|
|
|
|
ostream = [ row.split(' ') for row in ostream if row != '']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
r = []
|
|
|
|
|
|
|
|
for row in ostream :
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
row = [float(value) for value in row if value.strip() not in ['',name]] +[name]
|
|
|
|
|
|
|
|
r.append(row)
|
|
|
|
|
|
|
|
return r
|
|
|
|
|
|
|
|
def format(self,row):
|
|
|
|
|
|
|
|
return {"memory_usage":row[0],"cpu_usage":row[1],"memory_available":row[2]/1000,"label":row[3]}
|
|
|
|
def composite(self):
|
|
|
|
def composite(self):
|
|
|
|
#value = self.evaluate(self.name)
|
|
|
|
#value = self.evaluate(self.name)
|
|
|
|
#row= {"memory_usage":value[0],"cpu_usage":value[1]}
|
|
|
|
#row= {"memory_usage":value[0],"cpu_usage":value[1]}
|
|
|
|
#return row
|
|
|
|
#return row
|
|
|
|
ma = [self.evaluate(name) for name in self.names]
|
|
|
|
#ma = [self.evaluate(name) for name in self.names]
|
|
|
|
|
|
|
|
ma = []
|
|
|
|
|
|
|
|
for name in self.names:
|
|
|
|
|
|
|
|
matrix = self.evaluate(name)
|
|
|
|
|
|
|
|
ma += [self.format(row) for row in matrix]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#return [{"memory_usage":row[0],"cpu_usage":row[1],"memory_available":row[2]/1000,"label":row[3]} for row in ma]
|
|
|
|
|
|
|
|
|
|
|
|
return [{"memory_usage":row[0],"cpu_usage":row[1],"memory_available":row[2]/1000,"label":row[3]} for row in ma]
|
|
|
|
return ma
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
This class will require
|
|
|
|
This class will require
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|