show user unsafe name

* We log stats using a safe hostname because of prometheus requirements.
However, when we display users the hostname we should use the Instance
hostname. This change outputs the Instance.hostname instead of the safe
prometheus name.
This commit is contained in:
chris meyers
2020-04-14 16:59:34 -04:00
parent 9cabf3ef4d
commit 63f56d33aa

View File

@@ -56,8 +56,8 @@ class Command(BaseCommand):
host_stats = [('hostname', 'state', 'start time', 'duration (sec)')] host_stats = [('hostname', 'state', 'start time', 'duration (sec)')]
for h in hostnames: for h in hostnames:
connection_color = '91' # red connection_color = '91' # red
h = safe_name(h) h_safe = safe_name(h)
prefix = f'awx_{h}' prefix = f'awx_{h_safe}'
connection_state = data.get(f'{prefix}_connection', 'N/A') connection_state = data.get(f'{prefix}_connection', 'N/A')
connection_started = 'N/A' connection_started = 'N/A'
connection_duration = 'N/A' connection_duration = 'N/A'
@@ -80,8 +80,8 @@ class Command(BaseCommand):
def get_connection_stats(cls, me, hostnames, data): def get_connection_stats(cls, me, hostnames, data):
host_stats = [('hostname', 'total', 'per minute')] host_stats = [('hostname', 'total', 'per minute')]
for h in hostnames: for h in hostnames:
h = safe_name(h) h_safe = safe_name(h)
prefix = f'awx_{h}' prefix = f'awx_{h_safe}'
messages_total = data.get(f'{prefix}_messages_received', '0') messages_total = data.get(f'{prefix}_messages_received', '0')
messages_per_minute = data.get(f'{prefix}_messages_received_per_minute', '0') messages_per_minute = data.get(f'{prefix}_messages_received_per_minute', '0')