|
|
|
@ -22,7 +22,7 @@ class Analysis:
|
|
|
|
|
self.logs.append(object)
|
|
|
|
|
def init(self):
|
|
|
|
|
d = datetime.datetime.now()
|
|
|
|
|
self.now = {"month":d.month,"year":d.year, "day":d.day,"hour":d.hour}
|
|
|
|
|
self.now = {"month":d.month,"year":d.year, "day":d.day,"hour":d.hour,"minute":d.minute}
|
|
|
|
|
"""
|
|
|
|
|
This class is designed to analyze environment variables. Environment variables can either be folders, files or simple values
|
|
|
|
|
The class returns a quantifiable assessment of the environment variables (expected 100%)
|
|
|
|
@ -57,6 +57,7 @@ class Env(Analysis):
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
def composite (self):
|
|
|
|
|
Analysis.init(self)
|
|
|
|
|
r = [ self.evaluate(id) for id in self.values] ;
|
|
|
|
|
N = len(r)
|
|
|
|
|
n = sum(r)
|
|
|
|
@ -90,6 +91,7 @@ class Sandbox(Analysis):
|
|
|
|
|
This function returns the ratio of existing modules relative to the ones expected
|
|
|
|
|
"""
|
|
|
|
|
def composite(self):
|
|
|
|
|
Analysis.init(self)
|
|
|
|
|
required_modules= self.get_requirements()
|
|
|
|
|
sandbox_modules = self.get_sandbox_requirements()
|
|
|
|
|
N = len(required_modules)
|
|
|
|
@ -115,6 +117,7 @@ class ProcessCounter(Analysis):
|
|
|
|
|
|
|
|
|
|
return int(handler.communicate()[0].replace("\n","") )
|
|
|
|
|
def composite(self):
|
|
|
|
|
Analysis.init(self)
|
|
|
|
|
r = {}
|
|
|
|
|
for name in self.names :
|
|
|
|
|
r[name] = self.evaluate(name)
|
|
|
|
@ -168,11 +171,14 @@ class DetailProcess(Analysis):
|
|
|
|
|
else:
|
|
|
|
|
return "crash"
|
|
|
|
|
def format(self,row):
|
|
|
|
|
|
|
|
|
|
r= {"memory_usage":row[0],"cpu_usage":row[1],"memory_available":row[2]/1000,"label":row[3]}
|
|
|
|
|
status = self.status(r)
|
|
|
|
|
r['status'] = status
|
|
|
|
|
return dict(self.now,**r)
|
|
|
|
|
def composite(self):
|
|
|
|
|
Analysis.init(self)
|
|
|
|
|
print ' **** ',self.now
|
|
|
|
|
#value = self.evaluate(self.name)
|
|
|
|
|
#row= {"memory_usage":value[0],"cpu_usage":value[1]}
|
|
|
|
|
#return row
|
|
|
|
@ -209,8 +215,8 @@ class Monitor (Thread):
|
|
|
|
|
self.queue.put(r)
|
|
|
|
|
self.prune()
|
|
|
|
|
self.queue.task_done()
|
|
|
|
|
|
|
|
|
|
time.sleep(10)
|
|
|
|
|
HALF_HOUR = 60*15
|
|
|
|
|
time.sleep(HALF_HOUR)
|
|
|
|
|
def prune(self) :
|
|
|
|
|
MAX_ENTRIES = 1000
|
|
|
|
|
if len(self.logs) > MAX_ENTRIES :
|
|
|
|
@ -230,14 +236,20 @@ class mapreducer:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if reducer is not None:
|
|
|
|
|
r = [reducer(self.store[key]) for key in self.store]
|
|
|
|
|
r = {}
|
|
|
|
|
for key in self.store:
|
|
|
|
|
beg = len(self.store[key]) - 101 if len(self.store[key]) > 100 else 0
|
|
|
|
|
end = beg + 100
|
|
|
|
|
r[key] = self.store[key][beg:end]
|
|
|
|
|
# r = [reducer(self.store[key]) for key in self.store]
|
|
|
|
|
else:
|
|
|
|
|
r = self.store
|
|
|
|
|
return r
|
|
|
|
|
def mapper(self,row,emit):
|
|
|
|
|
[emit(item['label'],item) for item in row ]
|
|
|
|
|
[emit(_matrix['label'],_matrix) for _matrix in row ]
|
|
|
|
|
def reducer(self,values):
|
|
|
|
|
return value
|
|
|
|
|
beg = len(values)-101 if len(values) > 100 else 0
|
|
|
|
|
return values[beg:]
|
|
|
|
|
|
|
|
|
|
def emit(self,key,content):
|
|
|
|
|
if key not in self.store:
|
|
|
|
|