mirror of https://github.com/Aidaho12/haproxy-wi
parent
aefed2d987
commit
f7dd5398da
|
@ -20,58 +20,58 @@ aftersave = ""
|
|||
|
||||
try:
|
||||
user, user_id, role, token, servers = funct.get_users_params()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if service == 'keepalived':
|
||||
title = "Working with Keepalived configs"
|
||||
title = "Working with Keepalived configuration files"
|
||||
action = "config.py?service=keepalived"
|
||||
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
||||
format = 'conf'
|
||||
file_format = 'conf'
|
||||
servers = sql.get_dick_permit(keepalived=1)
|
||||
elif service == 'nginx':
|
||||
title = "Working with Nginx configs"
|
||||
title = "Working with Nginx configuration files"
|
||||
action = "config.py?service=nginx"
|
||||
configs_dir = funct.get_config_var('configs', 'nginx_save_configs_dir')
|
||||
format = 'conf'
|
||||
file_format = 'conf'
|
||||
servers = sql.get_dick_permit(nginx=1)
|
||||
else:
|
||||
title = "Working with HAProxy configs"
|
||||
title = "Working with HAProxy configuration files"
|
||||
action = "config.py"
|
||||
configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
format = 'cfg'
|
||||
file_format = 'cfg'
|
||||
servers = sql.get_dick_permit()
|
||||
|
||||
if serv is not None:
|
||||
cfg = configs_dir + serv + "-" + funct.get_data('config') + "."+format
|
||||
cfg = configs_dir + serv + "-" + funct.get_data('config') + "."+file_format
|
||||
|
||||
if serv is not None and form.getvalue('open') is not None :
|
||||
if serv is not None and form.getvalue('open') is not None:
|
||||
funct.check_is_server_in_group(serv)
|
||||
if service == 'keepalived':
|
||||
error = funct.get_config(serv, cfg, keepalived=1)
|
||||
try:
|
||||
funct.logging(serv, " Keepalived config has opened for ")
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
elif service == 'nginx':
|
||||
error = funct.get_config(serv, cfg, nginx=1)
|
||||
try:
|
||||
funct.logging(serv, " Nginx config has opened ")
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
error = funct.get_config(serv, cfg)
|
||||
try:
|
||||
funct.logging(serv, " HAProxy config has opened ")
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
conf = open(cfg, "r")
|
||||
config_read = conf.read()
|
||||
conf.close
|
||||
conf.close()
|
||||
except IOError:
|
||||
error += '<br />Can\'t read import config file'
|
||||
error += '<br />Cannot read import config file'
|
||||
|
||||
os.system("/bin/mv %s %s.old" % (cfg, cfg))
|
||||
|
||||
|
@ -79,7 +79,7 @@ if serv is not None and form.getvalue('config') is not None:
|
|||
funct.check_is_server_in_group(serv)
|
||||
try:
|
||||
funct.logging(serv, "config.py edited config")
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
config = form.getvalue('config')
|
||||
|
@ -104,20 +104,20 @@ if serv is not None and form.getvalue('config') is not None:
|
|||
os.system("/bin/rm -f " + configs_dir + "*.old")
|
||||
|
||||
|
||||
template = template.render(h2 = 1, title = title,
|
||||
role = role,
|
||||
action = action,
|
||||
user = user,
|
||||
select_id = "serv",
|
||||
serv = serv,
|
||||
aftersave = aftersave,
|
||||
config = config_read,
|
||||
cfg = cfg,
|
||||
selects = servers,
|
||||
stderr = stderr,
|
||||
error = error,
|
||||
note = 1,
|
||||
versions = funct.versions(),
|
||||
service = service,
|
||||
token = token)
|
||||
template = template.render(h2=1, title=title,
|
||||
role=role,
|
||||
action=action,
|
||||
user=user,
|
||||
select_id="serv",
|
||||
serv=serv,
|
||||
aftersave=aftersave,
|
||||
config=config_read,
|
||||
cfg=cfg,
|
||||
selects=servers,
|
||||
stderr=stderr,
|
||||
error=error,
|
||||
note=1,
|
||||
versions=funct.versions(),
|
||||
service=service,
|
||||
token=token)
|
||||
print(template)
|
||||
|
|
|
@ -297,13 +297,13 @@ def update_db_v_3_8_1(**kwargs):
|
|||
try:
|
||||
cur.execute(i)
|
||||
con.commit()
|
||||
except sqltool.Error as e:
|
||||
except sqltool.Error:
|
||||
pass
|
||||
else:
|
||||
if kwargs.get('silent') != 1:
|
||||
print('Updating... go to version 3.12.0.0')
|
||||
return True
|
||||
cur.close()
|
||||
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
|
@ -359,11 +359,10 @@ def update_db_v_3_13(**kwargs):
|
|||
print('Updating... go to version 4.0.0')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
return False
|
||||
else:
|
||||
print("Updating... go to version 4.0.0")
|
||||
return True
|
||||
cur.close()
|
||||
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
|
@ -388,8 +387,8 @@ def update_db_v_4(**kwargs):
|
|||
else:
|
||||
if kwargs.get('silent') != 1:
|
||||
print('Updating... one more for version 4.0.0')
|
||||
return True
|
||||
cur.close()
|
||||
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
|
@ -407,11 +406,10 @@ def update_db_v_41(**kwargs):
|
|||
print('Updating... one more for version 4.0.0')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
return False
|
||||
else:
|
||||
print("Updating... one more for version 4.0.0")
|
||||
return True
|
||||
cur.close()
|
||||
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
|
@ -429,11 +427,10 @@ def update_db_v_42(**kwargs):
|
|||
print('Updating... go to version 4.2.3')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
return False
|
||||
else:
|
||||
print("Updating... go to version 4.2.3")
|
||||
return True
|
||||
cur.close()
|
||||
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
|
@ -451,9 +448,7 @@ def update_db_v_4_2_3(**kwargs):
|
|||
print('Updating... go to version 4.3.0')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
@ -472,9 +467,7 @@ def update_db_v_4_3(**kwargs):
|
|||
print('Updating... go to version 4.3.0')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
@ -498,9 +491,7 @@ def update_db_v_4_3_0(**kwargs):
|
|||
print('Updating... go to version 4.3.1')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
@ -519,11 +510,10 @@ def update_db_v_4_3_1(**kwargs):
|
|||
print('Updating... go to version 4.3.2')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
return False
|
||||
else:
|
||||
print("DB was update to 4.3.1")
|
||||
return True
|
||||
cur.close()
|
||||
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
|
@ -541,11 +531,10 @@ def update_db_v_4_3_2(**kwargs):
|
|||
print('Updating... go to version 4.4.0')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
return False
|
||||
else:
|
||||
print("Updating... go to version 4.4.0")
|
||||
return True
|
||||
cur.close()
|
||||
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
|
@ -581,9 +570,7 @@ def update_db_v_4_4(**kwargs):
|
|||
print('Updating... go to version 4.4.1')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
@ -607,9 +594,7 @@ def update_db_v_4_4_2(**kwargs):
|
|||
print('Updating... go to version 4.4.1')
|
||||
else:
|
||||
print("Updating... go to version to 4.4.1")
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
@ -628,14 +613,11 @@ def update_db_v_4_4_2_1(**kwargs):
|
|||
print('Updating... go to version 4.4.2')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
cur.close()
|
||||
con.close()
|
||||
return False
|
||||
else:
|
||||
print("DB was update to 4.4.2")
|
||||
cur.close()
|
||||
con.close()
|
||||
return True
|
||||
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def update_db_v_4_3_2_1(**kwargs):
|
||||
|
@ -688,9 +670,7 @@ def update_db_v_4_5(**kwargs):
|
|||
print('Updating... go to version 4.5.0')
|
||||
else:
|
||||
print("Updating... go to version to 4.5.0")
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
@ -723,14 +703,13 @@ def update_db_v_4_5_1(**kwargs):
|
|||
else:
|
||||
if kwargs.get('silent') != 1:
|
||||
print('DB was update to 4.5.0')
|
||||
return True
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def update_ver(**kwargs):
|
||||
con, cur = get_cur()
|
||||
sql = """update version set version = '4.5.2.0'; """
|
||||
sql = """update version set version = '4.5.3.0'; """
|
||||
try:
|
||||
cur.execute(sql)
|
||||
con.commit()
|
||||
|
|
35
app/funct.py
35
app/funct.py
|
@ -19,12 +19,12 @@ def get_config_var(sec, var):
|
|||
path_config = "haproxy-wi.cfg"
|
||||
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||||
config.read(path_config)
|
||||
except:
|
||||
except Exception:
|
||||
print('Content-type: text/html\n')
|
||||
print('<center><div class="alert alert-danger">Check the config file, whether it exists and the path. Must be: app/haproxy-webintarface.config</div>')
|
||||
print('<center><div class="alert alert-danger">Check the config file, whether it exists and the path. Must be: app/haproxy-wi.cfg</div>')
|
||||
try:
|
||||
return config.get(sec, var)
|
||||
except:
|
||||
except Exception:
|
||||
print('Content-type: text/html\n')
|
||||
print('<center><div class="alert alert-danger">Check the config file. Presence section %s and parameter %s</div>' % (sec, var))
|
||||
|
||||
|
@ -35,7 +35,7 @@ def get_data(type):
|
|||
import sql
|
||||
try:
|
||||
now_utc = datetime.now(timezone(sql.get_setting('time_zone')))
|
||||
except:
|
||||
except Exception:
|
||||
now_utc = datetime.now(timezone('UTC'))
|
||||
if type == 'config':
|
||||
fmt = "%Y-%m-%d.%H:%M:%S"
|
||||
|
@ -50,6 +50,7 @@ def get_data(type):
|
|||
def get_user_group(**kwargs):
|
||||
import sql
|
||||
import http.cookies
|
||||
|
||||
try:
|
||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
user_group_id = cookie.get('group')
|
||||
|
@ -61,7 +62,7 @@ def get_user_group(**kwargs):
|
|||
user_group = g[0]
|
||||
else:
|
||||
user_group = g[1]
|
||||
except:
|
||||
except Exception:
|
||||
user_group = ''
|
||||
|
||||
return user_group
|
||||
|
@ -79,13 +80,13 @@ def logging(serv, action, **kwargs):
|
|||
|
||||
try:
|
||||
ip = cgi.escape(os.environ["REMOTE_ADDR"])
|
||||
except:
|
||||
except Exception:
|
||||
ip = ''
|
||||
|
||||
try:
|
||||
user_uuid = cookie.get('uuid')
|
||||
login = sql.get_user_name_by_uuid(user_uuid.value)
|
||||
except:
|
||||
except Exception:
|
||||
login = ''
|
||||
|
||||
if kwargs.get('alerting') == 1:
|
||||
|
@ -114,7 +115,7 @@ def logging(serv, action, **kwargs):
|
|||
except IOError as e:
|
||||
print('<center><div class="alert alert-danger">Can\'t write log. Please check log_path in config %e</div></center>' % e)
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def telegram_send_mess(mess, **kwargs):
|
||||
import telebot
|
||||
|
@ -132,7 +133,7 @@ def telegram_send_mess(mess, **kwargs):
|
|||
channel_name = telegram[2]
|
||||
|
||||
if token_bot == '' or channel_name == '':
|
||||
mess = " Fatal: Can't send message. Add Telegram chanel before use alerting at this servers group"
|
||||
mess = " Fatal: Can't send message. Add Telegram channel before use alerting at this servers group"
|
||||
print(mess)
|
||||
logging('localhost', mess, haproxywi=1)
|
||||
sys.exit()
|
||||
|
@ -144,7 +145,7 @@ def telegram_send_mess(mess, **kwargs):
|
|||
bot.send_message(chat_id=channel_name, text=mess)
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
logging('localhost', str(e).decode(encoding='UTF-8'), haproxywi=1)
|
||||
logging('localhost', str(e), haproxywi=1)
|
||||
sys.exit()
|
||||
|
||||
|
||||
|
@ -233,6 +234,7 @@ def ssh_connect(serv, **kwargs):
|
|||
ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name = return_ssh_keys_path(serv)
|
||||
|
||||
servers = sql.select_servers(server=serv)
|
||||
ssh_port = 22
|
||||
for server in servers:
|
||||
ssh_port = server[10]
|
||||
|
||||
|
@ -316,7 +318,7 @@ def diff_config(oldcfg, cfg):
|
|||
try:
|
||||
user_uuid = cookie.get('uuid')
|
||||
login = sql.get_user_name_by_uuid(user_uuid.value)
|
||||
except:
|
||||
except Exception:
|
||||
login = ''
|
||||
|
||||
output, stderr = subprocess_execute(cmd)
|
||||
|
@ -429,19 +431,19 @@ def rewrite_section(start_line, end_line, config, section):
|
|||
|
||||
def get_backends_from_config(serv, backends='', **kwargs):
|
||||
configs_dir = get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
format = 'cfg'
|
||||
format_cfg = 'cfg'
|
||||
|
||||
try:
|
||||
cfg = configs_dir+get_files(dir=configs_dir, format=format)[0]
|
||||
cfg = configs_dir+get_files(dir=configs_dir, format=format_cfg)[0]
|
||||
except Exception as e:
|
||||
logging('localhost', str(e), haproxywi=1)
|
||||
try:
|
||||
cfg = configs_dir + serv + "-" + get_data('config') + '.'+format
|
||||
except:
|
||||
cfg = configs_dir + serv + "-" + get_data('config') + '.'+format_cfg
|
||||
except Exception:
|
||||
logging('localhost', ' Cannot generate cfg path', haproxywi=1)
|
||||
try:
|
||||
error = get_config(serv, cfg)
|
||||
except:
|
||||
except Exception:
|
||||
logging('localhost', ' Cannot download config', haproxywi=1)
|
||||
print('error: Cannot get backends')
|
||||
sys.exit()
|
||||
|
@ -488,6 +490,7 @@ def install_haproxy(serv, **kwargs):
|
|||
stats_password = sql.get_setting('stats_password')
|
||||
proxy = sql.get_setting('proxy')
|
||||
hapver = kwargs.get('hapver')
|
||||
ssh_port = 22
|
||||
ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name = return_ssh_keys_path(serv)
|
||||
|
||||
if ssh_enable == 0:
|
||||
|
|
199
app/options.py
199
app/options.py
|
@ -37,7 +37,7 @@ if form.getvalue('getcerts') is not None and serv is not None:
|
|||
try:
|
||||
funct.ssh_command(serv, commands, ip="1")
|
||||
except Exception as e:
|
||||
print('error: Cannot connect to the server: ' + str(e))
|
||||
print('error: Cannot connect to the server: ' + e.args[0])
|
||||
|
||||
if form.getvalue('checkSshConnect') is not None and serv is not None:
|
||||
print(funct.ssh_command(serv, ["ls -1t"]))
|
||||
|
@ -48,8 +48,8 @@ if form.getvalue('getcert') is not None and serv is not None:
|
|||
commands = ["cat " + cert_path + "/" + id]
|
||||
try:
|
||||
funct.ssh_command(serv, commands, ip="1")
|
||||
except:
|
||||
print('error: Can not connect to the server')
|
||||
except Exception as e:
|
||||
print('error: Can not connect to the server ' + e.args[0])
|
||||
|
||||
if serv and form.getvalue('ssl_cert'):
|
||||
cert_local_dir = os.path.dirname(os.getcwd()) + "/" + sql.get_setting('ssl_local_path')
|
||||
|
@ -107,8 +107,7 @@ if form.getvalue('ipbackend') is not None and form.getvalue('backend_server') is
|
|||
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
|
||||
backend = form.getvalue('ipbackend')
|
||||
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)
|
||||
output, stderr = funct.subprocess_execute(cmd)
|
||||
print(output[0])
|
||||
|
||||
|
@ -130,13 +129,11 @@ if form.getvalue('backend_ip') is not None:
|
|||
MASTERS = sql.is_master(serv)
|
||||
for master in MASTERS:
|
||||
if master[0] is not None:
|
||||
cmd = 'echo "set server %s/%s addr %s port %s check-port %s" |nc %s %s' % (
|
||||
backend_backend, backend_server, backend_ip, backend_port, backend_port, master[0], haproxy_sock_port)
|
||||
cmd = 'echo "set server %s/%s addr %s port %s check-port %s" |nc %s %s' % (backend_backend, backend_server, backend_ip, backend_port, backend_port, master[0], haproxy_sock_port)
|
||||
output, stderr = funct.subprocess_execute(cmd)
|
||||
print(output[0])
|
||||
|
||||
cmd = 'echo "set server %s/%s addr %s port %s check-port %s" |nc %s %s' % (
|
||||
backend_backend, backend_server, backend_ip, backend_port, backend_port, serv, haproxy_sock_port)
|
||||
cmd = 'echo "set server %s/%s addr %s port %s check-port %s" |nc %s %s' % (backend_backend, backend_server, backend_ip, backend_port, backend_port, serv, haproxy_sock_port)
|
||||
output, stderr = funct.subprocess_execute(cmd)
|
||||
|
||||
if stderr != '':
|
||||
|
@ -147,8 +144,7 @@ if form.getvalue('backend_ip') is not None:
|
|||
cfg = configs_dir + serv + "-" + funct.get_data('config') + ".cfg"
|
||||
|
||||
error = funct.get_config(serv, cfg)
|
||||
cmd = 'string=`grep %s %s -n -A25 |grep "server %s" |head -1|awk -F"-" \'{print $1}\'` && sed -Ei "$( echo $string)s/((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5]):[0-9]+/%s:%s/g" %s' % (
|
||||
backend_backend, cfg, backend_server, backend_ip, backend_port, cfg)
|
||||
cmd = 'string=`grep %s %s -n -A25 |grep "server %s" |head -1|awk -F"-" \'{print $1}\'` && sed -Ei "$( echo $string)s/((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5]):[0-9]+/%s:%s/g" %s' % (backend_backend, cfg, backend_server, backend_ip, backend_port, cfg)
|
||||
output, stderr = funct.subprocess_execute(cmd)
|
||||
stderr = funct.master_slave_upload_and_restart(serv, cfg, just_save='save')
|
||||
|
||||
|
@ -187,8 +183,7 @@ if form.getvalue('maxconn_frontend') is not None:
|
|||
cfg = configs_dir + serv + "-" + funct.get_data('config') + ".cfg"
|
||||
|
||||
error = funct.get_config(serv, cfg)
|
||||
cmd = 'string=`grep %s %s -n -A5 |grep maxcon -n |awk -F":" \'{print $2}\'|awk -F"-" \'{print $1}\'` && sed -Ei "$( echo $string)s/[0-9]+/%s/g" %s' % (
|
||||
frontend, cfg, maxconn, cfg)
|
||||
cmd = 'string=`grep %s %s -n -A5 |grep maxcon -n |awk -F":" \'{print $2}\'|awk -F"-" \'{print $1}\'` && sed -Ei "$( echo $string)s/[0-9]+/%s/g" %s' % (frontend, cfg, maxconn, cfg)
|
||||
output, stderr = funct.subprocess_execute(cmd)
|
||||
stderr = funct.master_slave_upload_and_restart(serv, cfg, just_save='save')
|
||||
print('success: Maxconn for %s has been set to %s ' % (frontend, maxconn))
|
||||
|
@ -419,7 +414,7 @@ if form.getvalue('action_service') is not None:
|
|||
elif action == "restart":
|
||||
cmd = "sudo systemctl restart %s --now" % serv
|
||||
output, stderr = funct.subprocess_execute(cmd)
|
||||
funct.logging('localhost', ' The service ' + serv + 'was ' + action + 'ed', haproxywi=1, login=1)
|
||||
funct.logging('localhost', ' The service ' + serv + ' was ' + action + 'ed', haproxywi=1, login=1)
|
||||
|
||||
if act == "overviewHapserverBackends":
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
@ -429,29 +424,29 @@ if act == "overviewHapserverBackends":
|
|||
service = form.getvalue('service')
|
||||
if service == 'haproxy':
|
||||
configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
format = 'cfg'
|
||||
format_file = 'cfg'
|
||||
elif service == 'nginx':
|
||||
configs_dir = funct.get_config_var('configs', 'nginx_save_configs_dir')
|
||||
format = 'conf'
|
||||
format_file = 'conf'
|
||||
try:
|
||||
sections = funct.get_sections(configs_dir + funct.get_files(dir=configs_dir, format=format)[0], service=service)
|
||||
sections = funct.get_sections(configs_dir + funct.get_files(dir=configs_dir, format=format_file)[0], service=service)
|
||||
except Exception as e:
|
||||
funct.logging('localhost', str(e), haproxywi=1)
|
||||
try:
|
||||
cfg = configs_dir + serv + "-" + funct.get_data('config') + '.' + format
|
||||
except:
|
||||
funct.logging('localhost', ' Cannot generate cfg path', haproxywi=1)
|
||||
cfg = configs_dir + serv + "-" + funct.get_data('config') + '.' + format_file
|
||||
except Exception as e:
|
||||
funct.logging('localhost', ' Cannot generate cfg path ' + str(e), haproxywi=1)
|
||||
try:
|
||||
if service == 'nginx':
|
||||
error = funct.get_config(serv, cfg, nginx=1)
|
||||
else:
|
||||
error = funct.get_config(serv, cfg)
|
||||
except:
|
||||
funct.logging('localhost', ' Cannot download config', haproxywi=1)
|
||||
except Exception as e:
|
||||
funct.logging('localhost', ' Cannot download config ' + str(e), haproxywi=1)
|
||||
try:
|
||||
sections = funct.get_sections(cfg, service=service)
|
||||
except:
|
||||
funct.logging('localhost', ' Cannot get sections from config file', haproxywi=1)
|
||||
except Exception as e:
|
||||
funct.logging('localhost', ' Cannot get sections from config file ' + str(e), haproxywi=1)
|
||||
sections = 'Cannot get backends'
|
||||
|
||||
template = template.render(backends=sections, serv=serv, service=service)
|
||||
|
@ -465,15 +460,15 @@ if act == "overviewHapservers":
|
|||
commands = ["ls -l %s |awk '{ print $6\" \"$7\" \"$8}'" % config_path]
|
||||
try:
|
||||
print(funct.ssh_command(serv, commands))
|
||||
except:
|
||||
print('error: Cannot get last date')
|
||||
except Exception as e:
|
||||
print('error: Cannot get last date ' + str(e))
|
||||
|
||||
if act == "overview":
|
||||
import asyncio
|
||||
|
||||
import http.cookies
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
async def async_get_overview(serv1, serv2):
|
||||
server_status = ()
|
||||
commands2 = ["ps ax |grep waf/bin/modsecurity |grep -v grep |wc -l"]
|
||||
cmd = 'echo "show info" |nc %s %s -w 1|grep -e "Process_num"' % (serv2, sql.get_setting('haproxy_sock_port'))
|
||||
keepalived = sql.select_keealived(serv2)
|
||||
|
@ -502,8 +497,6 @@ if act == "overview":
|
|||
|
||||
|
||||
async def get_runner_overview():
|
||||
import http.cookies
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True,
|
||||
extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do'])
|
||||
|
||||
|
@ -526,24 +519,22 @@ if act == "overview":
|
|||
|
||||
if act == "overviewwaf":
|
||||
import asyncio
|
||||
|
||||
import http.cookies
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
async def async_get_overviewWaf(serv1, serv2):
|
||||
haproxy_dir = sql.get_setting('haproxy_dir')
|
||||
server_status = ()
|
||||
commands = ["ps ax |grep waf/bin/modsecurity |grep -v grep |wc -l"]
|
||||
commands1 = ["cat %s/waf/modsecurity.conf |grep SecRuleEngine |grep -v '#' |awk '{print $2}'" % haproxy_dir]
|
||||
haproxy_path = sql.get_setting('haproxy_dir')
|
||||
commands0 = ["ps ax |grep waf/bin/modsecurity |grep -v grep |wc -l"]
|
||||
commands1 = ["cat %s/waf/modsecurity.conf |grep SecRuleEngine |grep -v '#' |awk '{print $2}'" % haproxy_path]
|
||||
|
||||
server_status = (serv1, serv2,
|
||||
funct.ssh_command(serv2, commands),
|
||||
funct.ssh_command(serv2, commands0),
|
||||
funct.ssh_command(serv2, commands1).strip(),
|
||||
sql.select_waf_metrics_enable_server(serv2))
|
||||
return server_status
|
||||
|
||||
|
||||
async def get_runner_overviewWaf():
|
||||
import http.cookies
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True,
|
||||
extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do'])
|
||||
template = env.get_template('overivewWaf.html')
|
||||
|
@ -569,8 +560,6 @@ if act == "overviewServers":
|
|||
|
||||
|
||||
async def async_get_overviewServers(serv1, serv2, service):
|
||||
server_status = ()
|
||||
|
||||
if service == 'haproxy':
|
||||
cmd = 'echo "show info" |nc %s %s -w 1|grep -e "Ver\|CurrConns\|Maxco\|MB\|Uptime:"' % (
|
||||
serv2, sql.get_setting('haproxy_sock_port'))
|
||||
|
@ -780,7 +769,7 @@ if serv is not None and act == "showMap":
|
|||
node = node.strip(' \t\n\r')
|
||||
node = node + ":" + bind[0]
|
||||
G.add_node(node, pos=(k, i), label_pos=(k, i + 100))
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if "server " in line or "use_backend" in line or "default_backend" in line and "stats" not in line and "#" not in line:
|
||||
|
@ -851,8 +840,7 @@ if form.getvalue('servaction') is not None:
|
|||
|
||||
if enable != "show":
|
||||
print(
|
||||
'<center><h3>You %s %s on HAproxy %s. <a href="viewsttats.py?serv=%s" title="View stat" target="_blank">Look it</a> or <a href="runtimeapi.py" title="RutimeAPI">Edit something else</a></h3><br />' % (
|
||||
enable, backend, serv, serv))
|
||||
'<center><h3>You %s %s on HAproxy %s. <a href="viewsttats.py?serv=%s" title="View stat" target="_blank">Look it</a> or <a href="runtimeapi.py" title="Runtime API">Edit something else</a></h3><br />' % (enable, backend, serv, serv))
|
||||
|
||||
print(funct.ssh_command(serv, command, show_log="1"))
|
||||
action = 'runtimeapi.py ' + enable + ' ' + backend
|
||||
|
@ -968,8 +956,7 @@ if form.getvalue('master'):
|
|||
funct.install_nginx(slave)
|
||||
|
||||
commands = ["chmod +x " + script + " && ./" + script + " PROXY=" + proxy_serv + " SSH_PORT=" + ssh_port +
|
||||
" ETH=" + ETH + " IP=" + str(IP) + " MASTER=MASTER" + " SYN_FLOOD=" + syn_flood + " HOST=" + str(
|
||||
master) +
|
||||
" ETH=" + ETH + " IP=" + str(IP) + " MASTER=MASTER" + " SYN_FLOOD=" + syn_flood + " HOST=" + str(master) +
|
||||
" USER=" + str(ssh_user_name) + " PASS=" + str(ssh_user_password) + " KEY=" + str(ssh_key_name)]
|
||||
|
||||
output, error = funct.subprocess_execute(commands[0])
|
||||
|
@ -985,7 +972,7 @@ if form.getvalue('master'):
|
|||
l = l.split('"')[1]
|
||||
print(l + "<br>")
|
||||
break
|
||||
except:
|
||||
except Exception:
|
||||
print(output)
|
||||
break
|
||||
else:
|
||||
|
@ -1017,7 +1004,7 @@ if form.getvalue('master'):
|
|||
l = l.split('"')[1]
|
||||
print(l + "<br>")
|
||||
break
|
||||
except:
|
||||
except Exception:
|
||||
print(output)
|
||||
break
|
||||
else:
|
||||
|
@ -1402,13 +1389,15 @@ if form.getvalue('metrics_hapwi_cpu'):
|
|||
|
||||
if form.getvalue('new_metrics'):
|
||||
serv = form.getvalue('server')
|
||||
metric = sql.select_metrics(serv)
|
||||
time_range = form.getvalue('time_range')
|
||||
metric = sql.select_metrics(serv, time_range=time_range)
|
||||
metrics = {'chartData': {}}
|
||||
metrics['chartData']['labels'] = {}
|
||||
labels = ''
|
||||
curr_con = ''
|
||||
curr_ssl_con = ''
|
||||
sess_rate = ''
|
||||
server = ''
|
||||
|
||||
for i in metric:
|
||||
label = str(i[5])
|
||||
|
@ -1431,7 +1420,8 @@ if form.getvalue('new_metrics'):
|
|||
|
||||
if form.getvalue('new_waf_metrics'):
|
||||
serv = form.getvalue('server')
|
||||
metric = sql.select_waf_metrics(serv)
|
||||
time_range = form.getvalue('time_range')
|
||||
metric = sql.select_waf_metrics(serv, time_range=time_range)
|
||||
metrics = {'chartData': {}}
|
||||
metrics['chartData']['labels'] = {}
|
||||
labels = ''
|
||||
|
@ -1463,12 +1453,11 @@ if form.getvalue('get_exporter_v'):
|
|||
print(funct.check_service(serv, form.getvalue('get_exporter_v')))
|
||||
|
||||
if form.getvalue('bwlists'):
|
||||
list = os.path.dirname(os.getcwd()) + "/" + sql.get_setting('lists_path') + "/" + form.getvalue(
|
||||
'group') + "/" + form.getvalue('color') + "/" + form.getvalue('bwlists')
|
||||
list_path = os.path.dirname(os.getcwd()) + "/" + sql.get_setting('lists_path') + "/" + form.getvalue('group') + "/" + form.getvalue('color') + "/" + form.getvalue('bwlists')
|
||||
try:
|
||||
file = open(list, "r")
|
||||
file = open(list_path, "r")
|
||||
file_read = file.read()
|
||||
file.close
|
||||
file.close()
|
||||
print(file_read)
|
||||
except IOError:
|
||||
print('error: Cat\'n read ' + form.getvalue('color') + ' list , ')
|
||||
|
@ -1477,28 +1466,26 @@ if form.getvalue('bwlists_create'):
|
|||
color = form.getvalue('color')
|
||||
list_name = form.getvalue('bwlists_create').split('.')[0]
|
||||
list_name += '.lst'
|
||||
list = os.path.dirname(os.getcwd()) + "/" + sql.get_setting('lists_path') + "/" + form.getvalue(
|
||||
'group') + "/" + color + "/" + list_name
|
||||
list_path = os.path.dirname(os.getcwd()) + "/" + sql.get_setting('lists_path') + "/" + form.getvalue('group') + "/" + color + "/" + list_name
|
||||
try:
|
||||
open(list, 'a').close()
|
||||
print(color)
|
||||
open(list_path, 'a').close()
|
||||
print('success: ')
|
||||
try:
|
||||
funct.logging(server[1], 'has created ' + color + ' list ' + list_name, haproxywi=1, login=1)
|
||||
except:
|
||||
funct.logging(serv, 'has created ' + color + ' list ' + list_name, haproxywi=1, login=1)
|
||||
except Exception:
|
||||
pass
|
||||
except IOError as e:
|
||||
print('error: Cat\'n create new ' + color + ' list. %s , ' % e)
|
||||
print('error: Cannot create new ' + color + ' list. %s , ' % e)
|
||||
|
||||
if form.getvalue('bwlists_save'):
|
||||
color = form.getvalue('color')
|
||||
bwlists_save = form.getvalue('bwlists_save')
|
||||
list = os.path.dirname(os.getcwd()) + "/" + sql.get_setting('lists_path') + "/" + form.getvalue(
|
||||
'group') + "/" + color + "/" + bwlists_save
|
||||
list_path = os.path.dirname(os.getcwd()) + "/" + sql.get_setting('lists_path') + "/" + form.getvalue('group') + "/" + color + "/" + bwlists_save
|
||||
try:
|
||||
with open(list, "w") as file:
|
||||
with open(list_path, "w") as file:
|
||||
file.write(form.getvalue('bwlists_content'))
|
||||
except IOError as e:
|
||||
print('error: Cat\'n save ' + color + ' list. %s , ' % e)
|
||||
print('error: Cannot save ' + color + ' list. %s , ' % e)
|
||||
|
||||
path = sql.get_setting('haproxy_dir') + "/" + color
|
||||
servers = []
|
||||
|
@ -1518,14 +1505,15 @@ if form.getvalue('bwlists_save'):
|
|||
for serv in servers:
|
||||
funct.ssh_command(serv, ["sudo mkdir " + path])
|
||||
funct.ssh_command(serv, ["sudo chown $(whoami) " + path])
|
||||
error = funct.upload(serv, path + "/" + bwlists_save, list, dir='fullpath')
|
||||
error = funct.upload(serv, path + "/" + bwlists_save, list_path, dir='fullpath')
|
||||
|
||||
if error:
|
||||
print('error: Upload fail: %s , ' % error)
|
||||
else:
|
||||
print('success: Edited ' + color + ' list was uploaded to ' + serv + ' , ')
|
||||
try:
|
||||
funct.logging(serv, 'has edited ' + color + ' list ' + bwlists_save, haproxywi=1, login=1)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
haproxy_enterprise = sql.get_setting('haproxy_enterprise')
|
||||
|
@ -1540,11 +1528,10 @@ if form.getvalue('bwlists_save'):
|
|||
funct.ssh_command(serv, ["sudo systemctl reload " + haproxy_service_name])
|
||||
|
||||
if form.getvalue('get_lists'):
|
||||
list = os.path.dirname(os.getcwd()) + "/" + sql.get_setting('lists_path') + "/" + form.getvalue(
|
||||
'group') + "/" + form.getvalue('color')
|
||||
lists = funct.get_files(dir=list, format="lst")
|
||||
for list in lists:
|
||||
print(list)
|
||||
list_path = os.path.dirname(os.getcwd()) + "/" + sql.get_setting('lists_path') + "/" + form.getvalue('group') + "/" + form.getvalue('color')
|
||||
lists = funct.get_files(dir=list_path, format="lst")
|
||||
for l in lists:
|
||||
print(l)
|
||||
|
||||
if form.getvalue('get_ldap_email'):
|
||||
username = form.getvalue('get_ldap_email')
|
||||
|
@ -1574,7 +1561,7 @@ if form.getvalue('get_ldap_email'):
|
|||
results = [entry for dn, entry in result if isinstance(entry, dict)]
|
||||
try:
|
||||
print('["' + results[0][ldap_search_field][0].decode("utf-8") + '","' + domain + '"]')
|
||||
except:
|
||||
except Exception:
|
||||
print('error: user not found')
|
||||
finally:
|
||||
l.unbind()
|
||||
|
@ -1621,6 +1608,7 @@ if form.getvalue('newuser') is not None:
|
|||
if form.getvalue('userdel') is not None:
|
||||
userdel = form.getvalue('userdel')
|
||||
user = sql.select_users(id=userdel)
|
||||
username = ''
|
||||
for u in user:
|
||||
username = u[1]
|
||||
if sql.delete_user(userdel):
|
||||
|
@ -1646,11 +1634,11 @@ if form.getvalue('updateuser') is not None:
|
|||
|
||||
if form.getvalue('updatepassowrd') is not None:
|
||||
password = form.getvalue('updatepassowrd')
|
||||
id = form.getvalue('id')
|
||||
user = sql.select_users(id=id)
|
||||
user_id = form.getvalue('id')
|
||||
user = sql.select_users(id=user_id)
|
||||
for u in user:
|
||||
username = u[1]
|
||||
sql.update_user_password(password, id)
|
||||
sql.update_user_password(password, user_id)
|
||||
funct.logging('user ' + username, ' has changed password ', haproxywi=1, login=1)
|
||||
print("Ok")
|
||||
|
||||
|
@ -1802,7 +1790,7 @@ if form.getvalue('sshdel') is not None:
|
|||
cmd = 'rm -f %s' % ssh_key_name
|
||||
try:
|
||||
funct.subprocess_execute(cmd)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if sql.delete_ssh(sshdel):
|
||||
print("Ok")
|
||||
|
@ -1927,27 +1915,27 @@ if form.getvalue('updatesettings') is not None:
|
|||
print("Ok")
|
||||
|
||||
if form.getvalue('getusergroups'):
|
||||
id = form.getvalue('getusergroups')
|
||||
group_id = form.getvalue('getusergroups')
|
||||
groups = []
|
||||
u_g = sql.select_user_groups(id=id)
|
||||
u_g = sql.select_user_groups(id=group_id)
|
||||
for g in u_g:
|
||||
groups.append(g[0])
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
||||
template = env.get_template('/show_user_groups.html')
|
||||
template = template.render(groups=sql.select_groups(), user_groups=groups, id=id)
|
||||
template = template.render(groups=sql.select_groups(), user_groups=groups, id=group_id)
|
||||
print(template)
|
||||
|
||||
if form.getvalue('changeUserGroupId') is not None:
|
||||
id = form.getvalue('changeUserGroupId')
|
||||
group_id = form.getvalue('changeUserGroupId')
|
||||
groups = form.getvalue('changeUserGroups')
|
||||
user = form.getvalue('changeUserGroupsUser')
|
||||
if sql.delete_user_groups(id):
|
||||
if sql.delete_user_groups(group_id):
|
||||
for group in groups:
|
||||
if group[0] == ',':
|
||||
continue
|
||||
sql.update_user_groups(groups=group[0], id=id)
|
||||
sql.update_user_groups(groups=group[0], id=group_id)
|
||||
|
||||
funct.logging('localhost', ' has upgraded groups for user: ' + user, haproxywi=1, login=1)
|
||||
|
||||
|
@ -1957,14 +1945,14 @@ if form.getvalue('getcurrentusergroup') is not None:
|
|||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
user_id = cookie.get('uuid')
|
||||
group = cookie.get('group')
|
||||
id = sql.get_user_id_by_uuid(user_id.value)
|
||||
groups = sql.select_user_groups_with_names(id=id)
|
||||
group_id = sql.get_user_id_by_uuid(user_id.value)
|
||||
groups = sql.select_user_groups_with_names(id=group_id)
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
||||
template = env.get_template('/show_user_current_group.html')
|
||||
template = template.render(groups=groups, group=group.value, id=id)
|
||||
template = template.render(groups=groups, group=group.value, id=group_id)
|
||||
print(template)
|
||||
|
||||
if form.getvalue('newsmon') is not None:
|
||||
|
@ -1981,7 +1969,7 @@ if form.getvalue('newsmon') is not None:
|
|||
|
||||
try:
|
||||
port = int(port)
|
||||
except:
|
||||
except Exception:
|
||||
print('SMON error: port must number')
|
||||
sys.exit()
|
||||
if port > 65535 or port < 0:
|
||||
|
@ -2007,10 +1995,10 @@ if form.getvalue('newsmon') is not None:
|
|||
|
||||
if form.getvalue('smondel') is not None:
|
||||
user_group = funct.get_user_group(id=1)
|
||||
id = form.getvalue('smondel')
|
||||
smon_id = form.getvalue('smondel')
|
||||
|
||||
if funct.check_user_group():
|
||||
if sql.delete_smon(id, user_group):
|
||||
if sql.delete_smon(smon_id, user_group):
|
||||
print('Ok')
|
||||
funct.logging('SMON', ' Has been delete server from SMON ', haproxywi=1, login=1)
|
||||
|
||||
|
@ -2026,7 +2014,7 @@ if form.getvalue('showsmon') is not None:
|
|||
print(template)
|
||||
|
||||
if form.getvalue('updateSmonIp') is not None:
|
||||
id = form.getvalue('id')
|
||||
smon_id = form.getvalue('id')
|
||||
ip = form.getvalue('updateSmonIp')
|
||||
port = form.getvalue('updateSmonPort')
|
||||
en = form.getvalue('updateSmonEn')
|
||||
|
@ -2038,7 +2026,7 @@ if form.getvalue('updateSmonIp') is not None:
|
|||
|
||||
try:
|
||||
port = int(port)
|
||||
except:
|
||||
except Exception:
|
||||
print('SMON error: port must number')
|
||||
sys.exit()
|
||||
if port > 65535 or port < 0:
|
||||
|
@ -2051,7 +2039,7 @@ if form.getvalue('updateSmonIp') is not None:
|
|||
print('SMON error: Cannot be HTTP with 443 port')
|
||||
sys.exit()
|
||||
|
||||
if sql.update_smon(id, ip, port, body, telegram, group, desc, en):
|
||||
if sql.update_smon(smon_id, ip, port, body, telegram, group, desc, en):
|
||||
print("Ok")
|
||||
funct.logging('SMON', ' Has been update the server ' + ip + ' to SMON ', haproxywi=1, login=1)
|
||||
|
||||
|
@ -2086,7 +2074,7 @@ if form.getvalue('alert_consumer'):
|
|||
message = sql.select_alerts(user_group)
|
||||
for m in message:
|
||||
print(m[0] + ': ' + m[1] + ' date: ' + m[2] + ';')
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if form.getvalue('waf_rule_id'):
|
||||
|
@ -2107,7 +2095,7 @@ if form.getvalue('waf_rule_id'):
|
|||
try:
|
||||
funct.logging('WAF', ' Has been ' + en_for_log + ' WAF rule: ' + rule_file + ' for the server ' + serv,
|
||||
haproxywi=1, login=1)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
print(funct.ssh_command(serv, cmd))
|
||||
|
@ -2153,7 +2141,7 @@ if form.getvalue('lets_domain'):
|
|||
l = l.split('"')[1]
|
||||
print(l + "<br>")
|
||||
break
|
||||
except:
|
||||
except Exception:
|
||||
print(output)
|
||||
break
|
||||
else:
|
||||
|
@ -2218,3 +2206,26 @@ if form.getvalue('actionvpn') is not None:
|
|||
except IOError as e:
|
||||
print(e.args[0])
|
||||
funct.logging('localhost', e.args[0], haproxywi=1)
|
||||
|
||||
if form.getvalue('scan_ports') is not None:
|
||||
serv_id = form.getvalue('scan_ports')
|
||||
server = sql.select_servers(id=serv_id)
|
||||
|
||||
for s in server:
|
||||
ip = s[2]
|
||||
|
||||
cmd = "sudo nmap -sS %s |grep -E '^[[:digit:]]'|sed 's/ */ /g'" % ip
|
||||
cmd1 = "sudo nmap -sS %s |head -5|tail -3" % ip
|
||||
|
||||
stdout, stderr = funct.subprocess_execute(cmd)
|
||||
stdout1, stderr1 = funct.subprocess_execute(cmd1)
|
||||
|
||||
if stderr != '':
|
||||
print(stderr)
|
||||
else:
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
env = Environment(loader=FileSystemLoader('templates'), autoescape=True)
|
||||
template = env.get_template('ajax/scan_ports.html')
|
||||
template = template.render(ports=stdout, info=stdout1)
|
||||
print(template)
|
||||
|
|
|
@ -24,6 +24,10 @@ done
|
|||
|
||||
export ANSIBLE_HOST_KEY_CHECKING=False
|
||||
export ANSIBLE_DISPLAY_SKIPPED_HOSTS=False
|
||||
export ACTION_WARNINGS=False
|
||||
export LOCALHOST_WARNING=False
|
||||
export COMMAND_WARNINGS=False
|
||||
|
||||
PWD=`pwd`
|
||||
PWD=$PWD/scripts/ansible/
|
||||
echo $HOST > $PWD/$HOST
|
||||
|
|
|
@ -23,6 +23,10 @@ done
|
|||
|
||||
export ANSIBLE_HOST_KEY_CHECKING=False
|
||||
export ANSIBLE_DISPLAY_SKIPPED_HOSTS=False
|
||||
export ACTION_WARNINGS=False
|
||||
export LOCALHOST_WARNING=False
|
||||
export COMMAND_WARNINGS=False
|
||||
|
||||
PWD=`pwd`
|
||||
PWD=$PWD/scripts/ansible/
|
||||
echo $HOST > $PWD/$HOST
|
||||
|
|
|
@ -32,6 +32,9 @@ fi
|
|||
export ANSIBLE_HOST_KEY_CHECKING=False
|
||||
export ANSIBLE_DISPLAY_SKIPPED_HOSTS=False
|
||||
export ACTION_WARNINGS=False
|
||||
export LOCALHOST_WARNING=False
|
||||
export COMMAND_WARNINGS=False
|
||||
|
||||
PWD=`pwd`
|
||||
PWD=$PWD/scripts/ansible/
|
||||
echo $HOST > $PWD/$HOST
|
||||
|
@ -44,7 +47,9 @@ fi
|
|||
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
echo "error: Can't install Nginx service <br /><br />"
|
||||
exit 1
|
||||
echo "error: Can't install Nginx service <br /><br />"
|
||||
exit 1
|
||||
else
|
||||
echo "ok"
|
||||
fi
|
||||
rm -f $PWD/$HOST
|
||||
|
|
|
@ -30,7 +30,9 @@ fi
|
|||
export ANSIBLE_HOST_KEY_CHECKING=False
|
||||
export ANSIBLE_DISPLAY_SKIPPED_HOSTS=False
|
||||
export ACTION_WARNINGS=False
|
||||
export ANSIBLE_DEPRECATION_WARNINGS=False
|
||||
export LOCALHOST_WARNING=False
|
||||
export COMMAND_WARNINGS=False
|
||||
|
||||
PWD=`pwd`
|
||||
PWD=$PWD/scripts/ansible/
|
||||
echo $HOST > $PWD/$HOST
|
||||
|
|
|
@ -795,11 +795,15 @@
|
|||
<div id="lists">
|
||||
<table class="overview">
|
||||
<tr class="overviewHead">
|
||||
<th class="padding10 first-collumn">Server for upload</th>
|
||||
<th>New blacklist</th>
|
||||
<th class="padding10 first-collumn">New blacklist</th>
|
||||
<th>Server for uploading</th>
|
||||
<th>Existing blacklists</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding10 first-collumn" style="width: 25%;">
|
||||
Name: {{ input('new_blacklist_name') }}
|
||||
<button onclick="createList('black')">Create</button>
|
||||
</td>
|
||||
<td class="padding10 first-collumn">
|
||||
<select required name="serv-black-list" id="serv-black-list">
|
||||
<option disabled selected>Choose server</option>
|
||||
|
@ -809,10 +813,6 @@
|
|||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td style="width: 25%;">
|
||||
Name: {{ input('new_blacklist_name') }}
|
||||
<button onclick="createList('black')">Create</button>
|
||||
</td>
|
||||
<td style="width: 30%;">
|
||||
{% for list in black_lists %}
|
||||
<a onclick="editList('{{ list }}', 'black')" style="cursor: pointer;" title="Edit list {{ list }}">{{ list }}</a>
|
||||
|
@ -824,11 +824,15 @@
|
|||
</table>
|
||||
<table>
|
||||
<tr class="overviewHead">
|
||||
<th class="padding10 first-collumn">Server for upload</th>
|
||||
<th>New whitelist</th>
|
||||
<th class="padding10 first-collumn">New whitelist</th>
|
||||
<th>Server for uploading</th>
|
||||
<th>Existing whitelists</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding10 first-collumn" style="width: 25%;">
|
||||
Name: {{ input('new_whitelist_name') }}
|
||||
<button onclick="createList('white')">Create</button>
|
||||
</td>
|
||||
<td class="padding10 first-collumn">
|
||||
<select required name="serv-white-list" id="serv-white-list">
|
||||
<option disabled selected>Choose server</option>
|
||||
|
@ -838,10 +842,6 @@
|
|||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td style="width: 25%;">
|
||||
Name: {{ input('new_whitelist_name') }}
|
||||
<button onclick="createList( 'white')">Create</button>
|
||||
</td>
|
||||
<td style="width: 30%;">
|
||||
{% for list in white_lists %}
|
||||
<a onclick="editList('{{ list }}', 'white')" style="cursor: pointer;" title="Edit list {{ list }}">{{ list }}</a>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="sort_menu">
|
||||
<a href="#" title="Do not sort by status" onclick="showSmon('not_sort')">Do not sort</a> |
|
||||
<a href="#" id="sort_by_status" title="Sort by status" onclick="sort_by_status()">Sort by status</a> |
|
||||
<a href="#" title="Refresh page" onclick="showSmon('refresh');">Refresh</a>
|
||||
<a href="#" title="SMOM Dashboard - HAProxy-WI" onclick="showSmon('refresh');">Refresh</a>
|
||||
<span style="padding-left: 20px;">
|
||||
{% set down = [] %}
|
||||
{% set up = [] %}
|
||||
|
@ -35,12 +35,12 @@
|
|||
{% endif %}
|
||||
{% if s.3 == 1 %}
|
||||
{% if s.2 == 1 and s.10 == 1 and s.12 == 1 %}
|
||||
<div class="smon_services good">
|
||||
<div class="smon_services good div-server-head-up">
|
||||
{% else %}
|
||||
<div class="smon_services err">
|
||||
<div class="smon_services err div-server-head-down">
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div class="smon_services dis">
|
||||
<div class="smon_services dis div-server-head-dis">
|
||||
{% endif %}
|
||||
<div class="ip">
|
||||
{% if s.0|string|length > 23 %}
|
||||
|
|
|
@ -278,9 +278,10 @@
|
|||
</div>
|
||||
<div class="footer-div">
|
||||
<a href="https://haproxy-wi.org" class="footer-link" target="_blank" title="About HAProxy-WI">About</a>
|
||||
<a href="https://github.com/Aidaho12/haproxy-wi/issues" class="footer-link" target="_blank">Help</a>
|
||||
<a href="https://github.com/Aidaho12/haproxy-wi/issues" class="footer-link" target="_blank" title="Community help">Help</a>
|
||||
<a href="https://sd.haproxy-wi.org" class="footer-link" target="_blank" title="Service Desk">SD</a>
|
||||
<a href="https://haproxy-wi.org/contacts.py" class="footer-link" target="_blank">Contacts</a>
|
||||
<a href="https://haproxy-wi.org/cabinet.py" class="footer-link" target="_blank" title="Private cabinet for donaterers">Cabinet</a>
|
||||
<a href="https://haproxy-wi.org/cabinet.py" class="footer-link" target="_blank" title="Private cabinet">Cabinet</a>
|
||||
</div>
|
||||
</div>
|
||||
<div id="current-user-groups-dialog" style="display: none;">
|
||||
|
|
|
@ -8,10 +8,8 @@
|
|||
{% if selects|length == 0 %}
|
||||
{% include 'include/getstarted.html' %}
|
||||
{% else %}
|
||||
<h3>Choose server</h3>
|
||||
<p>
|
||||
<form action="{{ action }}" method="post">
|
||||
<a class="ui-button ui-widget ui-corner-all" title="Return back" id="back" onclick="history.go(-2)">Back</a>
|
||||
<input type="hidden" id="service" value="{{service|default('haproxy', true)}}" />
|
||||
<select autofocus required name="serv" id="{{ select_id }}">
|
||||
<option disabled>Choose server</option>
|
||||
|
@ -105,7 +103,7 @@
|
|||
<style>
|
||||
.CodeMirror {
|
||||
line-height: 1.2em;
|
||||
height: 50%;
|
||||
height: 60%;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<center>
|
||||
<h3>Choose server</h3>
|
||||
<p>
|
||||
<form action="{{ action }}" method="post">
|
||||
<input type="hidden" id="service" value="{{service}}">
|
||||
<a class="ui-button ui-widget ui-corner-all" title="Return back" onclick="history.back()">Back</a>
|
||||
{% include 'include/select.html' %}
|
||||
<button type="submit" value="open" name="open" class="btn btn-default">Open</button>
|
||||
</form>
|
||||
|
|
|
@ -5,15 +5,17 @@
|
|||
{% include 'include/getstarted.html' %}
|
||||
{% else %}
|
||||
<center>
|
||||
<h3>Choose server</h3>
|
||||
<p>
|
||||
<form action="{{ action }}" method="post">
|
||||
<a class="ui-button ui-widget ui-corner-all" title="Return back" onclick="history.back()">Back</a>
|
||||
{% include 'include/select.html' %}
|
||||
<button type="submit" value="open" name="open" class="btn btn-default">Open</button>
|
||||
{% if service != 'keepalived' %}
|
||||
<a href="config.py" class="ui-button ui-widget ui-corner-all" title="Configs page">Configs</a>
|
||||
<a class="ui-button ui-widget ui-corner-all" title="View stat" onclick="openStats()">Stat</a>
|
||||
{% endif %}
|
||||
</form>
|
||||
{% if not aftersave and not open %}
|
||||
<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; margin-top: 40%">
|
||||
Here you can work with previous versions of {%if service == 'keepalived' %}Keepalived{%else%}HAProxy{%endif%} configs. Roll back to them, view or delete
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
|
@ -85,9 +85,35 @@
|
|||
showBytes('{{ s.2 }}')
|
||||
}
|
||||
showMetrics();
|
||||
$( function() {
|
||||
$("#time-range").on('selectmenuchange', function () {
|
||||
removeData()
|
||||
let metrics = new Promise(
|
||||
(resolve, reject) => {
|
||||
{% for s in servers %}
|
||||
getChartData('{{s.2}}')
|
||||
getWafChartData('{{s.2}}')
|
||||
{% endfor %}
|
||||
});
|
||||
metrics.then();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
<div id="div-server-{{s.0}}" class="div-server-hapwi" {% if not serv %}style="cursor: move;"{%endif%}>
|
||||
{% if service == 'nginx' %}
|
||||
{% if s.5.0.3 == 'active' %}
|
||||
{% set additional_status_class = 'div-server-head-up' %}
|
||||
{% else %}
|
||||
{% set additional_status_class = 'div-server-head-down' %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if s.5 != False %}
|
||||
{% set additional_status_class = 'div-server-head-up' %}
|
||||
{% else %}
|
||||
{% set additional_status_class = 'div-server-head-down' %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<div id="div-server-{{s.0}}" class="div-server-hapwi {{additional_status_class}}" {% if not serv %}style="cursor: move;"{%endif%}>
|
||||
<div class="server-name">
|
||||
<input type="hidden" id="server-name-{{s.0}}" value="{{s.1}}" />
|
||||
<input type="hidden" id="service" value="{{service}}" />
|
||||
|
@ -96,7 +122,7 @@
|
|||
<span class="serverUp server-status" title="Uptime: {{s.5.0.4}}"></span>
|
||||
{% else %}
|
||||
<span class="serverDown server-status" title="Downtime: : {{s.5.0.4}}"></span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if s.5 != False %}
|
||||
<span class="serverUp server-status" title="{{s.5.0.2}}"></span>
|
||||
|
@ -227,8 +253,20 @@
|
|||
{% endfor %}
|
||||
</div>
|
||||
{% if serv and service == 'haproxy' %}
|
||||
<div id="refresh" style="text-align: right;margin-right: 105px;clear: both;display: block;margin-bottom: -25px;" title="Refresh metrics" onclick="showMetrics()">
|
||||
<span class="service-reload"></span>
|
||||
<div style="clear: both; width: 95%;">
|
||||
<div style="padding-left: 25px;float: left;margin-top: -15px;">
|
||||
<b>Time range:</b>
|
||||
<select title="Choose time range" id="time-range">
|
||||
<option value="30">30 minutes</option>
|
||||
<option value="60">1 hour</option>
|
||||
<option value="180">3 hours</option>
|
||||
<option value="360">6 hours</option>
|
||||
<option value="720">12 hours</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="refresh" style="text-align: right;margin-right: 3%;" title="Refresh metrics" onclick="showMetrics()">
|
||||
<span class="service-reload"></span>
|
||||
</div>
|
||||
</div>
|
||||
{% for s in servers %}
|
||||
<div class="chart-container" style="display: block; width: 91.3%; height: 300px;">
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<div id="create" style="margin-top: 20px;">
|
||||
<div id="left-collumn">
|
||||
<div class="div-pannel">
|
||||
<div class="div-server">
|
||||
<div class="div-server add-proxy-listen-head">
|
||||
<div class="server-name">
|
||||
<span title="Create Listen" class="redirectListen span-link">Create Listen</span>
|
||||
</div>
|
||||
|
@ -25,7 +25,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="div-pannel">
|
||||
<div class="div-server">
|
||||
<div class="div-server add-proxy-listen-head">
|
||||
<div class="server-name">
|
||||
<span title="Create HTTP Listen" class="redirectListen span-link" id="create-http-listen">Create HTTP Listen</span>
|
||||
</div>
|
||||
|
@ -35,7 +35,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="div-pannel">
|
||||
<div class="div-server">
|
||||
<div class="div-server add-proxy-listen-head">
|
||||
<div class="server-name">
|
||||
<span title="Create SSL Listen" class="redirectListen span-link" id="create-ssl-listen">Create SSL Listen</span>
|
||||
</div>
|
||||
|
@ -46,7 +46,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="div-pannel">
|
||||
<div class="div-server">
|
||||
<div class="div-server add-proxy-listen-head">
|
||||
<div class="server-name">
|
||||
<span title="Create SSL Listen" class="redirectListen span-link" id="create-https-listen">Create HTTPS Listen</span>
|
||||
</div>
|
||||
|
@ -56,7 +56,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="div-pannel">
|
||||
<div class="div-server">
|
||||
<div class="div-server add-proxy-listen-head">
|
||||
<div class="server-name">
|
||||
<span title="Create presaved options" class="span-link" id="add4">Create presaved options</span>
|
||||
</div>
|
||||
|
@ -68,7 +68,7 @@
|
|||
</div>
|
||||
<div id="middle-collumn">
|
||||
<div class="div-pannel">
|
||||
<div class="div-server">
|
||||
<div class="div-server add-proxy-frontend-head">
|
||||
<div class="server-name">
|
||||
<span title="Create Frontend" class="redirectFrontend span-link">Create Frontend</span>
|
||||
</div>
|
||||
|
@ -79,7 +79,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="div-server">
|
||||
<div class="div-server add-proxy-frontend-head">
|
||||
<div class="server-name">
|
||||
<span title="Create HTTP Frontend" class="redirectListen span-link" id="create-http-frontend">Create HTTP Frontend</span>
|
||||
</div>
|
||||
|
@ -88,7 +88,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="div-pannel">
|
||||
<div class="div-server">
|
||||
<div class="div-server add-proxy-frontend-head">
|
||||
<div class="server-name">
|
||||
<span title="Create SSL Frontend" class="redirectListen span-link" id="create-ssl-frontend">Create SSL Frontend</span>
|
||||
</div>
|
||||
|
@ -98,7 +98,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="div-pannel">
|
||||
<div class="div-server">
|
||||
<div class="div-server add-proxy-frontend-head">
|
||||
<div class="server-name">
|
||||
<span title="Create HTTPS Frontend" class="redirectListen span-link" id="create-https-frontend">Create HTTPS Frontend</span>
|
||||
</div>
|
||||
|
@ -108,7 +108,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="div-pannel">
|
||||
<div class="div-server">
|
||||
<div class="div-server add-proxy-frontend-head">
|
||||
<div class="server-name">
|
||||
<span title="Create presaved servers" class="span-link" id="add5">Create presaved servers</span>
|
||||
</div>
|
||||
|
@ -120,7 +120,7 @@
|
|||
</div>
|
||||
<div id="right-collumn">
|
||||
<div class="div-pannel">
|
||||
<div class="div-server">
|
||||
<div class="div-server add-proxy-backend-head">
|
||||
<div class="server-name">
|
||||
<span title="Create Backend" class="redirectBackend span-link">Create Backend</span>
|
||||
</div>
|
||||
|
@ -131,7 +131,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="div-server">
|
||||
<div class="div-server add-proxy-backend-head">
|
||||
<div class="server-name">
|
||||
<span title="Create SSL Backend" class="redirectListen span-link" id="create-http-backend">Create HTTP Backend</span>
|
||||
</div>
|
||||
|
@ -140,7 +140,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="div-pannel">
|
||||
<div class="div-server">
|
||||
<div class="div-server add-proxy-backend-head">
|
||||
<div class="server-name">
|
||||
<span title="Create HTTPS Backend" class="redirectListen span-link" id="create-ssl-backend">Create SSL Backend</span>
|
||||
</div>
|
||||
|
@ -150,7 +150,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="div-pannel">
|
||||
<div class="div-server">
|
||||
<div class="div-server add-proxy-backend-head">
|
||||
<div class="server-name">
|
||||
<span title="Create SSL Backend" class="redirectListen span-link" id="create-https-backend">Create HTTPS Backend</span>
|
||||
</div>
|
||||
|
@ -160,7 +160,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="div-pannel">
|
||||
<div class="div-server">
|
||||
<div class="div-server add-proxy-backend-head">
|
||||
<div class="server-name">
|
||||
<span title="Create userlists" class="span-link" id="add6">Create userlists</span>
|
||||
</div>
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
<span title="Actions with the master config will automatically apply on the slave">Slave for</span>
|
||||
</th>
|
||||
<th class="cred-field" style="width: 15%">Credentials</th>
|
||||
<th class="cred-field" style="width: 200px;"></th>
|
||||
<th style="width: 100%">Description</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
|
@ -114,6 +115,9 @@
|
|||
<button onclick="checkSshConnect('{{server.2}}')" title="Check SSH connect to the server {{server.1}}">check</button>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<button onclick="scanPorts('{{server.0}}')" title="Scanning open/filtered ports for the server {{server.1}}">scan</button>
|
||||
</td>
|
||||
<td>
|
||||
{% set id = 'desc-' + server.0|string() %}
|
||||
{% if server.11 != "None" %}
|
||||
|
|
|
@ -29,16 +29,24 @@ th, tr, td {
|
|||
{% include 'include/getstarted.html' %}
|
||||
{% else %}
|
||||
<div id="table_metrics"></div>
|
||||
<div id="refresh" style="text-align: right;margin-top: 20px;margin-right: 10px;" title="Refresh metrics" onclick="showMetrics()">
|
||||
<span class="service-reload"></span>
|
||||
<div style="padding-left: 25px;float: left;margin-top: 6px;">
|
||||
<b>Time range:</b>
|
||||
<select title="Choose time range" id="time-range">
|
||||
<option value="30">30 minutes</option>
|
||||
<option value="60">1 hour</option>
|
||||
<option value="180">3 hours</option>
|
||||
<option value="360">6 hours</option>
|
||||
<option value="720">12 hours</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="refresh" style="text-align: right;margin-top: 20px;margin-right: 10px;" title="Refresh metrics" onclick="showMetrics()">
|
||||
<span class="service-reload"></span>
|
||||
</div>
|
||||
<div id="sortable">
|
||||
{% for s in servers %}
|
||||
<div class="chart-container">
|
||||
<canvas id="{{s.0}}" role="img"></canvas>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<script>
|
||||
function showMetrics() {
|
||||
let metrics = new Promise(
|
||||
|
@ -51,6 +59,18 @@ th, tr, td {
|
|||
metrics.then();
|
||||
}
|
||||
showMetrics()
|
||||
$( function() {
|
||||
$("#time-range").on('selectmenuchange', function () {
|
||||
removeData()
|
||||
let metrics = new Promise(
|
||||
(resolve, reject) => {
|
||||
{% for s in servers %}
|
||||
getChartData('{{s.0}}')
|
||||
{% endfor %}
|
||||
});
|
||||
metrics.then();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
|
|
@ -5,14 +5,8 @@
|
|||
<script src="/inc/codemirror/nginx.js"></script>
|
||||
<script src="/inc/codemirror/haproxy.js"></script>
|
||||
<center>
|
||||
<h3>Choose a section</h3>
|
||||
<p>
|
||||
<form action="{{ action }}" method="post">
|
||||
{% if aftersave %}
|
||||
<a class="ui-button ui-widget ui-corner-all" title="Return back" onclick="history.go(-3)">Back</a>
|
||||
{% else %}
|
||||
<a class="ui-button ui-widget ui-corner-all" title="Return back" onclick="history.back()">Back</a>
|
||||
{% endif %}
|
||||
<select autofocus required name="section" id="{{ select_id }}">
|
||||
<option disabled>Choose a section</option>
|
||||
{% for s in sections %}
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
host = host.replace(/\./g, '\\.');
|
||||
hostnamea.push(host);
|
||||
{% endfor %}
|
||||
|
||||
</script>
|
||||
{% if servers_all|length == 0 %}
|
||||
{% include 'include/getstarted.html' %}
|
||||
|
@ -63,7 +64,7 @@
|
|||
</td>
|
||||
<td class="padding10">
|
||||
WAF mode
|
||||
</td class="padding10">
|
||||
</td>
|
||||
<td>
|
||||
Metrics
|
||||
</td>
|
||||
|
@ -85,7 +86,17 @@
|
|||
<script src="/inc/overview.js"></script>
|
||||
<script src="/inc/metrics.js"></script>
|
||||
<script src="/inc/chart.min.js"></script>
|
||||
<div id="refresh" style="text-align: right;margin-top: 20px;margin-right: 20px;" title="Refresh metrics" onclick="showWafMetrics()">
|
||||
<div style="padding-left: 25px;float: left;margin-top: 3px;">
|
||||
<b>Time range:</b>
|
||||
<select title="Choose time range" id="time-range">
|
||||
<option value="30">30 minutes</option>
|
||||
<option value="60">1 hour</option>
|
||||
<option value="180">3 hours</option>
|
||||
<option value="360">6 hours</option>
|
||||
<option value="720">12 hours</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="refresh" style="text-align: right;margin-top: 10px;margin-right: 20px; margin-bottom: 10px;" title="Refresh metrics" onclick="showWafMetrics()">
|
||||
<span class="service-reload"></span>
|
||||
</div>
|
||||
{% for s in servers %}
|
||||
|
@ -104,6 +115,18 @@
|
|||
}
|
||||
showWafMetrics();
|
||||
showOverviewWaf(ip, hostnamea);
|
||||
$( function() {
|
||||
$("#time-range").on('selectmenuchange', function () {
|
||||
removeData()
|
||||
let metrics = new Promise(
|
||||
(resolve, reject) => {
|
||||
{% for s in servers %}
|
||||
getWafChartData('{{s.0}}')
|
||||
{% endfor %}
|
||||
});
|
||||
metrics.then();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px; clear: both;">
|
||||
You can read the description and watch a video about WAF <a href="https://haproxy-wi.org/description.py?description=waf" title="WAF" target="_blank">here</a>
|
||||
|
|
|
@ -1313,8 +1313,7 @@ function createList(color) {
|
|||
toastr.info(data);
|
||||
} else if (data.indexOf('success') != '-1' ) {
|
||||
toastr.clear();
|
||||
toastr.success('WAF service has installed');
|
||||
showOverviewWaf(ip, hostnamea)
|
||||
toastr.success('List has been created');
|
||||
setTimeout(function () {
|
||||
location.reload();
|
||||
}, 2500);
|
||||
|
@ -1383,7 +1382,7 @@ function saveList(action, list, color) {
|
|||
|
||||
for (i = 0; i < data.length; i++) {
|
||||
if (data[i]) {
|
||||
if (data[i].indexOf('error:') != '-1') {
|
||||
if (data[i].indexOf('error: ') != '-1') {
|
||||
toastr.error(data[i]);
|
||||
} else {
|
||||
toastr.success(data[i]);
|
||||
|
|
|
@ -4,6 +4,7 @@ function getChartData(server) {
|
|||
data: {
|
||||
new_metrics: '1',
|
||||
server: server,
|
||||
time_range: $( "#time-range option:selected" ).val(),
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
|
@ -19,6 +20,13 @@ function getChartData(server) {
|
|||
}
|
||||
});
|
||||
}
|
||||
function removeData() {
|
||||
for (i = 0; i < charts.length; i++) {
|
||||
chart = charts[i];
|
||||
chart.destroy();
|
||||
}
|
||||
}
|
||||
var charts = []
|
||||
function renderChart(data, labels, server) {
|
||||
var ctx = document.getElementById(server)
|
||||
var myChart = new Chart(ctx, {
|
||||
|
@ -85,6 +93,7 @@ function renderChart(data, labels, server) {
|
|||
}
|
||||
}
|
||||
});
|
||||
charts.push(myChart);
|
||||
}
|
||||
|
||||
function getWafChartData(server) {
|
||||
|
@ -93,6 +102,7 @@ function getWafChartData(server) {
|
|||
data: {
|
||||
new_waf_metrics: '1',
|
||||
server: server,
|
||||
time_range: $( "#time-range option:selected" ).val(),
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
|
@ -158,8 +168,9 @@ function renderWafChart(data, labels, server) {
|
|||
}
|
||||
}
|
||||
});
|
||||
charts.push(myChart);
|
||||
}
|
||||
|
||||
console.log(charts);
|
||||
$("#secIntervals").css("display", "none");
|
||||
|
||||
function loadMetrics() {
|
||||
|
|
|
@ -308,7 +308,7 @@ function showStats() {
|
|||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
if (data.indexOf('error:') != '-1') {
|
||||
if (data.indexOf('error:') != '-1' && data.indexOf('Internal error:') == '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
toastr.clear();
|
||||
|
|
|
@ -394,7 +394,7 @@ pre {
|
|||
font-weight: bold;
|
||||
}
|
||||
.serverUp {
|
||||
background-color: #5CB85C;
|
||||
background-color: #5ad05a;
|
||||
}
|
||||
.serverNone {
|
||||
background-color: #ddd;
|
||||
|
@ -421,7 +421,7 @@ pre {
|
|||
font-size: 13px;
|
||||
}
|
||||
.serverDown {
|
||||
background-color: red;
|
||||
background-color: #be2424;
|
||||
}
|
||||
.padding10 {
|
||||
padding: 10px 10px 10px 0;
|
||||
|
@ -745,6 +745,27 @@ label {
|
|||
.div-server {
|
||||
height: 95px;
|
||||
}
|
||||
.div-server-head-up {
|
||||
border-top: 3px solid #5ad05a !important;
|
||||
}
|
||||
.div-server-head-down {
|
||||
border-top: 3px solid #be2424 !important;
|
||||
}
|
||||
.div-server-head-dis {
|
||||
border-top: 3px solid #aaa !important;
|
||||
}
|
||||
.div-server-head-up, .div-server-head-down, .div-server-head-dis {
|
||||
padding-top: 7px;
|
||||
}
|
||||
.add-proxy-listen-head {
|
||||
border-top: 3px solid #02869b;
|
||||
}
|
||||
.add-proxy-frontend-head {
|
||||
border-top: 3px solid #00a4bd;
|
||||
}
|
||||
.add-proxy-backend-head {
|
||||
border-top: 3px solid #00b8d7;
|
||||
}
|
||||
.div-backends {
|
||||
width: 89.3%;
|
||||
}
|
||||
|
@ -862,6 +883,7 @@ label {
|
|||
background-color: #fbfbfb;;
|
||||
margin: 10px;
|
||||
padding-left: 15px;
|
||||
padding-top: 0;
|
||||
border: 1px solid #A4C7F5;
|
||||
}
|
||||
#good_services {
|
||||
|
@ -947,15 +969,17 @@ label {
|
|||
}
|
||||
.div-server {
|
||||
margin-bottom: 30px !important;
|
||||
width: 43%;
|
||||
width: 300px;
|
||||
height: 100px;
|
||||
}
|
||||
.server-desc {
|
||||
width: 300px;
|
||||
}
|
||||
}
|
||||
@media (max-width: 1280px) {
|
||||
.div-server {
|
||||
margin-bottom: 30px !important;
|
||||
width: 90%;
|
||||
height: 70px;
|
||||
height: 100px;
|
||||
}
|
||||
#ssl_name {
|
||||
width: 100px;
|
||||
|
|
41
inc/users.js
41
inc/users.js
|
@ -173,6 +173,7 @@ $( function() {
|
|||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
$("#ajax").html('')
|
||||
if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') {
|
||||
toastr.error(data);
|
||||
} else if (data.indexOf('success') != '-1' ){
|
||||
|
@ -205,6 +206,7 @@ $( function() {
|
|||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
$("#ajax").html('')
|
||||
if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') {
|
||||
toastr.clear();
|
||||
toastr.error(data);
|
||||
|
@ -222,7 +224,7 @@ $( function() {
|
|||
} );
|
||||
});
|
||||
$('#grafna_install').click(function() {
|
||||
$("#ajaxmon").html('')
|
||||
$("#ajaxmon").html('');
|
||||
$("#ajaxmon").html(wait_mess);
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
|
@ -233,6 +235,7 @@ $( function() {
|
|||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
$("#ajaxmon").html('');
|
||||
if (data.indexOf('FAILED') != '-1') {
|
||||
toastr.clear();
|
||||
toastr.error(data);;
|
||||
|
@ -261,6 +264,7 @@ $( function() {
|
|||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
$("#ajaxmon").html('');
|
||||
if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') {
|
||||
toastr.clear();
|
||||
toastr.error(data);
|
||||
|
@ -291,6 +295,7 @@ $( function() {
|
|||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
$("#ajaxmon").html('');
|
||||
if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') {
|
||||
toastr.error(data);
|
||||
} else if (data.indexOf('success') != '-1' ){
|
||||
|
@ -2046,4 +2051,36 @@ function OpenVpnSess(id, action) {
|
|||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
function scanPorts(id) {
|
||||
$.ajax({
|
||||
url: "options.py",
|
||||
data: {
|
||||
scan_ports: id,
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function (data) {
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data.indexOf('danger') != '-1' || data.indexOf('unique') != '-1' || data.indexOf('error:') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
toastr.clear();
|
||||
$("#show_scans_ports_body").html(data);
|
||||
$("#show_scans_ports" ).dialog({
|
||||
resizable: false,
|
||||
height: "auto",
|
||||
width: 360,
|
||||
modal: true,
|
||||
title: "Openned ports",
|
||||
buttons: {
|
||||
Close: function() {
|
||||
$( this ).dialog( "close" );
|
||||
$("#show_scans_ports_body").html('');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ function installWaf(ip1) {
|
|||
}
|
||||
function changeWafMode(id) {
|
||||
var waf_mode = $('#'+id+' option:selected').val();
|
||||
console.log('1')
|
||||
var server_hostname = id.split('_')[0];
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
|
@ -105,14 +106,12 @@ $( function() {
|
|||
});
|
||||
});
|
||||
function waf_rules_en(id) {
|
||||
console.log('1')
|
||||
var enable = 0;
|
||||
if ($('#rule_id-'+id).is(':checked')) {
|
||||
enable = '1';
|
||||
}
|
||||
var serv = findGetParameter('serv')
|
||||
console.log(serv)
|
||||
console.log(id)
|
||||
console.log(enable)
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
|
@ -134,4 +133,4 @@ function waf_rules_en(id) {
|
|||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue