mirror of https://github.com/Aidaho12/haproxy-wi
parent
3d508cb0b2
commit
5b402b597b
|
@ -518,7 +518,7 @@ def update_db_v_3(**kwargs):
|
|||
except sqltool.Error as e:
|
||||
if kwargs.get('silent') != 1:
|
||||
if e.args[0] == 'duplicate column name: section' or e == " 1060 (42S21): Duplicate column name 'section' ":
|
||||
print('Updating... go to version 3.2')
|
||||
print('Updating... go to version 3.1')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
return False
|
||||
|
@ -550,7 +550,7 @@ def update_db_v_31(**kwargs):
|
|||
"INSERT INTO settings (param, value, section, `desc`) values('tmp_config_path', '/tmp/', 'haproxy', 'Temp store configs, for haproxy check');",
|
||||
"INSERT INTO settings (param, value, section, `desc`) values('cert_path', '/etc/ssl/certs/', 'haproxy', 'Path to SSL dir');",
|
||||
"INSERT INTO settings (param, value, section, `desc`) values('firewall_enable', '0', 'haproxy', 'If enable this option Haproxy-wi will be configure firewalld based on config port');",
|
||||
"update settings set `section` = 'main', `desc` = 'Path to black/white lists` where param = 'lists_path' "]
|
||||
"update settings set `section` = 'main', `desc` = 'Path to black/white lists' where param = 'lists_path' "]
|
||||
try:
|
||||
for i in sql:
|
||||
cur.execute(i)
|
||||
|
@ -558,7 +558,7 @@ def update_db_v_31(**kwargs):
|
|||
except sqltool.Error as e:
|
||||
if kwargs.get('silent') != 1:
|
||||
if e.args[0] == 'duplicate column name: desc' or e == "1060 (42S21): Duplicate column name 'desc' ":
|
||||
print('')
|
||||
print('Updating... go to version 3.2')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
return False
|
||||
|
@ -603,6 +603,27 @@ def update_db_v_3_21(**kwargs):
|
|||
return True
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
def update_db_v_3_2_1(**kwargs):
|
||||
con, cur = get_cur()
|
||||
sql = """
|
||||
insert into `settings` (param, value, section, `desc`) values ('apache_log_path', '/var/log/httpd/', 'logs', 'Path to Apache logs');
|
||||
"""
|
||||
try:
|
||||
cur.execute(sql)
|
||||
con.commit()
|
||||
except sqltool.Error as e:
|
||||
if kwargs.get('silent') != 1:
|
||||
if e.args[0] == 'column param is not unique' or e == "1062 (23000): Duplicate entry 'lists_path' for key 'param'":
|
||||
print('DB was update')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
return False
|
||||
else:
|
||||
print("Updating... go to version 3.0<br />")
|
||||
return True
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
def update_all():
|
||||
update_db_v_2_0_1()
|
||||
|
@ -624,6 +645,7 @@ def update_all():
|
|||
update_db_v_31()
|
||||
update_db_v_3_2()
|
||||
update_db_v_3_21()
|
||||
update_db_v_3_2_1()
|
||||
|
||||
def update_all_silent():
|
||||
update_db_v_2_0_1(silent=1)
|
||||
|
@ -645,4 +667,5 @@ def update_all_silent():
|
|||
update_db_v_31(silent=1)
|
||||
update_db_v_3_2(silent=1)
|
||||
update_db_v_3_21(silent=1)
|
||||
update_db_v_3_2_1(silent=1)
|
||||
|
|
@ -362,9 +362,9 @@ def upload_and_restart(serv, cfg, **kwargs):
|
|||
commands = [ "sudo mv -f " + tmp_file + " /etc/keepalived/keepalived.conf", "sudo systemctl restart keepalived" ]
|
||||
else:
|
||||
if kwargs.get("just_save") == "save":
|
||||
commands = [ "sudo /sbin/haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + sql.get_setting('haproxy_config_path') ]
|
||||
commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + sql.get_setting('haproxy_config_path') ]
|
||||
else:
|
||||
commands = [ "sudo /sbin/haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + sql.get_setting('haproxy_config_path') + " && sudo " + sql.get_setting('restart_command') ]
|
||||
commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + sql.get_setting('haproxy_config_path') + " && sudo " + sql.get_setting('restart_command') ]
|
||||
try:
|
||||
if sql.get_setting('firewall_enable') == "1":
|
||||
commands.extend(open_port_firewalld(cfg))
|
||||
|
@ -452,11 +452,11 @@ def ssh_command(serv, commands, **kwargs):
|
|||
else:
|
||||
return stdout.read().decode(encoding='UTF-8')
|
||||
|
||||
print(stderr.read().decode(encoding='UTF-8'))
|
||||
print("<div class='alert alert-warning'>"+stderr.read().decode(encoding='UTF-8')+"</div>")
|
||||
try:
|
||||
ssh.close()
|
||||
except:
|
||||
print(ssh)
|
||||
print("<div class='alert alert-danger'>"+ssh+"</div>")
|
||||
pass
|
||||
|
||||
def escape_html(text):
|
||||
|
|
|
@ -210,6 +210,7 @@ if serv is not None and form.getvalue('rows1') is not None:
|
|||
minut1 = form.getvalue('minut1')
|
||||
date = hour+':'+minut
|
||||
date1 = hour1+':'+minut1
|
||||
apache_log_path = sql.get_setting('apache_log_path')
|
||||
|
||||
if grep is not None:
|
||||
grep_act = '|grep'
|
||||
|
@ -218,9 +219,9 @@ if serv is not None and form.getvalue('rows1') is not None:
|
|||
grep = ''
|
||||
|
||||
if serv == 'haproxy-wi.access.log':
|
||||
cmd="cat %s| awk -F\"/|:\" '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % ('/var/log/httpd/'+serv, date, date1, rows, grep_act, grep)
|
||||
cmd="cat %s| awk -F\"/|:\" '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % (apache_log_path+"/"+serv, date, date1, rows, grep_act, grep)
|
||||
else:
|
||||
cmd="cat %s| awk '$4>\"%s:00\" && $4<\"%s:00\"' |tail -%s %s %s" % ('/var/log/httpd/'+serv, date, date1, rows, grep_act, grep)
|
||||
cmd="cat %s| awk '$4>\"%s:00\" && $4<\"%s:00\"' |tail -%s %s %s" % (apache_log_path+"/"+serv, date, date1, rows, grep_act, grep)
|
||||
|
||||
output, stderr = funct.subprocess_execute(cmd)
|
||||
|
||||
|
|
|
@ -10,7 +10,9 @@
|
|||
Server
|
||||
{% endif %}
|
||||
</td>
|
||||
{% if onclick != 'viewLogs()' %}
|
||||
<td style="width: 5%;">WAF logs</td>
|
||||
{% endif %}
|
||||
<td style="width: 10%;">Number rows</td>
|
||||
<td class="padding10" style="width: 10%;">Ex for grep</td>
|
||||
<td style="width: 10%;">
|
||||
|
@ -45,9 +47,11 @@
|
|||
{% endif %}
|
||||
</select>
|
||||
</td>
|
||||
{% if onclick != 'viewLogs()' %}
|
||||
<td>
|
||||
<label for="waf"></label><input type="checkbox" id="waf">
|
||||
</td>
|
||||
{% endif %}
|
||||
<td class="padding10" style="width: 10%;">
|
||||
<input type="number" name="rows" id="rows" value="{{ rows }}" class="form-control" required>
|
||||
</td>
|
||||
|
|
|
@ -74,12 +74,12 @@ def start_waf_worker(serv):
|
|||
port = sql.get_setting('haproxy_sock_port')
|
||||
cmd = "tools/metrics_waf_worker.py %s --port %s &" % (serv, port)
|
||||
os.system(cmd)
|
||||
funct.logging("localhost", " Masrer started new metrics worker for: "+serv, metrics=1)
|
||||
funct.logging("localhost", " Masrer started new WAF metrics worker for: "+serv, metrics=1)
|
||||
|
||||
def kill_waf_worker(serv):
|
||||
cmd = "ps ax |grep 'tools/metrics_waf_worker.py %s'|grep -v grep |awk '{print $1}' |xargs kill" % serv
|
||||
output, stderr = funct.subprocess_execute(cmd)
|
||||
funct.logging("localhost", " Masrer killed metrics worker for: "+serv, metrics=1)
|
||||
funct.logging("localhost", " Masrer killed WAF metrics worker for: "+serv, metrics=1)
|
||||
if stderr:
|
||||
funct.logging("localhost", stderr, metrics=1)
|
||||
|
||||
|
|
Loading…
Reference in New Issue