Skip to content

Commit

Permalink
Fix bad coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
mohierf committed Dec 17, 2019
1 parent 8951a46 commit b49b16c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
2 changes: 0 additions & 2 deletions module/plugins/logs/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,13 @@ 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
try:
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']:
Expand Down
25 changes: 13 additions & 12 deletions module/plugins/stats/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b49b16c

Please sign in to comment.