diff --git a/app/create_db.py b/app/create_db.py index fa7fa096..b373f90d 100644 --- a/app/create_db.py +++ b/app/create_db.py @@ -1,10 +1,15 @@ #!/usr/bin/env python3 +import distro from sql import out_error from db_model import * from funct import check_ver def default_values(): + if distro.id() == 'ubuntu': + apache_dir = 'apache2' + else: + apache_dir = 'httpd' data_source = [ {'param': 'time_zone', 'value': 'UTC', 'section': 'main', 'desc': 'Time Zone', 'group': '1'}, {'param': 'proxy', 'value': '', 'section': 'main', 'desc': 'IP address and port of the proxy server. Use proto://ip:port', 'group': '1'}, @@ -53,7 +58,7 @@ def default_values(): {'param': 'haproxy_enterprise', 'value': '0', 'section': 'haproxy', 'desc': 'If you use enterprise HAProxy, set the value of this parameter to 1. The name of the service will be changed as it is required for the commercial version', 'group': '1'}, - {'param': 'apache_log_path', 'value': '/var/log/httpd/', 'section': 'logs', 'desc': 'Path to Apache logs', + {'param': 'apache_log_path', 'value': '/var/log/'+apache_dir+'/', 'section': 'logs', 'desc': 'Path to Apache logs', 'group': '1'}, {'param': 'nginx_path_error_logs', 'value': '/var/log/nginx/error.log', 'section': 'nginx', 'desc': 'Nginx error log', 'group': '1'}, diff --git a/app/funct.py b/app/funct.py index bdf627c9..3ab2a39f 100644 --- a/app/funct.py +++ b/app/funct.py @@ -100,6 +100,8 @@ def get_user_group(**kwargs): def logging(serv, action, **kwargs): import sql import http.cookies + import distro + log_path = get_config_var('main', 'log_path') try: user_group = get_user_group() @@ -122,12 +124,12 @@ def logging(serv, action, **kwargs): login = '' try: - os.system('sudo chown apache:apache -R ' + log_path) - except Exception as e: - try: + if distro.id() == 'ubuntu': os.system('sudo chown www-data:www-data -R ' + log_path) - except Exception: - pass + else: + os.system('sudo chown apache:apache -R ' + log_path) + except Exception: + pass if kwargs.get('alerting') == 1: mess = get_data('date_in_log') + action + "\n" diff --git a/app/hapservers.py b/app/hapservers.py index 816e0fb2..df4ec8e5 100644 --- a/app/hapservers.py +++ b/app/hapservers.py @@ -115,10 +115,10 @@ for s in servers: servers_with_status.append(h) servers_with_status.append(s[17]) else: - cmd = 'echo "show info" |nc %s %s -w 1 |grep -e "Ver\|Uptime:\|Process_num"' % (s[2], haproxy_sock_port) + cmd = 'echo "show info" |nc %s %s -w 1 -v|grep -e "Ver\|Uptime:\|Process_num"' % (s[2], haproxy_sock_port) out = funct.subprocess_execute(cmd) for k in out: - if "Ncat:" not in k: + if "Connection refused" not in k: out1 = out else: out1 = False diff --git a/app/viewlogs.py b/app/viewlogs.py index 672caada..7f1a499e 100644 --- a/app/viewlogs.py +++ b/app/viewlogs.py @@ -48,10 +48,6 @@ try: for dirpath, dirnames, filenames in os.walk(log_path): for file in filenames: curpath = os.path.join(dirpath, file) - try: - funct.subprocess_execute('sudo chown apache:apache ' + curpath) - except Exception: - pass file_modified = datetime.datetime.fromtimestamp(os.path.getmtime(curpath)) if datetime.datetime.now() - file_modified > datetime.timedelta(hours=time_storage_hours): os.remove(curpath)