From b49b16cc2bde5137fc372bbed9550153e9ea1499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20MOHIER?= Date: Tue, 17 Dec 2019 17:57:10 +0100 Subject: [PATCH] Fix bad coding standards --- module/plugins/logs/logs.py | 2 -- module/plugins/stats/stats.py | 25 +++++++++++++------------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/module/plugins/logs/logs.py b/module/plugins/logs/logs.py index f62a139c..bc6e9402 100644 --- a/module/plugins/logs/logs.py +++ b/module/plugins/logs/logs.py @@ -219,7 +219,6 @@ def get_history(): range_start = int(app.request.query.get('range_start', "")) except ValueError: logger.debug("No range start") - pass search_range_start = range_start range_end = None @@ -227,7 +226,6 @@ def get_history(): range_end = int(app.request.query.get('range_end', "")) except ValueError: logger.debug("No range end") - pass search_range_end = range_end if params['date_format'] in ['datetime']: diff --git a/module/plugins/stats/stats.py b/module/plugins/stats/stats.py index c60f2773..5ab19c34 100644 --- a/module/plugins/stats/stats.py +++ b/module/plugins/stats/stats.py @@ -389,8 +389,9 @@ def get_service_stats(name): logger.info("[stats] query: %s", query) hosts = Counter() - for l in logs: - hosts[l['host_name']] += 1 + for log in logs: + hosts[log['host_name']] += 1 + return { 'service': name, 'hosts': hosts, @@ -451,19 +452,19 @@ def get_host_stats(name): hosts = Counter() services = Counter() - for l in logs: + for log in logs: # Alignak logstash parser.... - if 'alignak' in l: - l = l['alignak'] - if 'time' not in l: - l['time'] = int(time.mktime(l.pop('timestamp').timetuple())) + if 'alignak' in log: + log = log['alignak'] + if 'time' not in log: + log['time'] = int(time.mktime(log.pop('timestamp').timetuple())) - if 'service' in l: - l['service_description'] = l.pop('service') + if 'service' in log: + log['service_description'] = log.pop('service') - hosts[l['host_name']] += 1 - if 'service_description' in l: - services[l['service_description']] += 1 + hosts[log['host_name']] += 1 + if 'service_description' in log: + services[log['service_description']] += 1 return { 'host': name,