browbeat/lib/Connmon.py
Alex Krzos cc5fee596b Remove ansible api due to 1.9.4 confusion and bugs.
+ Adjusted workloads to positional args and is flexiable to take:
  - ./browbeat.py                      ---> Runs all worklaods in order: perfkit rally shaker
  - ./browbeat.py all                  ---> Runs all workloads in order: perfkit rally shaker
  - ./browbeat.py perfkit rally        ---> Runs workloads in order: perfkit rally
  - ./browbeat.py shaker rally perfkit ---> Runs workloads in order: shaker rally perfkit
+ --debug now displays debug messages in stdout in addition to previous locations it logged
+ --setup or -s to take a config, Defaults to browbeat-config.yaml (Same as before), Examples:
  - ./browbeat.py -s browbeat-complete.yaml rally
  - ./browbeat.py -s conf/browbeat-keystone-complete.yaml --debug
+ Use __init__.py to allow cleaner importing of files under lib/
+ Remove ansible version restriction in requirements.txt
+ Separate connmon config from browbeat config for clarity.

Change-Id: Ifb74e5868be128fb378c7b052ba5a1bea46b4dff
2016-03-30 15:00:15 -04:00

56 lines
1.9 KiB
Python

from Tools import *
class Connmon :
def __init__(self,config):
self.logger = logging.getLogger('browbeat.Connmon')
self.config = config
self.tools = Tools(self.config)
return None
# Start connmond
def start_connmon(self,retry=None):
self.stop_connmon()
tool="connmond"
connmond=self.tools.find_cmd(tool)
if not connmond :
self.logger.error("Unable to find {}".format(tool))
as_sudo = self.config['connmon']['sudo']
cmd = ""
if as_sudo :
cmd +="sudo "
cmd += "screen -X -S connmond kill"
self.tools.run_cmd(cmd)
self.logger.info("Starting connmond")
cmd = ""
cmd +="{} --config /etc/connmon.cfg > /tmp/connmond 2>&1 &".format(connmond)
self.tools.run_cmd(cmd)
if self.check_connmon_results == False:
if retry == None :
self.start_connmon(retry=True)
else :
return False
else :
return True
def check_connmon_results(self,result_file='/tmp/connmon_results.csv'):
return os.path.isfile(result_file)
# Stop connmond
def stop_connmon(self):
self.logger.info("Stopping connmond")
return self.tools.run_cmd("pkill -9 connmond")
# Create Connmon graphs
def connmon_graphs(self,result_dir,test_name):
cmd="python graphing/connmonplot.py {}/connmon/{}.csv".format(result_dir,
test_name)
return self.tools.run_cmd(cmd)
# Move connmon results
def move_connmon_results(self,result_dir,test_name):
path = "%s/connmon" % result_dir
if not os.path.exists(path) :
os.mkdir(path)
return shutil.move("/tmp/connmon_results.csv",
"{}/connmon/{}.csv".format(result_dir,test_name))