|
|
|
@ -86,20 +86,24 @@ class Sandbox(Analysis):
|
|
|
|
|
This class performs the analysis of a list of processes and determines
|
|
|
|
|
The class provides a quantifiable measure of how many processes it found over all
|
|
|
|
|
"""
|
|
|
|
|
class Processes(Analysis):
|
|
|
|
|
class ProcessCounter(Analysis):
|
|
|
|
|
def __init__(self,names):
|
|
|
|
|
Analysis.__init__(self)
|
|
|
|
|
self.names = names
|
|
|
|
|
def evaluate(self,name):
|
|
|
|
|
cmd = "".join(['ps aux |grep -E "^ {0,}',name,'" |wc -l'])
|
|
|
|
|
cmd = "".join(['ps -eo comm |grep ',name,' |wc -l'])
|
|
|
|
|
handler = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE)
|
|
|
|
|
|
|
|
|
|
return int(handler.communicate()[0].replace('\n','')) > 0
|
|
|
|
|
return int(handler.communicate()[0].replace("\n","") )
|
|
|
|
|
def composite(self):
|
|
|
|
|
r = [ self.evaluate(name) for name in self.names]
|
|
|
|
|
N = len(r)
|
|
|
|
|
n = sum(r)
|
|
|
|
|
return n/N
|
|
|
|
|
r = {}
|
|
|
|
|
for name in self.names :
|
|
|
|
|
r[name] = self.evaluate(name)
|
|
|
|
|
|
|
|
|
|
#N = len(r)
|
|
|
|
|
#n = sum(r)
|
|
|
|
|
#return n/N
|
|
|
|
|
return r
|
|
|
|
|
"""
|
|
|
|
|
This class returns an application's both memory and cpu usage
|
|
|
|
|
"""
|
|
|
|
|