From 9cabf3ef4df50514ee78ddb4c24d358a390e98bf Mon Sep 17 00:00:00 2001 From: chris meyers Date: Tue, 14 Apr 2020 16:54:00 -0400 Subject: [PATCH] do not include iso nodes in wsbroadcast status --- awx/main/management/commands/run_wsbroadcast.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/awx/main/management/commands/run_wsbroadcast.py b/awx/main/management/commands/run_wsbroadcast.py index 5b94bed1e0..2e60d945e8 100644 --- a/awx/main/management/commands/run_wsbroadcast.py +++ b/awx/main/management/commands/run_wsbroadcast.py @@ -7,6 +7,7 @@ import re from datetime import datetime as dt from django.core.management.base import BaseCommand +from django.db.models import Q from awx.main.analytics.broadcast_websocket import ( BroadcastWebsocketStatsManager, @@ -67,7 +68,7 @@ class Command(BaseCommand): connection_started = data.get(f'{prefix}_connection_start', 'Error') if connection_started != 'Error': connection_started = datetime.datetime.fromtimestamp(connection_started) - connection_duration = (dt.now() - connection_started).total_seconds() + connection_duration = int((dt.now() - connection_started).total_seconds()) connection_state = f'\033[{connection_color}m{connection_state}\033[0m' @@ -81,8 +82,8 @@ class Command(BaseCommand): for h in hostnames: h = safe_name(h) prefix = f'awx_{h}' - messages_total = data.get(f'{prefix}_messages_received', 'N/A') - messages_per_minute = data.get(f'{prefix}_messages_received_per_minute', 'N/A') + messages_total = data.get(f'{prefix}_messages_received', '0') + messages_per_minute = data.get(f'{prefix}_messages_received_per_minute', '0') host_stats.append((h, str(int(messages_total)), str(int(messages_per_minute)))) @@ -101,7 +102,7 @@ class Command(BaseCommand): else: data[family.name] = family.samples[0].value me = Instance.objects.me() - hostnames = [i.hostname for i in Instance.objects.exclude(hostname=me.hostname)] + hostnames = [i.hostname for i in Instance.objects.exclude(Q(hostname=me.hostname) | Q(rampart_groups__controller__isnull=False))] host_stats = Command.get_connection_status(me, hostnames, data) lines = Command._format_lines(host_stats)