From 4139ef04cfbbb07058b7ddd3b224c79b9d0ee557 Mon Sep 17 00:00:00 2001 From: Dmitry Sutyagin Date: Tue, 27 Dec 2016 17:32:38 -0800 Subject: [PATCH] Change: minor changes in analyze & rabbitmq module Change-Id: Ib3e373bfea86ad35e3e2f384b0cdc8762cc25f5a --- specs/python-timmy.spec | 6 +++++- timmy/analyze.py | 23 ++++++++++++++++------- timmy/analyze_modules/rabbitmq.py | 18 ++++++++++++------ timmy/env.py | 2 +- 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/specs/python-timmy.spec b/specs/python-timmy.spec index 855e414..d724363 100644 --- a/specs/python-timmy.spec +++ b/specs/python-timmy.spec @@ -4,7 +4,7 @@ %global pypi_name timmy Name: python-%{pypi_name} -Version: 1.26.4 +Version: 1.26.5 Release: 1%{?dist}~mos0 Summary: Log collector tool for OpenStack Fuel @@ -107,6 +107,10 @@ popd %changelog +* Tue Dec 27 2016 Dmitry Sutyagin - 1.26.5 +- Change: minor changes in analyze & rabbitmq module +- Add: stderr for mapping scripts + * Thu Dec 22 2016 Dmitry Sutyagin - 1.26.4 - Add: max_pairs argument; other minor changes diff --git a/timmy/analyze.py b/timmy/analyze.py index c4564bd..b08889d 100644 --- a/timmy/analyze.py +++ b/timmy/analyze.py @@ -59,8 +59,17 @@ def analyze(node_manager): if os.path.exists(param['stderr_path']): with open(param['stderr_path'], 'r') as f: stderr = f.read() - exitcode = stderr.splitlines()[0] - exitcode = exitcode.rstrip().split()[1] + try: + exitcode = stderr.splitlines()[0] + exitcode = int(exitcode.rstrip().split()[1]) + except IndexError: + logger.warning('Could not extract exitcode' + ' from file "%s"' % + param['stderr_path']) + except ValueError: + logger.warning('Could not convert exitcode' + ' in file "%s" to int' % + param['stderr_path']) else: stderr = None exitcode = 0 @@ -106,11 +115,11 @@ def analyze_print_results(node_manager): (os.path.exists(r['stderr_file']))): print('%s%s: %s' % (12*' ', 'stderr_file', r['stderr_file'])) if r['exitcode'] != 0: - print('%s%s: %s' % (12*' ', 'exit code', r['exitcode'])) + print('%s%s: %s' % (12*' ', 'exitcode', r['exitcode'])) if len(r['details']) > 1: - print(' details:') + print('%sdetails:' % (12*' ')) for d in r['details']: - print(' - %s' % d) - else: - print(' details: %s' % r['details'][0]) + print('%s- %s' % (16*' ', d)) + elif r['details']: + print('%sdetails: %s' % (12*' ', r['details'][0])) sys.stdout.write(color_end) diff --git a/timmy/analyze_modules/rabbitmq.py b/timmy/analyze_modules/rabbitmq.py index 034a806..79b5b50 100644 --- a/timmy/analyze_modules/rabbitmq.py +++ b/timmy/analyze_modules/rabbitmq.py @@ -35,6 +35,9 @@ def parse_list_queues(stdout, script, node, stderr=None, exitcode=None): error = 1000 health = GREEN details = [] + if exitcode: + health = UNKNOWN + return health, details data = [l.rstrip() for l in stdout.splitlines()] for line in data[1:]: elements = line.rstrip().split() @@ -118,14 +121,17 @@ def squash_dicts(input_data): def parse_status(stdout, script, node, stderr=None, exitcode=None): - status = prepare_status(stdout) - if not status or exitcode: - health = RED - details = ['Failed on getting data from status'] - return health, details - health = GREEN details = [] + status = prepare_status(stdout) + if not status: + health = UNKNOWN + details = ['Status unavailable'] + if exitcode: + if exitcode == 69: + health = RED + details = ['RabbitMQ is not running'] + return health, details # disk free check try: diff --git a/timmy/env.py b/timmy/env.py index f88e0d1..6d17962 100644 --- a/timmy/env.py +++ b/timmy/env.py @@ -16,7 +16,7 @@ # under the License. project_name = 'timmy' -version = '1.26.4' +version = '1.26.5' if __name__ == '__main__': import sys