mirror of https://github.com/Aidaho12/haproxy-wi
parent
fab9eb4837
commit
701b560df6
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import funct
|
from sql import out_error
|
||||||
from db_model import *
|
from db_model import *
|
||||||
|
from funct import check_ver
|
||||||
|
|
||||||
|
|
||||||
def default_values():
|
def default_values():
|
||||||
|
@ -43,9 +44,9 @@ def default_values():
|
||||||
'group': '1'},
|
'group': '1'},
|
||||||
{'param': 'haproxy_config_path', 'value': '/etc/haproxy/haproxy.cfg', 'section': 'haproxy', 'desc': 'Path to the HAProxy configuration file',
|
{'param': 'haproxy_config_path', 'value': '/etc/haproxy/haproxy.cfg', 'section': 'haproxy', 'desc': 'Path to the HAProxy configuration file',
|
||||||
'group': '1'},
|
'group': '1'},
|
||||||
{'param': 'server_state_file', 'value': 'stats', 'section': 'haproxy', 'desc': 'Path to the HAProxy state file',
|
{'param': 'server_state_file', 'value': '/etc/haproxy/haproxy.state', 'section': 'haproxy', 'desc': 'Path to the HAProxy state file',
|
||||||
'group': '1'},
|
'group': '1'},
|
||||||
{'param': 'haproxy_sock', 'value': '/etc/haproxy/haproxy.state', 'section': 'haproxy',
|
{'param': 'haproxy_sock', 'value': '/var/run/haproxy.sock', 'section': 'haproxy',
|
||||||
'desc': 'Socket port for HAProxy', 'group': '1'},
|
'desc': 'Socket port for HAProxy', 'group': '1'},
|
||||||
{'param': 'haproxy_sock_port', 'value': '1999', 'section': 'haproxy', 'desc': 'HAProxy sock port',
|
{'param': 'haproxy_sock_port', 'value': '1999', 'section': 'haproxy', 'desc': 'HAProxy sock port',
|
||||||
'group': '1'},
|
'group': '1'},
|
||||||
|
@ -91,7 +92,7 @@ def default_values():
|
||||||
try:
|
try:
|
||||||
Setting.insert_many(data_source).on_conflict_ignore().execute()
|
Setting.insert_many(data_source).on_conflict_ignore().execute()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
funct.out_error(e)
|
out_error(e)
|
||||||
|
|
||||||
data_source = [
|
data_source = [
|
||||||
{'username': 'admin', 'email': 'admin@localhost', 'password': '21232f297a57a5a743894a0e4a801fc3', 'role': 'superAdmin', 'groups': '1'},
|
{'username': 'admin', 'email': 'admin@localhost', 'password': '21232f297a57a5a743894a0e4a801fc3', 'role': 'superAdmin', 'groups': '1'},
|
||||||
|
@ -102,7 +103,7 @@ def default_values():
|
||||||
try:
|
try:
|
||||||
User.insert_many(data_source).on_conflict_ignore().execute()
|
User.insert_many(data_source).on_conflict_ignore().execute()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
funct.out_error(e)
|
out_error(e)
|
||||||
|
|
||||||
data_source = [
|
data_source = [
|
||||||
{'name': 'admin', 'description': 'Can do everything'},
|
{'name': 'admin', 'description': 'Can do everything'},
|
||||||
|
@ -113,12 +114,12 @@ def default_values():
|
||||||
try:
|
try:
|
||||||
Role.insert_many(data_source).on_conflict_ignore().execute()
|
Role.insert_many(data_source).on_conflict_ignore().execute()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
funct.out_error(e)
|
out_error(e)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
Groups.insert(name='All', description='All servers enter in this group').on_conflict_ignore().execute()
|
Groups.insert(name='All', description='All servers enter in this group').on_conflict_ignore().execute()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
funct.out_error(e)
|
out_error(e)
|
||||||
|
|
||||||
|
|
||||||
def update_db_v_3_4_5_22():
|
def update_db_v_3_4_5_22():
|
||||||
|
@ -236,7 +237,7 @@ def update_db_v_4_3_2_1(**kwargs):
|
||||||
try:
|
try:
|
||||||
query_res = query.execute()
|
query_res = query.execute()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
funct.out_error(e)
|
out_error(e)
|
||||||
else:
|
else:
|
||||||
groups = query_res
|
groups = query_res
|
||||||
|
|
||||||
|
@ -265,7 +266,7 @@ def update_db_v_4_5_1(**kwargs):
|
||||||
try:
|
try:
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
funct.out_error(e)
|
out_error(e)
|
||||||
else:
|
else:
|
||||||
role = cursor.fetchall()
|
role = cursor.fetchall()
|
||||||
|
|
||||||
|
@ -593,7 +594,7 @@ def update_db_v_4_5_8_2(**kwargs):
|
||||||
try:
|
try:
|
||||||
query_res = query.execute()
|
query_res = query.execute()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
funct.out_error(e)
|
out_error(e)
|
||||||
else:
|
else:
|
||||||
groups = query_res
|
groups = query_res
|
||||||
|
|
||||||
|
@ -717,7 +718,7 @@ def update_ver():
|
||||||
|
|
||||||
|
|
||||||
def update_all():
|
def update_all():
|
||||||
if funct.check_ver() is None:
|
if check_ver() is None:
|
||||||
update_db_v_3_4_5_22()
|
update_db_v_3_4_5_22()
|
||||||
update_db_v_4()
|
update_db_v_4()
|
||||||
update_db_v_41()
|
update_db_v_41()
|
||||||
|
@ -740,7 +741,7 @@ def update_all():
|
||||||
|
|
||||||
|
|
||||||
def update_all_silent():
|
def update_all_silent():
|
||||||
if funct.check_ver() is None:
|
if check_ver() is None:
|
||||||
update_db_v_3_4_5_22()
|
update_db_v_3_4_5_22()
|
||||||
update_db_v_4(silent=1)
|
update_db_v_4(silent=1)
|
||||||
update_db_v_41(silent=1)
|
update_db_v_41(silent=1)
|
||||||
|
|
37
app/funct.py
37
app/funct.py
|
@ -3,14 +3,25 @@ import cgi
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def is_ip_or_dns(server_from_request: str) -> str:
|
||||||
|
import re
|
||||||
|
ip_regex = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"
|
||||||
|
dns_regex = "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$"
|
||||||
|
try:
|
||||||
|
if re.match(ip_regex, server_from_request):
|
||||||
|
return server_from_request
|
||||||
|
else:
|
||||||
|
if re.match(dns_regex, server_from_request):
|
||||||
|
return server_from_request
|
||||||
|
else:
|
||||||
|
return ''
|
||||||
|
except:
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
form = cgi.FieldStorage()
|
form = cgi.FieldStorage()
|
||||||
serv = form.getvalue('serv')
|
serv = is_ip_or_dns(form.getvalue('serv'))
|
||||||
|
|
||||||
|
|
||||||
def get_app_dir():
|
|
||||||
d = sys.path[0]
|
|
||||||
d = d.split('/')[-1]
|
|
||||||
return sys.path[0] if d == "app" else os.path.dirname(sys.path[0])
|
|
||||||
|
|
||||||
|
|
||||||
def get_config_var(sec, var):
|
def get_config_var(sec, var):
|
||||||
|
@ -245,8 +256,8 @@ def is_admin(**kwargs):
|
||||||
try:
|
try:
|
||||||
return True if role <= level else False
|
return True if role <= level else False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('error: '+str(e))
|
# print('error: '+str(e))
|
||||||
# return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def page_for_admin(**kwargs):
|
def page_for_admin(**kwargs):
|
||||||
|
@ -934,7 +945,7 @@ def show_haproxy_log(serv, rows=10, waf='0', grep=None, hour='00', minut='00', h
|
||||||
|
|
||||||
if service == 'nginx' or service == 'haproxy':
|
if service == 'nginx' or service == 'haproxy':
|
||||||
syslog_server_enable = sql.get_setting('syslog_server_enable')
|
syslog_server_enable = sql.get_setting('syslog_server_enable')
|
||||||
if syslog_server_enable is None or syslog_server_enable == "0":
|
if syslog_server_enable is None or syslog_server_enable == 0:
|
||||||
if service == 'nginx':
|
if service == 'nginx':
|
||||||
local_path_logs = sql.get_setting('nginx_path_error_logs')
|
local_path_logs = sql.get_setting('nginx_path_error_logs')
|
||||||
commands = ["sudo cat %s| awk '$2>\"%s:00\" && $2<\"%s:00\"' |tail -%s %s %s" % (local_path_logs, date, date1, rows, grep_act, exgrep_act)]
|
commands = ["sudo cat %s| awk '$2>\"%s:00\" && $2<\"%s:00\"' |tail -%s %s %s" % (local_path_logs, date, date1, rows, grep_act, exgrep_act)]
|
||||||
|
@ -959,11 +970,11 @@ def show_haproxy_log(serv, rows=10, waf='0', grep=None, hour='00', minut='00', h
|
||||||
apache_log_path = sql.get_setting('apache_log_path')
|
apache_log_path = sql.get_setting('apache_log_path')
|
||||||
|
|
||||||
if serv == 'roxy-wi.access.log':
|
if serv == 'roxy-wi.access.log':
|
||||||
cmd = "cat %s| awk -F\"/|:\" '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % (apache_log_path+"/"+serv, date, date1, rows, grep_act, exgrep_act)
|
cmd = "cat {}| awk -F\"/|:\" '$3>\"{}:00\" && $3<\"{}:00\"' |tail -{} {} {}".format(apache_log_path+"/"+serv, date, date1, rows, grep_act, exgrep_act)
|
||||||
elif serv == 'roxy-wi.error.log':
|
elif serv == 'roxy-wi.error.log':
|
||||||
cmd = "cat %s| awk '$4>\"%s:00\" && $4<\"%s:00\"' |tail -%s %s %s" % (apache_log_path+"/"+serv, date, date1, rows, grep_act, exgrep_act)
|
cmd = "cat {}| awk '$4>\"{}:00\" && $4<\"{}:00\"' |tail -{} {} {}".format(apache_log_path+"/"+serv, date, date1, rows, grep_act, exgrep_act)
|
||||||
elif serv == 'fail2ban.log':
|
elif serv == 'fail2ban.log':
|
||||||
cmd = "cat %s| awk -F\"/|:\" '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % ("/var/log/"+serv, date, date1, rows, grep_act, exgrep_act)
|
cmd = "cat {}| awk -F\"/|:\" '$3>\"{}:00\" && $3<\"{}:00\"' |tail -{} {} {}".format("/var/log/"+serv, date, date1, rows, grep_act, exgrep_act)
|
||||||
|
|
||||||
output, stderr = subprocess_execute(cmd)
|
output, stderr = subprocess_execute(cmd)
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import funct
|
||||||
import sql
|
import sql
|
||||||
|
|
||||||
form = funct.form
|
form = funct.form
|
||||||
serv = form.getvalue("serv")
|
serv = funct.is_ip_or_dns(form.getvalue('serv'))
|
||||||
act = form.getvalue("act")
|
act = form.getvalue("act")
|
||||||
|
|
||||||
if (form.getvalue('new_metrics') or
|
if (form.getvalue('new_metrics') or
|
||||||
|
@ -108,7 +108,7 @@ if form.getvalue('ip_select') is not None:
|
||||||
funct.show_backends(serv)
|
funct.show_backends(serv)
|
||||||
|
|
||||||
if form.getvalue('ipbackend') is not None and form.getvalue('backend_server') is None:
|
if form.getvalue('ipbackend') is not None and form.getvalue('backend_server') is None:
|
||||||
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
|
haproxy_sock_port = int(sql.get_setting('haproxy_sock_port'))
|
||||||
backend = form.getvalue('ipbackend')
|
backend = form.getvalue('ipbackend')
|
||||||
cmd = 'echo "show servers state"|nc %s %s |grep "%s" |awk \'{print $4}\'' % (serv, haproxy_sock_port, backend)
|
cmd = 'echo "show servers state"|nc %s %s |grep "%s" |awk \'{print $4}\'' % (serv, haproxy_sock_port, backend)
|
||||||
output, stderr = funct.subprocess_execute(cmd)
|
output, stderr = funct.subprocess_execute(cmd)
|
||||||
|
@ -119,7 +119,7 @@ if form.getvalue('ipbackend') is not None and form.getvalue('backend_server') is
|
||||||
print(i + '<br>')
|
print(i + '<br>')
|
||||||
|
|
||||||
if form.getvalue('ipbackend') is not None and form.getvalue('backend_server') is not None:
|
if form.getvalue('ipbackend') is not None and form.getvalue('backend_server') is not None:
|
||||||
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
|
haproxy_sock_port = int(sql.get_setting('haproxy_sock_port'))
|
||||||
backend = form.getvalue('ipbackend')
|
backend = form.getvalue('ipbackend')
|
||||||
backend_server = form.getvalue('backend_server')
|
backend_server = form.getvalue('backend_server')
|
||||||
cmd = 'echo "show servers state"|nc %s %s |grep "%s" |grep "%s" |awk \'{print $5":"$19}\' |head -1' % (serv, haproxy_sock_port, backend, backend_server)
|
cmd = 'echo "show servers state"|nc %s %s |grep "%s" |grep "%s" |awk \'{print $5":"$19}\' |head -1' % (serv, haproxy_sock_port, backend, backend_server)
|
||||||
|
@ -377,12 +377,12 @@ if form.getvalue("change_pos") is not None:
|
||||||
pos = form.getvalue('change_pos')
|
pos = form.getvalue('change_pos')
|
||||||
sql.update_server_pos(pos, serv)
|
sql.update_server_pos(pos, serv)
|
||||||
|
|
||||||
if form.getvalue('ip') is not None and serv is not None:
|
if form.getvalue('show_ip') is not None and serv is not None:
|
||||||
commands = ["sudo ip a |grep inet |egrep -v '::1' |awk '{ print $2 }' |awk -F'/' '{ print $1 }'"]
|
commands = ["sudo ip a |grep inet |egrep -v '::1' |awk '{ print $2 }' |awk -F'/' '{ print $1 }'"]
|
||||||
funct.ssh_command(serv, commands, ip="1")
|
funct.ssh_command(serv, commands, ip="1")
|
||||||
|
|
||||||
if form.getvalue('showif'):
|
if form.getvalue('showif'):
|
||||||
commands = ["sudo ip link|grep 'UP' |grep -v 'lo'| awk '{print $2}' |awk -F':' '{print $1}'"]
|
commands = ["sudo ip link|grep 'UP' |grep -v 'lo'| awk '{print $2}' |awk -F':' '{print $1}'"]
|
||||||
funct.ssh_command(serv, commands, ip="1")
|
funct.ssh_command(serv, commands, ip="1")
|
||||||
|
|
||||||
if form.getvalue('action_hap') is not None and serv is not None:
|
if form.getvalue('action_hap') is not None and serv is not None:
|
||||||
|
@ -507,6 +507,8 @@ if form.getvalue('show_userlists'):
|
||||||
if act == "overviewHapservers":
|
if act == "overviewHapservers":
|
||||||
if form.getvalue('service') == 'nginx':
|
if form.getvalue('service') == 'nginx':
|
||||||
config_path = sql.get_setting('nginx_config_path')
|
config_path = sql.get_setting('nginx_config_path')
|
||||||
|
elif form.getvalue('service') == 'keepalived':
|
||||||
|
config_path = '/etc/keepalived/keepalived.conf'
|
||||||
else:
|
else:
|
||||||
config_path = sql.get_setting('haproxy_config_path')
|
config_path = sql.get_setting('haproxy_config_path')
|
||||||
commands = ["ls -l %s |awk '{ print $6\" \"$7\" \"$8}'" % config_path]
|
commands = ["ls -l %s |awk '{ print $6\" \"$7\" \"$8}'" % config_path]
|
||||||
|
@ -749,7 +751,7 @@ if serv is not None and act == "stats":
|
||||||
else:
|
else:
|
||||||
print(data.decode('utf-8'))
|
print(data.decode('utf-8'))
|
||||||
|
|
||||||
if serv is not None and form.getvalue('rows') is not None:
|
if serv is not None and form.getvalue('show_log') is not None:
|
||||||
rows = form.getvalue('rows')
|
rows = form.getvalue('rows')
|
||||||
waf = form.getvalue('waf')
|
waf = form.getvalue('waf')
|
||||||
grep = form.getvalue('grep')
|
grep = form.getvalue('grep')
|
||||||
|
@ -897,16 +899,15 @@ if serv is not None and act == "showMap":
|
||||||
|
|
||||||
print('<img src="/map%s.png" alt="map">' % date)
|
print('<img src="/map%s.png" alt="map">' % date)
|
||||||
|
|
||||||
|
|
||||||
if form.getvalue('servaction') is not None:
|
if form.getvalue('servaction') is not None:
|
||||||
server_state_file = sql.get_setting('server_state_file')
|
server_state_file = sql.get_setting('server_state_file')
|
||||||
haproxy_sock = sql.get_setting('haproxy_sock')
|
haproxy_sock = sql.get_setting('haproxy_sock')
|
||||||
enable = form.getvalue('servaction')
|
enable = form.getvalue('servaction')
|
||||||
backend = form.getvalue('servbackend')
|
backend = form.getvalue('servbackend')
|
||||||
cmd = 'echo "%s %s" |sudo socat stdio %s' % (enable, backend, haproxy_sock)
|
cmd = 'echo "{} {}" |sudo socat stdio {}'.format(enable, backend, haproxy_sock)
|
||||||
|
|
||||||
if form.getvalue('save') == "on":
|
if form.getvalue('save') == "on":
|
||||||
save_command = 'echo "show servers state" | sudo socat %s stdio > %s' % (haproxy_sock, server_state_file)
|
save_command = 'echo "show servers state" | sudo socat {} stdio > {}'.format(haproxy_sock, server_state_file)
|
||||||
command = [cmd + ';' + save_command]
|
command = [cmd + ';' + save_command]
|
||||||
else:
|
else:
|
||||||
command = [cmd]
|
command = [cmd]
|
||||||
|
@ -2290,16 +2291,16 @@ if form.getvalue('showBytes') is not None:
|
||||||
serv = form.getvalue('showBytes')
|
serv = form.getvalue('showBytes')
|
||||||
port = sql.get_setting('haproxy_sock_port')
|
port = sql.get_setting('haproxy_sock_port')
|
||||||
bin_bout = []
|
bin_bout = []
|
||||||
cmd = "echo 'show stat' |nc " + serv + " " + port + " |cut -d ',' -f 1-2,9|grep -E '[0-9]'|awk -F',' '{sum+=$3;}END{print sum;}'"
|
cmd = "echo 'show stat' |nc {} {} |cut -d ',' -f 1-2,9|grep -E '[0-9]'|awk -F',' '{{sum+=$3;}}END{{print sum;}}'".format(serv, port)
|
||||||
bin, stderr = funct.subprocess_execute(cmd)
|
bin, stderr = funct.subprocess_execute(cmd)
|
||||||
bin_bout.append(bin[0])
|
bin_bout.append(bin[0])
|
||||||
cmd = "echo 'show stat' |nc " + serv + " " + port + " |cut -d ',' -f 1-2,10|grep -E '[0-9]'|awk -F',' '{sum+=$3;}END{print sum;}'"
|
cmd = "echo 'show stat' |nc {} {} |cut -d ',' -f 1-2,10|grep -E '[0-9]'|awk -F',' '{{sum+=$3;}}END{{print sum;}}'".format(serv, port)
|
||||||
bin, stderr = funct.subprocess_execute(cmd)
|
bin, stderr = funct.subprocess_execute(cmd)
|
||||||
bin_bout.append(bin[0])
|
bin_bout.append(bin[0])
|
||||||
cmd = "echo 'show stat' |nc " + serv + " " + port + " |cut -d ',' -f 1-2,5|grep -E '[0-9]'|awk -F',' '{sum+=$3;}END{print sum;}'"
|
cmd = "echo 'show stat' |nc {} {} |cut -d ',' -f 1-2,5|grep -E '[0-9]'|awk -F',' '{{sum+=$3;}}END{{print sum;}}'".format(serv, port)
|
||||||
bin, stderr = funct.subprocess_execute(cmd)
|
bin, stderr = funct.subprocess_execute(cmd)
|
||||||
bin_bout.append(bin[0])
|
bin_bout.append(bin[0])
|
||||||
cmd = "echo 'show stat' |nc " + serv + " " + port + " |cut -d ',' -f 1-2,8|grep -E '[0-9]'|awk -F',' '{sum+=$3;}END{print sum;}'"
|
cmd = "echo 'show stat' |nc {} {} |cut -d ',' -f 1-2,8|grep -E '[0-9]'|awk -F',' '{{sum+=$3;}}END{{print sum;}}'".format(serv, port)
|
||||||
bin, stderr = funct.subprocess_execute(cmd)
|
bin, stderr = funct.subprocess_execute(cmd)
|
||||||
bin_bout.append(bin[0])
|
bin_bout.append(bin[0])
|
||||||
|
|
||||||
|
|
71
app/sql.py
71
app/sql.py
|
@ -8,10 +8,10 @@ mysql_enable = funct.get_config_var('mysql', 'enable')
|
||||||
|
|
||||||
def out_error(error):
|
def out_error(error):
|
||||||
error = str(error)
|
error = str(error)
|
||||||
# try:
|
try:
|
||||||
# funct.logging('localhost', error, haproxywi=1, login=1)
|
funct.logging('localhost', error, haproxywi=1, login=1)
|
||||||
# except Exception:
|
except Exception:
|
||||||
# funct.logging('localhost', error, haproxywi=1)
|
funct.logging('localhost', error, haproxywi=1)
|
||||||
print('error: '+error)
|
print('error: '+error)
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,9 +149,9 @@ def add_setting_for_new_group(group_id):
|
||||||
'group': group_id},
|
'group': group_id},
|
||||||
{'param': 'haproxy_config_path', 'value': '/etc/haproxy/haproxy.cfg', 'section': 'haproxy', 'desc': 'Path to the HAProxy configuration file',
|
{'param': 'haproxy_config_path', 'value': '/etc/haproxy/haproxy.cfg', 'section': 'haproxy', 'desc': 'Path to the HAProxy configuration file',
|
||||||
'group': group_id},
|
'group': group_id},
|
||||||
{'param': 'server_state_file', 'value': 'stats', 'section': 'haproxy', 'desc': 'Path to the HAProxy state file',
|
{'param': 'server_state_file', 'value': '/etc/haproxy/haproxy.state', 'section': 'haproxy', 'desc': 'Path to the HAProxy state file',
|
||||||
'group': group_id},
|
'group': group_id},
|
||||||
{'param': 'haproxy_sock', 'value': '/etc/haproxy/haproxy.state', 'section': 'haproxy',
|
{'param': 'haproxy_sock', 'value': '/var/run/haproxy.sock', 'section': 'haproxy',
|
||||||
'desc': 'Path to the HAProxy sock file', 'group': group_id},
|
'desc': 'Path to the HAProxy sock file', 'group': group_id},
|
||||||
{'param': 'haproxy_sock_port', 'value': '1999', 'section': 'haproxy', 'desc': 'Socket port for HAProxy',
|
{'param': 'haproxy_sock_port', 'value': '1999', 'section': 'haproxy', 'desc': 'Socket port for HAProxy',
|
||||||
'group': group_id},
|
'group': group_id},
|
||||||
|
@ -444,7 +444,7 @@ def select_servers(**kwargs):
|
||||||
sql = """select * from servers where enable = '1' ORDER BY groups """
|
sql = """select * from servers where enable = '1' ORDER BY groups """
|
||||||
|
|
||||||
if kwargs.get("server") is not None:
|
if kwargs.get("server") is not None:
|
||||||
sql = """select * from servers where ip='%s' """ % kwargs.get("server")
|
sql = """select * from servers where ip='{}' """.format(kwargs.get("server"))
|
||||||
if kwargs.get("full") is not None:
|
if kwargs.get("full") is not None:
|
||||||
sql = """select * from servers ORDER BY hostname """
|
sql = """select * from servers ORDER BY hostname """
|
||||||
if kwargs.get("get_master_servers") is not None:
|
if kwargs.get("get_master_servers") is not None:
|
||||||
|
@ -453,16 +453,16 @@ def select_servers(**kwargs):
|
||||||
sql = """ select servers.id, servers.hostname from servers
|
sql = """ select servers.id, servers.hostname from servers
|
||||||
left join user as user on servers.groups = user.groups
|
left join user as user on servers.groups = user.groups
|
||||||
left join uuid as uuid on user.id = uuid.user_id
|
left join uuid as uuid on user.id = uuid.user_id
|
||||||
where uuid.uuid = '%s' and servers.master = 0 and servers.type_ip = 0 and servers.enable = 1 ORDER BY servers.groups
|
where uuid.uuid = '{}' and servers.master = 0 and servers.type_ip = 0 and servers.enable = 1 ORDER BY servers.groups
|
||||||
""" % kwargs.get('uuid')
|
""".format(kwargs.get('uuid'))
|
||||||
if kwargs.get("id"):
|
if kwargs.get("id"):
|
||||||
sql = """select * from servers where id='%s' """ % kwargs.get("id")
|
sql = """select * from servers where id='{}' """.format(kwargs.get("id"))
|
||||||
if kwargs.get("hostname"):
|
if kwargs.get("hostname"):
|
||||||
sql = """select * from servers where hostname='%s' """ % kwargs.get("hostname")
|
sql = """select * from servers where hostname='{}' """.format(kwargs.get("hostname"))
|
||||||
if kwargs.get("id_hostname"):
|
if kwargs.get("id_hostname"):
|
||||||
sql = """select * from servers where hostname='%s' or id = '%s' or ip = '%s'""" % (kwargs.get("id_hostname"), kwargs.get("id_hostname"), kwargs.get("id_hostname"))
|
sql = """select * from servers where hostname='{}' or id = '{}' or ip = '{}'""".format(kwargs.get("id_hostname"), kwargs.get("id_hostname"), kwargs.get("id_hostname"))
|
||||||
if kwargs.get("server") and kwargs.get("keep_alive"):
|
if kwargs.get("server") and kwargs.get("keep_alive"):
|
||||||
sql = """select active from servers where ip='%s' """ % kwargs.get("server")
|
sql = """select active from servers where ip='{}' """.format(kwargs.get("server"))
|
||||||
try:
|
try:
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -567,7 +567,7 @@ def delete_old_uuid():
|
||||||
def update_last_act_user(uuid):
|
def update_last_act_user(uuid):
|
||||||
session_ttl = int(get_setting('session_ttl'))
|
session_ttl = int(get_setting('session_ttl'))
|
||||||
|
|
||||||
query = UUID.update(exp=funct.get_data('regular', timedelta=session_ttl))
|
query = UUID.update(exp=funct.get_data('regular', timedelta=session_ttl)).where(UUID.uuid == uuid)
|
||||||
try:
|
try:
|
||||||
query.execute()
|
query.execute()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -717,7 +717,7 @@ def get_dick_permit(**kwargs):
|
||||||
if funct.check_user_group(token=token):
|
if funct.check_user_group(token=token):
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
if grp == '1' and not only_group:
|
if grp == '1' and not only_group:
|
||||||
sql = """ select * from servers where enable = 1 %s %s %s %s %s order by pos""" % (disable, type_ip, nginx, keepalived, ip)
|
sql = """ select * from servers where enable = 1 {} {} {} {} {} order by pos""" .format(disable, type_ip, nginx, keepalived, ip)
|
||||||
else:
|
else:
|
||||||
sql = """ select * from servers where groups = '{group}' and (enable = 1 {disable}) {type_ip} {ip} {haproxy} {nginx} {keepalived} order by pos
|
sql = """ select * from servers where groups = '{group}' and (enable = 1 {disable}) {type_ip} {ip} {haproxy} {nginx} {keepalived} order by pos
|
||||||
""".format(group=grp, disable=disable, type_ip=type_ip, ip=ip, haproxy=haproxy, nginx=nginx, keepalived=keepalived)
|
""".format(group=grp, disable=disable, type_ip=type_ip, ip=ip, haproxy=haproxy, nginx=nginx, keepalived=keepalived)
|
||||||
|
@ -1640,7 +1640,18 @@ def get_setting(param, **kwargs):
|
||||||
return query_res
|
return query_res
|
||||||
else:
|
else:
|
||||||
for setting in query_res:
|
for setting in query_res:
|
||||||
return setting.value
|
if (
|
||||||
|
param == 'nginx_stats_port' or param == 'session_ttl' or param == 'token_ttl' or
|
||||||
|
param == 'stats_port' or param == 'haproxy_sock_port' or param == 'ldap_type' or
|
||||||
|
param == 'ldap_port' or param == 'ldap_enable' or param == 'log_time_storage' or
|
||||||
|
param == 'syslog_server_enable' or param == 'smon_check_interval' or
|
||||||
|
param == 'checker_check_interval' or param == 'port_scan_interval' or
|
||||||
|
param == 'smon_keep_history_range' or param == 'checker_keep_history_range' or
|
||||||
|
param == 'portscanner_keep_history_range' or param == 'haproxy_enterprise'
|
||||||
|
):
|
||||||
|
return int(setting.value)
|
||||||
|
else:
|
||||||
|
return setting.value
|
||||||
|
|
||||||
|
|
||||||
def update_setting(param, val):
|
def update_setting(param, val):
|
||||||
|
@ -1679,7 +1690,7 @@ def select_alert(**kwargs):
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
sql = """select ip from servers where alert = 1 and enable = 1 """
|
sql = """select ip from servers where alert = 1 and enable = 1 """
|
||||||
if kwargs.get("group") is not None:
|
if kwargs.get("group") is not None:
|
||||||
sql = """select ip from servers where alert = 1 and `groups` = '%s' and enable = 1 """ % kwargs.get("group")
|
sql = """select ip from servers where alert = 1 and `groups` = '{}' and enable = 1 """.format(kwargs.get("group"))
|
||||||
try:
|
try:
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -1708,7 +1719,7 @@ def select_nginx_alert(**kwargs):
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
sql = """select ip from servers where nginx_alert = 1 and enable = 1 """
|
sql = """select ip from servers where nginx_alert = 1 and enable = 1 """
|
||||||
if kwargs.get("group") is not None:
|
if kwargs.get("group") is not None:
|
||||||
sql = """select ip from servers where nginx_alert = 1 and `groups` = '%s' and enable = 1 """ % kwargs.get("group")
|
sql = """select ip from servers where nginx_alert = 1 and `groups` = '{}' and enable = 1 """.format(kwargs.get("group"))
|
||||||
try:
|
try:
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -2076,21 +2087,24 @@ def response_time(time, smon_id):
|
||||||
|
|
||||||
|
|
||||||
def smon_list(user_group):
|
def smon_list(user_group):
|
||||||
cursor = conn.cursor()
|
|
||||||
|
|
||||||
if user_group == 1:
|
if user_group == 1:
|
||||||
user_group = ''
|
query = (SMON.select(SMON.ip, SMON.port,SMON.status,SMON.en,SMON.desc,SMON.response_time,SMON.time_state,
|
||||||
|
SMON.group,SMON.script,SMON.http,SMON.http_status,SMON.body,SMON.body_status)
|
||||||
|
.order_by(SMON.group)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
user_group = "where user_group='%s'" % user_group
|
query = (SMON.select(SMON.ip, SMON.port, SMON.status, SMON.en, SMON.desc, SMON.response_time, SMON.time_state,
|
||||||
|
SMON.group, SMON.script, SMON.http, SMON.http_status, SMON.body, SMON.body_status)
|
||||||
|
.where(SMON.user_group == user_group)
|
||||||
|
.order_by(SMON.group)
|
||||||
|
)
|
||||||
|
|
||||||
sql = """ select ip,port,status,en,`desc`,response_time,time_state,`group`,script,http,http_status,body,body_status
|
|
||||||
from smon %s order by `group` desc """ % user_group
|
|
||||||
try:
|
try:
|
||||||
cursor.execute(sql)
|
query_res = query.execute()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
out_error(e)
|
out_error(e)
|
||||||
else:
|
else:
|
||||||
return cursor.fetchall()
|
return query_res
|
||||||
|
|
||||||
|
|
||||||
def insert_alerts(user_group, level, ip, port, message, service):
|
def insert_alerts(user_group, level, ip, port, message, service):
|
||||||
|
@ -2153,8 +2167,7 @@ def insert_port_scanner_settings(server_id, user_group_id, enabled, notify, hist
|
||||||
PortScannerSettings.insert(server_id=server_id, user_group_id=user_group_id, enabled=enabled,
|
PortScannerSettings.insert(server_id=server_id, user_group_id=user_group_id, enabled=enabled,
|
||||||
notify=notify, history=history).execute()
|
notify=notify, history=history).execute()
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except:
|
||||||
out_error(e)
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@ -2274,7 +2287,7 @@ def delete_alert_history(keep_interval: int, service: str):
|
||||||
|
|
||||||
def delete_portscanner_history(keep_interval: int):
|
def delete_portscanner_history(keep_interval: int):
|
||||||
query = PortScannerHistory.delete().where(
|
query = PortScannerHistory.delete().where(
|
||||||
PortScannerHistory.date < funct.get_data('regular', timedelta_minus=keep_interval))
|
PortScannerHistory.date < funct.get_data('regular', timedelta_minus=int(keep_interval)))
|
||||||
try:
|
try:
|
||||||
query.execute()
|
query.execute()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -7,14 +7,14 @@
|
||||||
{% set up = [] %}
|
{% set up = [] %}
|
||||||
{% set dis = [] %}
|
{% set dis = [] %}
|
||||||
{% for s in smon %}
|
{% for s in smon %}
|
||||||
{% if s.3 == 1 %}
|
{% if s.en == 1 %}
|
||||||
{% if s.2 == 1 and s.10 == 1 and s.12 == 1 %}
|
{% if s.status == 1 and s.http_status == 1 and s.body_status == 1 %}
|
||||||
{% if up.append('1') %} {% endif %}
|
{% if up.append('1') %} {% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if down.append('1') %} {% endif %}
|
{% if down.append('1') %} {% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if dis.append(s.7) %} {% endif %}
|
{% if dis.append(s.group) %} {% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<b>Counting state: UP: {{up|length}}, DOWN: {{down|length}}, Disabled: {{dis|length}}</b>
|
<b>Counting state: UP: {{up|length}}, DOWN: {{down|length}}, Disabled: {{dis|length}}</b>
|
||||||
|
@ -23,15 +23,15 @@
|
||||||
{% set group = [] %}
|
{% set group = [] %}
|
||||||
{% set group_prev = [] %}
|
{% set group_prev = [] %}
|
||||||
{%- for s in smon -%}
|
{%- for s in smon -%}
|
||||||
{% if s.7 %}
|
{% if s.group %}
|
||||||
{% if s.7 not in group %}
|
{% if s.group not in group %}
|
||||||
<div class="smon_group">
|
<div class="smon_group">
|
||||||
<div class="group_name">
|
<div class="group_name">
|
||||||
{{ s.7 }}
|
{{ s.group }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if group.append(s.7) %} {% endif %}
|
{% if group.append(s.group) %} {% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="smon_group">
|
<div class="smon_group">
|
||||||
<div class="group_name">
|
<div class="group_name">
|
||||||
|
@ -39,8 +39,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if s.3 == 1 %}
|
{% if s.en == 1 %}
|
||||||
{% if s.2 == 1 and s.10 == 1 and s.12 == 1 %}
|
{% if s.status == 1 and s.http_status == 1 and s.body_status == 1 %}
|
||||||
<div class="smon_services good div-server-head-up"
|
<div class="smon_services good div-server-head-up"
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="smon_services err div-server-head-down"
|
<div class="smon_services err div-server-head-down"
|
||||||
|
@ -49,37 +49,37 @@
|
||||||
<div class="smon_services dis div-server-head-dis"
|
<div class="smon_services dis div-server-head-dis"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
title="Enabled checks:
|
title="Enabled checks:
|
||||||
Port check{% if s.9 %},
|
Port check{% if s.http %},
|
||||||
HTTP status check: {{s.9.split(':')[0]}}://{{s.0}}:{{s.1}}{{s.9.split(':')[1]}}
|
HTTP status check: {{s.http.split(':')[0]}}://{{s.ip}}:{{s.port}}{{s.http.split(':')[1]}}
|
||||||
{% if s.11 and s.11 is not none %}, Body response check: {{s.11}}{% endif %}
|
{% if s.body and s.body is not none %}, Body response check: {{s.body}}{% endif %}
|
||||||
{% endif %}">
|
{% endif %}">
|
||||||
<div class="ip">
|
<div class="ip">
|
||||||
{% if s.0|string|length > 23 %}
|
{% if s.ip|string|length > 23 %}
|
||||||
<span style="font-size: 11px;">
|
<span style="font-size: 11px;">
|
||||||
{% elif s.0|string|length > 20 %}
|
{% elif s.ip|string|length > 20 %}
|
||||||
<span style="font-size: 12px;">
|
<span style="font-size: 12px;">
|
||||||
{% elif s.0|string|length > 17 %}
|
{% elif s.ip|string|length > 17 %}
|
||||||
<span style="font-size: 15px;">
|
<span style="font-size: 15px;">
|
||||||
{% else %}
|
{% else %}
|
||||||
<span>
|
<span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a href="smon.py?action=history&host={{s.0}}" title="View history for {{s.0}} host" class="link">{{s.0}}:{{s.1}}</a>
|
<a href="smon.py?action=history&host={{s.ip}}" title="View history for {{s.ip}} host" class="link">{{s.ip}}:{{s.port}}</a>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="desc">
|
<div class="desc">
|
||||||
{% if s.4 is not none %}
|
{% if s.desc is not none %}
|
||||||
<b>{{s.4}}</b>
|
<b>{{s.desc}}</b>
|
||||||
{% else %}
|
{% else %}
|
||||||
Desc: None
|
Desc: None
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="desc">
|
<div class="desc">
|
||||||
{% if s.3 == 1 %}
|
{% if s.en == 1 %}
|
||||||
{% if s.2 == 1 and s.10 == 1 and s.12 == 1 %}
|
{% if s.status == 1 and s.http_status == 1 and s.body_status == 1 %}
|
||||||
Uptime: <time class="timeago" datetime="{{s.6}}">{{s.6}}</time>
|
Uptime: <time class="timeago" datetime="{{s.time_state}}">{{s.time_state}}</time>
|
||||||
{% elif s.2 == 0 or s.10 == 0 or s.12 == 0 %}
|
{% elif s.status == 0 or s.http_status == 0 or s.body_status == 0 %}
|
||||||
Downtime: <time class="timeago" datetime="{{s.6}}">{{s.6}}</time>
|
Downtime: <time class="timeago" datetime="{{s.time_state}}">{{s.time_state}}</time>
|
||||||
{% else %}
|
{% else %}
|
||||||
Uptime: N/A
|
Uptime: N/A
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -88,14 +88,14 @@ HTTP status check: {{s.9.split(':')[0]}}://{{s.0}}:{{s.1}}{{s.9.split(':')[1]}}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="res_time">
|
<div class="res_time">
|
||||||
{% if s.3 == 1 %}
|
{% if s.en == 1 %}
|
||||||
{% if s.2 == 1 %}
|
{% if s.status == 1 %}
|
||||||
Resp time:
|
Resp time:
|
||||||
{% else %}
|
{% else %}
|
||||||
Last resp time:
|
Last resp time:
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if s.5 %}
|
{% if s.responce_time %}
|
||||||
<span title="{{s.5}} ms">{{s.5|truncate(9)}} ms</span>
|
<span title="{{s.responce_time}} ms">{{s.responce_time|truncate(9)}} ms</span>
|
||||||
{% else %}
|
{% else %}
|
||||||
N/A
|
N/A
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -103,26 +103,26 @@ HTTP status check: {{s.9.split(':')[0]}}://{{s.0}}:{{s.1}}{{s.9.split(':')[1]}}
|
||||||
N/A
|
N/A
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% if s.3 == 1 %}
|
{% if s.en == 1 %}
|
||||||
{% if s.2 == 1 and s.10 == 1 and s.12 == 1 %}
|
{% if s.status == 1 and s.http_status == 1 and s.body_status == 1 %}
|
||||||
<div class="up">
|
<div class="up">
|
||||||
<center>
|
<center>
|
||||||
UP
|
UP
|
||||||
</center>
|
</center>
|
||||||
</div>
|
</div>
|
||||||
{% elif s.10 == 0 %}
|
{% elif s.http_status == 0 %}
|
||||||
<div class="down">
|
<div class="down">
|
||||||
<center style="padding-top: 7px;">
|
<center style="padding-top: 7px;">
|
||||||
HTTP IS FAILURE
|
HTTP IS FAILURE
|
||||||
</center>
|
</center>
|
||||||
</div>
|
</div>
|
||||||
{% elif s.12 == 0 %}
|
{% elif s.body_status == 0 %}
|
||||||
<div class="down">
|
<div class="down">
|
||||||
<center style="padding-top: 7px;">
|
<center style="padding-top: 7px;">
|
||||||
BODY IS FAILURE
|
BODY IS FAILURE
|
||||||
</center>
|
</center>
|
||||||
</div>
|
</div>
|
||||||
{% elif s.2 == 3 %}
|
{% elif s.status == 3 %}
|
||||||
<div class="unknown">
|
<div class="unknown">
|
||||||
<center style="padding-top: 7px;">
|
<center style="padding-top: 7px;">
|
||||||
UNKNOWN
|
UNKNOWN
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
p {margin: 0;}
|
p {margin: 0;}
|
||||||
</style>
|
</style>
|
||||||
<table class="overview">
|
<table class="overview">
|
||||||
<caption><h3>Create new HA cluster</h3></caption>
|
<caption><h3>Create a new HA cluster</h3></caption>
|
||||||
<tr class="overviewHead">
|
<tr class="overviewHead">
|
||||||
<td class="padding10 first-collumn">Master</td>
|
<td class="padding10 first-collumn">Master</td>
|
||||||
<td>Slave</td>
|
<td>Slave</td>
|
||||||
|
@ -17,13 +17,13 @@
|
||||||
<td class="checkbox-head help_cursor"><span title="Roxy-WI will try to install HAProxy">HAProxy</span></td>
|
<td class="checkbox-head help_cursor"><span title="Roxy-WI will try to install HAProxy">HAProxy</span></td>
|
||||||
<td class="checkbox-head help_cursor"><span title="Roxy-WI will try to install Nginx">Nginx</span></td>
|
<td class="checkbox-head help_cursor"><span title="Roxy-WI will try to install Nginx">Nginx</span></td>
|
||||||
<td class="checkbox-head help_cursor"><span title="Roxy-WI will add VRRP address as a separated server">Add VIRT</span></td>
|
<td class="checkbox-head help_cursor"><span title="Roxy-WI will add VRRP address as a separated server">Add VIRT</span></td>
|
||||||
<td class="checkbox-head">SYN flood protect</td>
|
<td class="checkbox-head">SYN-flood protection</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="padding10 first-collumn">
|
<td class="padding10 first-collumn">
|
||||||
<select id="master">
|
<select id="master">
|
||||||
<option disabled selected>Choose master</option>
|
<option disabled selected>------</option>
|
||||||
{% for select in selects %}
|
{% for select in selects %}
|
||||||
<option value="{{ select.2 }}">{{ select.1 }}</option>
|
<option value="{{ select.2 }}">{{ select.1 }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select id="slave">
|
<select id="slave">
|
||||||
<option disabled selected>Choose master</option>
|
<option disabled selected>------</option>
|
||||||
{% for select in selects %}
|
{% for select in selects %}
|
||||||
<option value="{{ select.2 }}">{{ select.1 }}</option>
|
<option value="{{ select.2 }}">{{ select.1 }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<table class="overview">
|
<table class="overview">
|
||||||
<caption><h3>Or add VRRP to exist</h3></caption>
|
<caption><h3>Add VRRP to an existing cluster</h3></caption>
|
||||||
<tr class="overviewHead">
|
<tr class="overviewHead">
|
||||||
<td class="padding10 first-collumn">Master</td>
|
<td class="padding10 first-collumn">Master</td>
|
||||||
<td>Slave</td>
|
<td>Slave</td>
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td class="padding10 first-collumn">
|
<td class="padding10 first-collumn">
|
||||||
<select id="master-add">
|
<select id="master-add">
|
||||||
<option disabled selected>Choose master</option>
|
<option disabled selected>------</option>
|
||||||
{% for select in selects %}
|
{% for select in selects %}
|
||||||
<option value="{{ select.2 }}">{{ select.1 }}</option>
|
<option value="{{ select.2 }}">{{ select.1 }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -74,7 +74,7 @@
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select id="slave-add">
|
<select id="slave-add">
|
||||||
<option disabled selected>Choose master</option>
|
<option disabled selected>------</option>
|
||||||
{% for select in selects %}
|
{% for select in selects %}
|
||||||
<option value="{{ select.2 }}">{{ select.1 }}</option>
|
<option value="{{ select.2 }}">{{ select.1 }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -142,9 +142,9 @@
|
||||||
<input type="hidden" id="service" value="{{service}}" />
|
<input type="hidden" id="service" value="{{service}}" />
|
||||||
{% if service == 'nginx' or service == 'keepalived' %}
|
{% if service == 'nginx' or service == 'keepalived' %}
|
||||||
{% if s.5.0.1 == 'active' %}
|
{% if s.5.0.1 == 'active' %}
|
||||||
<span class="serverUp server-status" title="Uptime: {{s.5.0.4}}"></span>
|
<span class="serverUp server-status" title="Started: {{s.5.0.4}}"></span>
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="serverDown server-status" title="Downtime: : {{s.5.0.4}}"></span>
|
<span class="serverDown server-status" title="Stopped: : {{s.5.0.4}}"></span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if s.5 != False %}
|
{% if s.5 != False %}
|
||||||
|
@ -201,9 +201,9 @@
|
||||||
Version: {{s.5.0.0}} Process_num: {{s.5.0.3}}
|
Version: {{s.5.0.0}} Process_num: {{s.5.0.3}}
|
||||||
<br />
|
<br />
|
||||||
{% if s.5.0.1 == 'active' %}
|
{% if s.5.0.1 == 'active' %}
|
||||||
Uptime:
|
Started:
|
||||||
{% else %}
|
{% else %}
|
||||||
Downtime:
|
Stopped:
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{s.5.0.2}}
|
{{s.5.0.2}}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
|
@ -21,21 +21,30 @@
|
||||||
{% set section.section = set.section %}
|
{% set section.section = set.section %}
|
||||||
<tr class="{{ loop.cycle('odd', 'even') }} {{set.section}}-section" style="display: none">
|
<tr class="{{ loop.cycle('odd', 'even') }} {{set.section}}-section" style="display: none">
|
||||||
<td class="addName">
|
<td class="addName">
|
||||||
<a href="#{{set.param}}" title="{{set.param}}" style="color: #000;">{{set.param}}</a>
|
{{set.param}}
|
||||||
</td>
|
</td>
|
||||||
<td class="addOption">
|
<td class="addOption">
|
||||||
{% if set.param == 'ldap_password' %}
|
{% if set.param == 'ldap_password' or set.param == 'stats_password' or set.param == 'nginx_stats_password' %}
|
||||||
{% if set.value == 'None' %}
|
{% if set.value is none %}
|
||||||
<input type="password" name="{{set.param}}" id="{{set.param}}" value="" title="" size="25" class="form-control" autocomplete="new-password">
|
{{ input(set.param, size='25', type='password') }}
|
||||||
|
{% else %}
|
||||||
|
{{ input(set.param, size='25', type='password', placeholder='*****') }}
|
||||||
|
{% endif %}
|
||||||
|
{% elif set.param == 'nginx_stats_port' or set.param == 'session_ttl' or set.param == 'token_ttl' or
|
||||||
|
set.param == 'stats_port' or set.param == 'haproxy_sock_port' or set.param == 'ldap_type' or
|
||||||
|
set.param == 'ldap_port' or set.param == 'ldap_enable' or set.param == 'log_time_storage' or
|
||||||
|
set.param == 'syslog_server_enable' or set.param == 'smon_check_interval' or
|
||||||
|
set.param == 'checker_check_interval' or set.param == 'port_scan_interval' or
|
||||||
|
set.param == 'smon_keep_history_range' or set.param == 'checker_keep_history_range' or
|
||||||
|
set.param == 'portscanner_keep_history_range' or set.param == 'haproxy_enterprise' %}
|
||||||
|
|
||||||
|
{{ input(set.param, value=set.value, style='width: 210px;', type='number') }}
|
||||||
{% else %}
|
{% else %}
|
||||||
<input type="password" name="{{set.param}}" id="{{set.param}}" value="" placeholder="*****" title="" size="25" class="form-control" autocomplete="new-password">
|
{% if set.value is none %}
|
||||||
{% endif %}
|
{{ input(set.param, size='25') }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if set.value == 'None' %}
|
{{ input(set.param, value=set.value, size='25') }}
|
||||||
<input type="text" name="{{set.param}}" id="{{set.param}}" value="" title="" size="25" class="form-control">
|
{% endif %}
|
||||||
{% else %}
|
|
||||||
<input type="text" name="{{set.param}}" id="{{set.param}}" value="{{set.value}}" title="" size="25" class="form-control">
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td class="addOption">
|
<td class="addOption">
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
<td style="width: 5%;">WAF logs</td>
|
<td style="width: 5%;">WAF logs</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td>Number rows</td>
|
<td>Number rows</td>
|
||||||
<td class="padding10 help_cursor"><span title="Find in log file(supports regular expressions)">Find<span></td>
|
<td class="padding10 help_cursor"><span title="Find in a log file(supports regular expressions)">Find<span></td>
|
||||||
<td class="padding10 help_cursor"><span title="Exclude from search in log file(supports regular expressions)">Exclude<span></td>
|
<td class="padding10 help_cursor"><span title="Exclude from search in a log file(supports regular expressions)">Exclude<span></td>
|
||||||
<td style="width: 10%;">
|
<td style="width: 10%;">
|
||||||
<label for="time_range_out_hour" style="padding: 0">Time range:</label>
|
<label for="time_range_out_hour" style="padding: 0">Time range:</label>
|
||||||
{{ input('time_range_out_hour', value=hour, class='time-range', readonly='readonly') }}:{{ input('time_range_out_minut', value=minut, class='time-range', readonly='readonly') }}
|
{{ input('time_range_out_hour', value=hour, class='time-range', readonly='readonly') }}:{{ input('time_range_out_minut', value=minut, class='time-range', readonly='readonly') }}
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
<form action="" method="post" id="show_log_form">
|
<form action="" method="post" id="show_log_form">
|
||||||
{% if select_id == 'viewlogs' %}
|
{% if select_id == 'viewlogs' %}
|
||||||
<select autofocus required name="serv" id="{{ select_id }}">
|
<select autofocus required name="serv" id="{{ select_id }}">
|
||||||
<option disabled selected>Choose log</option>
|
<option disabled selected>------</option>
|
||||||
{% for select in selects %}
|
{% for select in selects %}
|
||||||
{% if page == 'for_editor' %}
|
{% if page == 'for_editor' %}
|
||||||
{% if select.1.startswith('roxy-wi') or select.1.startswith('config_edit') or select.1.startswith('port_sca') %}
|
{% if select.1.startswith('roxy-wi') or select.1.startswith('config_edit') or select.1.startswith('port_sca') %}
|
||||||
|
@ -76,8 +76,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<div id="ajax">
|
<div id="ajax"></div>
|
||||||
</div>
|
|
||||||
{% if select_id == 'viewlogs' and serv != '' and viewlogs != '' and viewlogs != 'roxy-wi.error.log' and viewlogs != 'roxy-wi.access.log' %}
|
{% if select_id == 'viewlogs' and serv != '' and viewlogs != '' and viewlogs != 'roxy-wi.error.log' and viewlogs != 'roxy-wi.access.log' %}
|
||||||
<script>
|
<script>
|
||||||
viewLogs()
|
viewLogs()
|
||||||
|
@ -88,15 +87,15 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
||||||
You can read the descriptions about all logs <a href="https://roxy-wi.org/description.py?description=logs" title="Servers description" target="_blank">here</a>
|
You can read the descriptions about all logs <a href="https://roxy-wi.org/description.py?description=logs" title="Servers description" target="_blank" class="link">here</a>
|
||||||
</div>
|
</div>
|
||||||
{% elif serv == 'roxy-wi.error.log' or serv == 'roxy-wi.access.log' %}
|
{% elif serv == 'roxy-wi.error.log' or serv == 'roxy-wi.access.log' %}
|
||||||
<script>
|
<script>
|
||||||
showApacheLog('{{serv}}');
|
showApacheLog('{{serv}}');
|
||||||
</script>
|
</script>
|
||||||
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
||||||
You can read the description about all logs file <a href="https://roxy-wi.org/description.py?description=logs" title="Servers description" target="_blank">here</a>
|
You can read the description about all logs file <a href="https://roxy-wi.org/description.py?description=logs" title="Servers description" target="_blank" class="link">here</a>
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<script>
|
<script>
|
||||||
{% if waf == '1' %}
|
{% if waf == '1' %}
|
||||||
|
|
|
@ -18,7 +18,7 @@ except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if manage_rules == '1':
|
if manage_rules == '1':
|
||||||
serv = form.getvalue('serv')
|
serv = funct.is_ip_or_dns(form.getvalue('serv'))
|
||||||
funct.check_is_server_in_group(serv)
|
funct.check_is_server_in_group(serv)
|
||||||
title = "Manage rules - Web application firewall"
|
title = "Manage rules - Web application firewall"
|
||||||
servers_waf = ''
|
servers_waf = ''
|
||||||
|
|
|
@ -265,7 +265,7 @@ $( function() {
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
url: "options.py",
|
url: "options.py",
|
||||||
data: {
|
data: {
|
||||||
ip: request.term,
|
show_ip: request.term,
|
||||||
serv: $("#serv").val(),
|
serv: $("#serv").val(),
|
||||||
token: $('#token').val()
|
token: $('#token').val()
|
||||||
},
|
},
|
||||||
|
|
|
@ -397,7 +397,7 @@ function showLog() {
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
url: "options.py",
|
url: "options.py",
|
||||||
data: {
|
data: {
|
||||||
rows: rows,
|
show_log: rows,
|
||||||
serv: $("#serv").val(),
|
serv: $("#serv").val(),
|
||||||
waf: waf,
|
waf: waf,
|
||||||
grep: grep,
|
grep: grep,
|
||||||
|
@ -616,8 +616,11 @@ function viewLogs() {
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
$("#ajax").html(data);
|
if (data.indexOf('error: ') != '-1') {
|
||||||
window.history.pushState("View logs", "View logs", cur_url[0] + "?type="+ type +
|
toastr.error(data);
|
||||||
|
} else {
|
||||||
|
$("#ajax").html(data);
|
||||||
|
window.history.pushState("View logs", "View logs", cur_url[0] + "?type=" + type +
|
||||||
"&viewlogs=" + viewlogs +
|
"&viewlogs=" + viewlogs +
|
||||||
'&rows=' + rows +
|
'&rows=' + rows +
|
||||||
'&grep=' + grep +
|
'&grep=' + grep +
|
||||||
|
@ -626,6 +629,7 @@ function viewLogs() {
|
||||||
'&minut=' + minut +
|
'&minut=' + minut +
|
||||||
'&hour1=' + hour1 +
|
'&hour1=' + hour1 +
|
||||||
'&minut1=' + minut1);
|
'&minut1=' + minut1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue