diff --git a/rq.yaml b/rq.yaml index a2d19d5..7490975 100644 --- a/rq.yaml +++ b/rq.yaml @@ -4,10 +4,12 @@ filelists: ceph-osd: [etc-ceph] cinder: [etc-cinder] compute: [etc-nova, etc-libvirt] - controller: [etc-glance, etc-haproxy, etc-heat, etc-ceph-controller, etc-nova, + controller: [etc-glance, etc-haproxy, etc-nova, etc-keystone, etc-neutron, etc-mysql] + # f3flight: removed etc-heat, etc-ceph-controller from controller since it's not always present, gives a warning + # f3flight: need to make a better way to decide which files to collect by_os_platform: - centos: [yum] + centos: [etc-yum] ubuntu: [etc-apt] scripts: by_release: diff --git a/rq/filelists/etc-yum b/rq/filelists/etc-yum new file mode 100644 index 0000000..74769da --- /dev/null +++ b/rq/filelists/etc-yum @@ -0,0 +1 @@ +/etc/yum diff --git a/rq/filelists/etc-yum-d b/rq/filelists/etc-yum-d new file mode 100644 index 0000000..12315d2 --- /dev/null +++ b/rq/filelists/etc-yum-d @@ -0,0 +1 @@ +/etc/yum.d diff --git a/rq/filelists/yum b/rq/filelists/yum deleted file mode 100644 index 6a3f70d..0000000 --- a/rq/filelists/yum +++ /dev/null @@ -1,3 +0,0 @@ -/etc/yum.d/ -/etc/yum -/etc/yum.conf diff --git a/rq/scripts/ceph-mon-status b/rq/scripts/ceph-mon-status index 5c03762..6858851 100644 --- a/rq/scripts/ceph-mon-status +++ b/rq/scripts/ceph-mon-status @@ -1,2 +1,7 @@ -ceph mon_status - +which ceph +if [ "$?" -eq "0" ] +then + ceph mon_status +else + echo 'Timmy says: ceph not installed' +fi diff --git a/timmy/cli.py b/timmy/cli.py index daa4c53..6fcc4d3 100755 --- a/timmy/cli.py +++ b/timmy/cli.py @@ -26,6 +26,14 @@ from timmy.tools import interrupt_wrapper from tempfile import gettempdir +def pretty_run(msg, f, args=[], kwargs={}): + sys.stdout.write('%s...\r' % msg) + sys.stdout.flush() + result = f(*args, **kwargs) + print('%s: done' % msg) + return result + + @interrupt_wrapper def main(argv=None): if argv is None: @@ -82,8 +90,12 @@ def main(argv=None): ' an archive with all outputs and files' ' is created every time you run Timmy.'), action='store_true') + parser.add_argument('--no-clean', + help=('Do not clean previous results. Allows' + ' accumulating results across runs.'), + action='store_true') args = parser.parse_args(argv[1:]) - loglevel = logging.ERROR + loglevel = logging.WARNING if args.verbose: loglevel = logging.INFO if args.debug: @@ -94,10 +106,9 @@ def main(argv=None): conf = load_conf(args.conf) if args.command or args.file: conf['shell_mode'] = True + if args.no_clean: + conf['clean'] = False if conf['shell_mode']: - # set clean to True if not defined in config - if conf['clean'] is None: - conf['clean'] = True filter = conf['hard_filter'] # config cleanup for shell mode for k in Node.conf_actionable: @@ -118,28 +129,44 @@ def main(argv=None): main_arc = os.path.join(conf['archives'], 'general.tar.gz') if args.dest_file: main_arc = args.dest_file - nm = NodeManager(conf=conf, - extended=args.extended) + nm = pretty_run('Initializing node data', + NodeManager, + kwargs={'conf': conf, + 'extended': args.extended}) if not args.only_logs: - nm.run_commands(conf['outdir'], args.maxthreads) - nm.get_files(conf['outdir'], args.maxthreads) + if not (conf['shell_mode'] and not args.command): + pretty_run('Executing commands and scripts', + nm.run_commands, + args=(conf['outdir'], args.maxthreads)) + if not (conf['shell_mode'] and not args.file): + pretty_run('Collecting files and filelists', + nm.get_files, + args=(conf['outdir'], args.maxthreads)) if not args.no_archive: - nm.create_archive_general(conf['outdir'], - main_arc, - 60) + pretty_run('Creating outputs and files archive', + nm.create_archive_general, + args=(conf['outdir'], main_arc, 60)) if args.only_logs or args.getlogs: lf = os.path.join(gettempdir(), 'timmy-logs.lock') lock = flock.FLock(lf) if lock.lock(): - size = nm.calculate_log_size(args.maxthreads) + size = pretty_run('Calculating logs size', + nm.calculate_log_size, + args=(args.maxthreads,)) if size == 0: - logging.warning('No logs to collect.') + logging.warning('Size zero - no logs to collect.') + print('Size zero - no logs to collect.') return - if nm.is_enough_space(conf['archives']): - nm.get_logs(conf['archives'], - conf['compress_timeout'], - maxthreads=args.logs_maxthreads, - fake=args.fake_logs) + enough = pretty_run('Checking free space', + nm.is_enough_space, + args=(conf['archives'],)) + if enough: + pretty_run('Collecting and packing logs', + nm.get_logs, + args=(conf['archives'], + conf['compress_timeout']), + kwargs={'maxthreads': args.logs_maxthreads, + 'fake': args.fake_logs}) lock.unlock() else: logging.warning('Unable to obtain lock %s, skipping "logs"-part' % diff --git a/timmy/conf.py b/timmy/conf.py index 01ba8c3..408be21 100644 --- a/timmy/conf.py +++ b/timmy/conf.py @@ -41,9 +41,8 @@ def load_conf(filename): place specified by conf['outdir'], archive will also be created and put in a place specified by conf['archives'].''' conf['shell_mode'] = False - '''Clean - erase previous results in outdir and archives dir, if any. - Enabled by default for shell mode. Set to True or False to override.''' - conf['clean'] = None + '''Clean - erase previous results in outdir and archives dir, if any.''' + conf['clean'] = True if filename: conf_extra = load_yaml_file(filename) conf.update(**conf_extra) diff --git a/timmy/nodes.py b/timmy/nodes.py index e153751..56f6a30 100644 --- a/timmy/nodes.py +++ b/timmy/nodes.py @@ -214,7 +214,7 @@ class Node(object): (self.id, self.ip, cmd, code, errs)) def get_files(self, odir='info', timeout=15): - def check_code(code): + def check_code(code, errs): if code != 0: logging.warning("get_files: node: %s, ip: %s, " "code: %s, error message: %s" % @@ -232,7 +232,7 @@ class Node(object): file=file, ddir=ddir, recursive=True) - check_code(code) + check_code(code, errs) else: data = '' for f in self.filelists: @@ -252,7 +252,7 @@ class Node(object): ssh_opts=self.ssh_opts, dpath=ddir, timeout=self.timeout) - check_code(code) + check_code(c, e) def logs_populate(self, timeout=5): diff --git a/timmy/tools.py b/timmy/tools.py index d8a9aad..2bfea11 100644 --- a/timmy/tools.py +++ b/timmy/tools.py @@ -192,12 +192,14 @@ def launch_cmd(command, timeout, input=None): timeout_killer = threading.Timer(timeout, _timeout_terminate, [p.pid]) timeout_killer.start() outs, errs = p.communicate(input=input) + errs = errs.rstrip('\n') except: try: p.kill() except: pass outs, errs = p.communicate() + errs = errs.rstrip('\n') logging.error("command: %s err: %s, returned: %s" % (command, errs, p.returncode)) finally: