|
|
|
@ -2,6 +2,8 @@
|
|
|
|
|
This program is designed to inspect an application environment
|
|
|
|
|
This program should only be run on unix friendly systems
|
|
|
|
|
|
|
|
|
|
We enable the engines to be able to run a several configurations
|
|
|
|
|
Similarly to what a visitor design-pattern would do
|
|
|
|
|
"""
|
|
|
|
|
from __future__ import division
|
|
|
|
|
import os
|
|
|
|
@ -20,8 +22,9 @@ class Analysis:
|
|
|
|
|
The class returns a quantifiable assessment of the environment variables (expected 100%)
|
|
|
|
|
"""
|
|
|
|
|
class Env(Analysis):
|
|
|
|
|
def __init__(self,values):
|
|
|
|
|
def __init__(self):
|
|
|
|
|
Analysis.__init__(self)
|
|
|
|
|
def init(self,values):
|
|
|
|
|
self.values = values
|
|
|
|
|
"""
|
|
|
|
|
This function evaluate the validity of an environment variable by returning a 1 or 0 (computable)
|
|
|
|
@ -55,8 +58,9 @@ class Env(Analysis):
|
|
|
|
|
return {"value":value,"missing":missing}
|
|
|
|
|
|
|
|
|
|
class Sandbox(Analysis):
|
|
|
|
|
def __init__(self,conf):
|
|
|
|
|
def __init__(self):
|
|
|
|
|
Analysis.__init__(self)
|
|
|
|
|
def init(self,conf):
|
|
|
|
|
self.sandbox_path = conf['sandbox']
|
|
|
|
|
self.requirements_path = conf['requirements']
|
|
|
|
|
def get_requirements (self):
|
|
|
|
@ -91,8 +95,9 @@ class Sandbox(Analysis):
|
|
|
|
|
The class provides a quantifiable measure of how many processes it found over all
|
|
|
|
|
"""
|
|
|
|
|
class ProcessCounter(Analysis):
|
|
|
|
|
def __init__(self,names):
|
|
|
|
|
def __init__(self):
|
|
|
|
|
Analysis.__init__(self)
|
|
|
|
|
def init(self,names):
|
|
|
|
|
self.names = names
|
|
|
|
|
def evaluate(self,name):
|
|
|
|
|
cmd = "".join(['ps -eo comm |grep ',name,' |wc -l'])
|
|
|
|
@ -112,7 +117,9 @@ class ProcessCounter(Analysis):
|
|
|
|
|
This class returns an application's both memory and cpu usage
|
|
|
|
|
"""
|
|
|
|
|
class DetailProcess(Analysis):
|
|
|
|
|
def __init__(self,names):
|
|
|
|
|
def __init__(self):
|
|
|
|
|
Analysis.__init__(self)
|
|
|
|
|
def init (self,names):
|
|
|
|
|
self.names = names;
|
|
|
|
|
def evaluate(self,name) :
|
|
|
|
|
cmd = "ps -eo pmem,pcpu,vsize,comm|grep :app$"
|
|
|
|
@ -122,8 +129,11 @@ class DetailProcess(Analysis):
|
|
|
|
|
|
|
|
|
|
r = []
|
|
|
|
|
for row in ostream :
|
|
|
|
|
|
|
|
|
|
row = [float(value) for value in row if value.strip() not in ['',name]] +[name]
|
|
|
|
|
#
|
|
|
|
|
# Though the comm should only return the name as specified,
|
|
|
|
|
# On OSX it has been observed that the fully qualified path is sometimes returned (go figure)
|
|
|
|
|
#
|
|
|
|
|
row = [float(value) for value in row if value.strip() != '' and name not in value ] +[name]
|
|
|
|
|
r.append(row)
|
|
|
|
|
return r
|
|
|
|
|
def format(self,row):
|
|
|
|
@ -141,41 +151,3 @@ class DetailProcess(Analysis):
|
|
|
|
|
#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
|
|
|
|
|
"""
|
|
|
|
|
class QueueServer(Analysis):
|
|
|
|
|
def __init__(self,conf):
|
|
|
|
|
Analysis.__init__(self)
|
|
|
|
|
pass
|
|
|
|
|
def is_running(self):
|
|
|
|
|
p = Process(['rabbitmq-server'])
|
|
|
|
|
return p.composite()
|
|
|
|
|
def has_virtualhost(self,name):
|
|
|
|
|
return 0
|
|
|
|
|
def has_user(self,uid):
|
|
|
|
|
return 0
|
|
|
|
|
def composite(self):
|
|
|
|
|
if self.is_running() :
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
return [0,0,0]
|
|
|
|
|
"""
|
|
|
|
|
Normalization will be required for the data produced by this class
|
|
|
|
|
"""
|
|
|
|
|
class DatabaseServer(Analysis):
|
|
|
|
|
def __init__(self,conf):
|
|
|
|
|
Analysis.__init__(self)
|
|
|
|
|
pass
|
|
|
|
|
def has_table(self,name):
|
|
|
|
|
pass
|
|
|
|
|
def has_fields(self,table,fields):
|
|
|
|
|
pass
|
|
|
|
|
def has_data(self,table):
|
|
|
|
|
pass
|
|
|
|
|
"""
|
|
|
|
|
This function will return the number of test-cases of the last build.
|
|
|
|
|
The use of the returned number will have to be normalized if used in a dataset.
|
|
|
|
|
"""
|
|
|
|
|
#class TestCaseCount(Analysis):
|
|
|
|
|
#pass
|