From 6425ebb30b1046d1624ff88f22c89992608539d7 Mon Sep 17 00:00:00 2001 From: Alexander Calhoun Date: Fri, 4 May 2018 13:38:41 -0400 Subject: [PATCH] Updated logging scheme to and added additional logging statements. changed prints to logging statements. --- cbt.py | 2 +- common.py | 4 +++- log_support.py | 2 +- monitoring.py | 4 ++++ settings.py | 1 - 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cbt.py b/cbt.py index 91dfc0ce..dd3253ef 100755 --- a/cbt.py +++ b/cbt.py @@ -41,7 +41,7 @@ def main(argv): settings.initialize(ctx) iteration = 0 - logger.debug("Settings.cluster:\n %s", + logger.info("Settings.cluster:\n %s", pprint.pformat(settings.cluster).replace("\n", "\n ")) global_init = collections.OrderedDict() diff --git a/common.py b/common.py index 73f3a92d..fb95e866 100644 --- a/common.py +++ b/common.py @@ -106,7 +106,7 @@ def get_fqdn_list(nodes): return ret def clean_remote_dir (remote_dir): - print "cleaning remote dir %s" % remote_dir + logger.info("cleaning remote dir %s" % remote_dir) if remote_dir == "/" or not os.path.isabs(remote_dir): raise SystemExit("Cleaning the remote dir doesn't seem safe, bailing.") @@ -115,12 +115,14 @@ def clean_remote_dir (remote_dir): continue_if_error=False).communicate() def make_remote_dir(remote_dir): + logger.info("making remote dir %s" % remote_dir) nodes = settings.getnodes('clients', 'osds', 'mons', 'rgws', 'mds') pdsh(nodes, 'mkdir -p -m0755 -- %s' % remote_dir, continue_if_error=False).communicate() def sync_files(remote_dir, local_dir): + logger.info("sync files between local and remote directories %s and %s" % (local_dir, remote_dir)) nodes = settings.getnodes('clients', 'osds', 'mons', 'rgws', 'mds') if not os.path.exists(local_dir): diff --git a/log_support.py b/log_support.py index 22ce57bd..d8056aff 100644 --- a/log_support.py +++ b/log_support.py @@ -64,7 +64,7 @@ def setup_loggers(def_level=logging.DEBUG, log_fname=None): sh = logging.StreamHandler() sh.setLevel(def_level) - log_format = '%(asctime)s - %(levelname)s - %(name)-8s - %(message)s' + log_format = '%(asctime)s %(levelname)s %(name)s %(module)s: %(message)s' colored_formatter = ColoredFormatter(log_format, datefmt="%H:%M:%S") sh.setFormatter(colored_formatter) diff --git a/monitoring.py b/monitoring.py index f3dd99c4..2533582b 100644 --- a/monitoring.py +++ b/monitoring.py @@ -1,8 +1,11 @@ import common import settings +import logging +logger = logging.getLogger("cbt") def start(directory): + logger.info('starting monitoring') nodes = settings.getnodes('clients', 'osds', 'mons', 'rgws') collectl_dir = '%s/collectl' % directory # perf_dir = '%s/perf' % directory @@ -25,6 +28,7 @@ def start(directory): def stop(directory=None): + logger.info('Stopping monitoring') nodes = settings.getnodes('clients', 'osds', 'mons', 'rgws') common.pdsh(nodes, 'killall -SIGINT -f collectl').communicate() diff --git a/settings.py b/settings.py index 52ee70e3..1bd4f293 100644 --- a/settings.py +++ b/settings.py @@ -72,7 +72,6 @@ def getnodes(*nodelists): nodelist, cur) str_nodes = ','.join(uniquenodes(nodes)) - logger.debug("Nodes : %s", str_nodes) return str_nodes