mirror of https://github.com/Aidaho12/haproxy-wi
parent
7c5c2443c8
commit
7151950dd9
|
@ -1,10 +1,15 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
import distro
|
||||||
from sql import out_error
|
from sql import out_error
|
||||||
from db_model import *
|
from db_model import *
|
||||||
from funct import check_ver
|
from funct import check_ver
|
||||||
|
|
||||||
|
|
||||||
def default_values():
|
def default_values():
|
||||||
|
if distro.id() == 'ubuntu':
|
||||||
|
apache_dir = 'apache2'
|
||||||
|
else:
|
||||||
|
apache_dir = 'httpd'
|
||||||
data_source = [
|
data_source = [
|
||||||
{'param': 'time_zone', 'value': 'UTC', 'section': 'main', 'desc': 'Time Zone', 'group': '1'},
|
{'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'},
|
{'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',
|
{'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',
|
'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'},
|
'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'},
|
'group': '1'},
|
||||||
{'param': 'nginx_path_error_logs', 'value': '/var/log/nginx/error.log', 'section': 'nginx',
|
{'param': 'nginx_path_error_logs', 'value': '/var/log/nginx/error.log', 'section': 'nginx',
|
||||||
'desc': 'Nginx error log', 'group': '1'},
|
'desc': 'Nginx error log', 'group': '1'},
|
||||||
|
|
|
@ -100,6 +100,8 @@ def get_user_group(**kwargs):
|
||||||
def logging(serv, action, **kwargs):
|
def logging(serv, action, **kwargs):
|
||||||
import sql
|
import sql
|
||||||
import http.cookies
|
import http.cookies
|
||||||
|
import distro
|
||||||
|
|
||||||
log_path = get_config_var('main', 'log_path')
|
log_path = get_config_var('main', 'log_path')
|
||||||
try:
|
try:
|
||||||
user_group = get_user_group()
|
user_group = get_user_group()
|
||||||
|
@ -122,10 +124,10 @@ def logging(serv, action, **kwargs):
|
||||||
login = ''
|
login = ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.system('sudo chown apache:apache -R ' + log_path)
|
if distro.id() == 'ubuntu':
|
||||||
except Exception as e:
|
|
||||||
try:
|
|
||||||
os.system('sudo chown www-data:www-data -R ' + log_path)
|
os.system('sudo chown www-data:www-data -R ' + log_path)
|
||||||
|
else:
|
||||||
|
os.system('sudo chown apache:apache -R ' + log_path)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -115,10 +115,10 @@ for s in servers:
|
||||||
servers_with_status.append(h)
|
servers_with_status.append(h)
|
||||||
servers_with_status.append(s[17])
|
servers_with_status.append(s[17])
|
||||||
else:
|
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)
|
out = funct.subprocess_execute(cmd)
|
||||||
for k in out:
|
for k in out:
|
||||||
if "Ncat:" not in k:
|
if "Connection refused" not in k:
|
||||||
out1 = out
|
out1 = out
|
||||||
else:
|
else:
|
||||||
out1 = False
|
out1 = False
|
||||||
|
|
|
@ -48,10 +48,6 @@ try:
|
||||||
for dirpath, dirnames, filenames in os.walk(log_path):
|
for dirpath, dirnames, filenames in os.walk(log_path):
|
||||||
for file in filenames:
|
for file in filenames:
|
||||||
curpath = os.path.join(dirpath, file)
|
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))
|
file_modified = datetime.datetime.fromtimestamp(os.path.getmtime(curpath))
|
||||||
if datetime.datetime.now() - file_modified > datetime.timedelta(hours=time_storage_hours):
|
if datetime.datetime.now() - file_modified > datetime.timedelta(hours=time_storage_hours):
|
||||||
os.remove(curpath)
|
os.remove(curpath)
|
||||||
|
|
Loading…
Reference in New Issue