diff --git a/awx/api/templates/api/setting_logging_test.md b/awx/api/templates/api/setting_logging_test.md
index 149fac28ae..5b6c49dc57 100644
--- a/awx/api/templates/api/setting_logging_test.md
+++ b/awx/api/templates/api/setting_logging_test.md
@@ -1 +1,2 @@
# Test Logging Configuration
+
diff --git a/awx/conf/views.py b/awx/conf/views.py
index 7a2a21a713..4b1f070d98 100644
--- a/awx/conf/views.py
+++ b/awx/conf/views.py
@@ -5,6 +5,9 @@
import collections
import logging
import sys
+import socket
+import os
+from urllib.parse import urlparse
# Django
from django.conf import settings
@@ -12,7 +15,7 @@ from django.http import Http404
from django.utils.translation import ugettext_lazy as _
# Django REST Framework
-from rest_framework.exceptions import PermissionDenied, ValidationError
+from rest_framework.exceptions import PermissionDenied
from rest_framework.response import Response
from rest_framework import serializers
from rest_framework import status
@@ -161,8 +164,41 @@ class SettingLoggingTest(GenericAPIView):
filter_backends = []
def post(self, request, *args, **kwargs):
- logging.getLogger('awx').info('AWX Connection Test')
- return Response(status=status.HTTP_202_ACCEPTED)
+ # Send test message to configured logger based on db settings
+ logging.getLogger('awx').error('AWX Connection Test Message')
+
+ hostname = getattr(settings, 'LOG_AGGREGATOR_HOST', None)
+ protocol = getattr(settings, 'LOG_AGGREGATOR_PROTOCOL', None)
+
+ # Check if host is reacheable
+ host = urlparse(hostname).netloc
+ response = os.system("ping -c 1 " + host)
+ if response != 0:
+ return Response({'error': 'The host is not available'}, status=status.HTTP_400_BAD_REQUEST)
+
+ # Check to ensure port is open at host
+ if protocol in ['udp', 'tcp']:
+ port = getattr(settings, 'LOG_AGGREGATOR_PORT', None)
+ # Error if port is not set when using UDP/TCP
+ if not port:
+ return Response({'error': 'Port required for ' + protocol}, status=status.HTTP_400_BAD_REQUEST)
+ else:
+ return Response(status=status.HTTP_202_ACCEPTED)
+
+ # Error if logging is not enabled
+ enabled = getattr(settings, 'LOG_AGGREGATOR_ENABLED', False)
+ if not enabled:
+ return Response({'error': 'Logging not enabled'}, status=status.HTTP_400_BAD_REQUEST)
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+
+ try:
+ s.settimeout(.5)
+ s.connect((hostname, int(port)))
+ s.shutdown(2)
+ s.close()
+ return Response(status=status.HTTP_202_ACCEPTED)
+ except Exception as e:
+ return Response({'error': str(e)}, status=status.HTTP_400_BAD_REQUEST)
# Create view functions for all of the class-based views to simplify inclusion
diff --git a/awx/main/tasks.py b/awx/main/tasks.py
index ebf29bbe97..c69a0c7f78 100644
--- a/awx/main/tasks.py
+++ b/awx/main/tasks.py
@@ -72,7 +72,7 @@ from awx.main.utils import (get_ssh_version, update_scm_url,
ignore_inventory_group_removal, extract_ansible_vars, schedule_task_manager,
get_awx_version)
from awx.main.utils.ansible import read_ansible_config
-from awx.main.utils.common import get_ansible_version, _get_ansible_version, get_custom_venv_choices
+from awx.main.utils.common import _get_ansible_version, get_custom_venv_choices
from awx.main.utils.external_logging import reconfigure_rsyslog
from awx.main.utils.safe_yaml import safe_dump, sanitize_jinja
from awx.main.utils.reload import stop_local_services
diff --git a/awx/main/utils/reload.py b/awx/main/utils/reload.py
index 04868f06d0..9c71697516 100644
--- a/awx/main/utils/reload.py
+++ b/awx/main/utils/reload.py
@@ -6,8 +6,6 @@ import subprocess
import logging
import os
-# Django
-from django.conf import settings
logger = logging.getLogger('awx.main.utils.reload')
diff --git a/awx/ui/client/src/configuration/forms/system-form/configuration-system.controller.js b/awx/ui/client/src/configuration/forms/system-form/configuration-system.controller.js
index 4178b2f929..63fed820d2 100644
--- a/awx/ui/client/src/configuration/forms/system-form/configuration-system.controller.js
+++ b/awx/ui/client/src/configuration/forms/system-form/configuration-system.controller.js
@@ -215,7 +215,7 @@ export default [
});
})
.catch(({ data, status }) => {
- if (status === 500) {
+ if (status === 400 || status == 500) {
ngToast.danger({
content: '' +
i18n._('Log aggregator test failed.
Detail: ') + $filter('sanitize')(data.error),
diff --git a/tools/docker-compose/supervisor.conf b/tools/docker-compose/supervisor.conf
index a28a230da1..0b7fd029f8 100644
--- a/tools/docker-compose/supervisor.conf
+++ b/tools/docker-compose/supervisor.conf
@@ -72,7 +72,11 @@ stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
[program:awx-rsyslogd]
+<<<<<<< HEAD
command = rsyslogd -n -i /var/run/rsyslog/rsyslog.pid -f /var/lib/awx/rsyslog/rsyslog.conf
+=======
+command = rsyslogd -n -i /var/run/tower/sockets/rsyslog.pid -f /var/lib/awx/rsyslog/rsyslog.conf
+>>>>>>> 3a8bd7c40... Fix Logging settings "Test" button functionality
autostart = true
autorestart = true
stopwaitsecs = 1