mirror of https://github.com/Aidaho12/haproxy-wi
parent
bc6c8371de
commit
b6a75c298e
|
@ -41,8 +41,8 @@ if all(v is None for v in [
|
||||||
if not os.path.exists(black_dir):
|
if not os.path.exists(black_dir):
|
||||||
os.makedirs(black_dir)
|
os.makedirs(black_dir)
|
||||||
|
|
||||||
white_lists = funct.get_files(dir=white_dir, format="lst")
|
white_lists = funct.get_files(white_dir, "lst")
|
||||||
black_lists = funct.get_files(dir=black_dir, format="lst")
|
black_lists = funct.get_files(black_dir, "lst")
|
||||||
|
|
||||||
template = template.render(
|
template = template.render(
|
||||||
title="Add: ", role=role, user=user, selects=servers, add=form.getvalue('add'), conf_add=form.getvalue('conf'),
|
title="Add: ", role=role, user=user, selects=servers, add=form.getvalue('add'), conf_add=form.getvalue('conf'),
|
||||||
|
|
|
@ -32,7 +32,7 @@ except Exception as e:
|
||||||
if service in ('haproxy', 'nginx', 'keepalived', 'apache'):
|
if service in ('haproxy', 'nginx', 'keepalived', 'apache'):
|
||||||
service_desc = sql.select_service(service)
|
service_desc = sql.select_service(service)
|
||||||
if funct.check_login(service=service_desc.service_id):
|
if funct.check_login(service=service_desc.service_id):
|
||||||
title = f"Working with {service_desc.service} configuration files"
|
title = f"{service_desc.service} config view page"
|
||||||
action = f"config.py?service={service_desc.slug}"
|
action = f"config.py?service={service_desc.slug}"
|
||||||
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
||||||
file_format = 'conf'
|
file_format = 'conf'
|
||||||
|
@ -60,6 +60,8 @@ if serv is not None and form.getvalue('open') is not None and form.getvalue('new
|
||||||
is_serv_protected = sql.is_serv_protected(serv)
|
is_serv_protected = sql.is_serv_protected(serv)
|
||||||
server_id = sql.select_server_id_by_ip(serv)
|
server_id = sql.select_server_id_by_ip(serv)
|
||||||
is_restart = sql.select_service_setting(server_id, service, 'restart')
|
is_restart = sql.select_service_setting(server_id, service, 'restart')
|
||||||
|
service_desc = sql.select_service(service)
|
||||||
|
title = f'{service_desc.service} config edit page'
|
||||||
|
|
||||||
if service == 'keepalived':
|
if service == 'keepalived':
|
||||||
error = funct.get_config(serv, cfg, keepalived=1)
|
error = funct.get_config(serv, cfg, keepalived=1)
|
||||||
|
|
|
@ -988,7 +988,7 @@ def update_db_v_6_1_4():
|
||||||
|
|
||||||
|
|
||||||
def update_ver():
|
def update_ver():
|
||||||
query = Version.update(version='6.1.4.0')
|
query = Version.update(version='6.1.5.0')
|
||||||
try:
|
try:
|
||||||
query.execute()
|
query.execute()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
@ -561,6 +561,17 @@ class WafNginx(BaseModel):
|
||||||
constraints = [SQL('UNIQUE (server_id)')]
|
constraints = [SQL('UNIQUE (server_id)')]
|
||||||
|
|
||||||
|
|
||||||
|
class ServiceStatus(BaseModel):
|
||||||
|
server_id = ForeignKeyField(Server, on_delete='Cascade')
|
||||||
|
service_id = IntegerField()
|
||||||
|
service_check = CharField()
|
||||||
|
status = IntegerField(constraints=[SQL('DEFAULT 1')])
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
table_name = 'services_statuses'
|
||||||
|
constraints = [SQL('UNIQUE (server_id, service_id, service_check)')]
|
||||||
|
|
||||||
|
|
||||||
def create_tables():
|
def create_tables():
|
||||||
with conn:
|
with conn:
|
||||||
conn.create_tables([User, Server, Role, Telegram, Slack, UUID, Token, ApiToken, Groups, UserGroups, ConfigVersion,
|
conn.create_tables([User, Server, Role, Telegram, Slack, UUID, Token, ApiToken, Groups, UserGroups, ConfigVersion,
|
||||||
|
@ -568,4 +579,4 @@ def create_tables():
|
||||||
PortScannerSettings, PortScannerPorts, PortScannerHistory, ProvidersCreds, ServiceSetting,
|
PortScannerSettings, PortScannerPorts, PortScannerHistory, ProvidersCreds, ServiceSetting,
|
||||||
ProvisionedServers, MetricsHttpStatus, SMON, WafRules, Alerts, GeoipCodes, NginxMetrics,
|
ProvisionedServers, MetricsHttpStatus, SMON, WafRules, Alerts, GeoipCodes, NginxMetrics,
|
||||||
SystemInfo, Services, UserName, GitSetting, CheckerSetting, ApacheMetrics, ProvisionParam,
|
SystemInfo, Services, UserName, GitSetting, CheckerSetting, ApacheMetrics, ProvisionParam,
|
||||||
WafNginx])
|
WafNginx, ServiceStatus])
|
||||||
|
|
97
app/funct.py
97
app/funct.py
|
@ -3,6 +3,8 @@ import cgi
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
import json
|
||||||
|
import http.cookies
|
||||||
|
|
||||||
|
|
||||||
def is_ip_or_dns(server_from_request: str) -> str:
|
def is_ip_or_dns(server_from_request: str) -> str:
|
||||||
|
@ -58,7 +60,7 @@ def get_config_var(sec, var):
|
||||||
return config.get(sec, var)
|
return config.get(sec, var)
|
||||||
except Exception:
|
except Exception:
|
||||||
print('Content-type: text/html\n')
|
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))
|
print(f'<center><div class="alert alert-danger">Check the config file. Presence section {sec} and parameter {var}</div>')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,7 +110,6 @@ def get_data(log_type, **kwargs):
|
||||||
|
|
||||||
def get_user_group(**kwargs):
|
def get_user_group(**kwargs):
|
||||||
import sql
|
import sql
|
||||||
import http.cookies
|
|
||||||
user_group = ''
|
user_group = ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -130,7 +131,6 @@ def get_user_group(**kwargs):
|
||||||
|
|
||||||
def logging(server_ip, action, **kwargs):
|
def logging(server_ip, action, **kwargs):
|
||||||
import sql
|
import sql
|
||||||
import http.cookies
|
|
||||||
import distro
|
import distro
|
||||||
|
|
||||||
login = ''
|
login = ''
|
||||||
|
@ -288,7 +288,6 @@ def slack_send_mess(mess, **kwargs):
|
||||||
|
|
||||||
def check_login(**kwargs):
|
def check_login(**kwargs):
|
||||||
import sql
|
import sql
|
||||||
import http.cookies
|
|
||||||
user_uuid = None
|
user_uuid = None
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
try:
|
try:
|
||||||
|
@ -325,7 +324,6 @@ def get_user_id(**kwargs):
|
||||||
if kwargs.get('login'):
|
if kwargs.get('login'):
|
||||||
return sql.get_user_id_by_username(kwargs.get('login'))
|
return sql.get_user_id_by_username(kwargs.get('login'))
|
||||||
|
|
||||||
import http.cookies
|
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
user_uuid = cookie.get('uuid')
|
user_uuid = cookie.get('uuid')
|
||||||
|
|
||||||
|
@ -337,7 +335,6 @@ def get_user_id(**kwargs):
|
||||||
|
|
||||||
def is_admin(**kwargs):
|
def is_admin(**kwargs):
|
||||||
import sql
|
import sql
|
||||||
import http.cookies
|
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
user_id = cookie.get('uuid')
|
user_id = cookie.get('uuid')
|
||||||
try:
|
try:
|
||||||
|
@ -364,8 +361,7 @@ def page_for_admin(**kwargs):
|
||||||
|
|
||||||
if not is_admin(level=give_level):
|
if not is_admin(level=give_level):
|
||||||
print('<meta http-equiv="refresh" content="0; url=/">')
|
print('<meta http-equiv="refresh" content="0; url=/">')
|
||||||
import sys
|
return
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
|
|
||||||
def return_ssh_keys_path(server_ip, **kwargs):
|
def return_ssh_keys_path(server_ip, **kwargs):
|
||||||
|
@ -439,6 +435,7 @@ def ssh_connect(server_ip):
|
||||||
|
|
||||||
def get_config(server_ip, cfg, **kwargs):
|
def get_config(server_ip, cfg, **kwargs):
|
||||||
import sql
|
import sql
|
||||||
|
config_path = ''
|
||||||
|
|
||||||
if kwargs.get("keepalived") or kwargs.get("service") == 'keepalived':
|
if kwargs.get("keepalived") or kwargs.get("service") == 'keepalived':
|
||||||
config_path = sql.get_setting('keepalived_config_path')
|
config_path = sql.get_setting('keepalived_config_path')
|
||||||
|
@ -479,7 +476,6 @@ def get_config(server_ip, cfg, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
def diff_config(oldcfg, cfg, **kwargs):
|
def diff_config(oldcfg, cfg, **kwargs):
|
||||||
import http.cookies
|
|
||||||
import sql
|
import sql
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
log_path = get_config_var('main', 'log_path')
|
log_path = get_config_var('main', 'log_path')
|
||||||
|
@ -628,7 +624,7 @@ def get_backends_from_config(server_ip, backends=''):
|
||||||
format_cfg = 'cfg'
|
format_cfg = 'cfg'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cfg = configs_dir + get_files(dir=configs_dir, format=format_cfg)[0]
|
cfg = configs_dir + get_files(configs_dir, format_cfg)[0]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging('localhost', str(e), haproxywi=1)
|
logging('localhost', str(e), haproxywi=1)
|
||||||
try:
|
try:
|
||||||
|
@ -987,9 +983,9 @@ def upload_and_restart(server_ip, cfg, **kwargs):
|
||||||
config_path = sql.get_setting('haproxy_config_path')
|
config_path = sql.get_setting('haproxy_config_path')
|
||||||
tmp_file = sql.get_setting('tmp_config_path') + "/" + get_data('config') + ".cfg"
|
tmp_file = sql.get_setting('tmp_config_path') + "/" + get_data('config') + ".cfg"
|
||||||
|
|
||||||
is_docker = sql.select_service_setting(server_id, service, 'dockerized')
|
is_dockerized = sql.select_service_setting(server_id, service, 'dockerized')
|
||||||
|
|
||||||
if is_docker == '1':
|
if is_dockerized == '1':
|
||||||
service_cont_name = service + '_container_name'
|
service_cont_name = service + '_container_name'
|
||||||
container_name = sql.get_setting(service_cont_name)
|
container_name = sql.get_setting(service_cont_name)
|
||||||
reload_command = " && sudo docker kill -s HUP " + container_name
|
reload_command = " && sudo docker kill -s HUP " + container_name
|
||||||
|
@ -1035,7 +1031,7 @@ def upload_and_restart(server_ip, cfg, **kwargs):
|
||||||
else:
|
else:
|
||||||
commands = [move_config + reload_or_restart_command]
|
commands = [move_config + reload_or_restart_command]
|
||||||
elif service == "nginx":
|
elif service == "nginx":
|
||||||
if is_docker == '1':
|
if is_dockerized == '1':
|
||||||
check_config = "sudo docker exec -it exec " + container_name + " nginx -t "
|
check_config = "sudo docker exec -it exec " + container_name + " nginx -t "
|
||||||
else:
|
else:
|
||||||
check_config = "sudo nginx -t "
|
check_config = "sudo nginx -t "
|
||||||
|
@ -1049,7 +1045,7 @@ def upload_and_restart(server_ip, cfg, **kwargs):
|
||||||
if sql.return_firewall(server_ip):
|
if sql.return_firewall(server_ip):
|
||||||
commands[0] += open_port_firewalld(cfg, server_ip=server_ip, service='nginx')
|
commands[0] += open_port_firewalld(cfg, server_ip=server_ip, service='nginx')
|
||||||
elif service == "apache":
|
elif service == "apache":
|
||||||
if is_docker == '1':
|
if is_dockerized == '1':
|
||||||
check_config = "sudo docker exec -it exec " + container_name + " sudo apachectl configtest "
|
check_config = "sudo docker exec -it exec " + container_name + " sudo apachectl configtest "
|
||||||
else:
|
else:
|
||||||
check_config = "sudo apachectl configtest "
|
check_config = "sudo apachectl configtest "
|
||||||
|
@ -1069,7 +1065,7 @@ def upload_and_restart(server_ip, cfg, **kwargs):
|
||||||
else:
|
else:
|
||||||
commands = [check_and_move + reload_or_restart_command]
|
commands = [check_and_move + reload_or_restart_command]
|
||||||
else:
|
else:
|
||||||
if is_docker == '1':
|
if is_dockerized == '1':
|
||||||
check_config = "sudo docker exec -it " + container_name + " haproxy -c -f " + tmp_file
|
check_config = "sudo docker exec -it " + container_name + " haproxy -c -f " + tmp_file
|
||||||
else:
|
else:
|
||||||
check_config = "sudo " + service_name + " -c -f " + tmp_file
|
check_config = "sudo " + service_name + " -c -f " + tmp_file
|
||||||
|
@ -1224,10 +1220,10 @@ def open_port_firewalld(cfg, server_ip, **kwargs):
|
||||||
def check_haproxy_config(server_ip):
|
def check_haproxy_config(server_ip):
|
||||||
import sql
|
import sql
|
||||||
server_id = sql.select_server_id_by_ip(server_ip=server_ip)
|
server_id = sql.select_server_id_by_ip(server_ip=server_ip)
|
||||||
is_docker = sql.select_service_setting(server_id, 'haproxy', 'dockerized')
|
is_dockerized = sql.select_service_setting(server_id, 'haproxy', 'dockerized')
|
||||||
config_path = sql.get_setting('haproxy_config_path')
|
config_path = sql.get_setting('haproxy_config_path')
|
||||||
|
|
||||||
if is_docker == '1':
|
if is_dockerized == '1':
|
||||||
container_name = sql.get_setting('haproxy_container_name')
|
container_name = sql.get_setting('haproxy_container_name')
|
||||||
commands = ["sudo docker exec -it " + container_name + " haproxy -q -c -f " + config_path]
|
commands = ["sudo docker exec -it " + container_name + " haproxy -q -c -f " + config_path]
|
||||||
else:
|
else:
|
||||||
|
@ -1301,7 +1297,10 @@ def show_finding_in_config(stdout: str, **kwargs) -> str:
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
def show_haproxy_log(serv, rows=10, waf='0', grep=None, hour='00', minut='00', hour1='24', minut1='00', service='haproxy', **kwargs):
|
def show_haproxy_log(
|
||||||
|
serv, rows='10', waf='0', grep=None, hour='00',
|
||||||
|
minut='00', hour1='24', minut1='00', service='haproxy', **kwargs
|
||||||
|
) -> str:
|
||||||
import sql
|
import sql
|
||||||
exgrep = form.getvalue('exgrep')
|
exgrep = form.getvalue('exgrep')
|
||||||
log_file = form.getvalue('file')
|
log_file = form.getvalue('file')
|
||||||
|
@ -1379,7 +1378,7 @@ def show_haproxy_log(serv, rows=10, waf='0', grep=None, hour='00', minut='00', h
|
||||||
user_grep = ''
|
user_grep = ''
|
||||||
|
|
||||||
log_path = get_config_var('main', 'log_path')
|
log_path = get_config_var('main', 'log_path')
|
||||||
logs_files = get_files(log_path, format="log")
|
logs_files = get_files(log_path, "log")
|
||||||
|
|
||||||
for key, value in logs_files:
|
for key, value in logs_files:
|
||||||
if int(serv) == key:
|
if int(serv) == key:
|
||||||
|
@ -1403,7 +1402,7 @@ def roxy_wi_log(**kwargs):
|
||||||
log_path = get_config_var('main', 'log_path')
|
log_path = get_config_var('main', 'log_path')
|
||||||
|
|
||||||
if kwargs.get('log_id'):
|
if kwargs.get('log_id'):
|
||||||
selects = get_files(log_path, format="log")
|
selects = get_files(log_path, "log")
|
||||||
for key, value in selects:
|
for key, value in selects:
|
||||||
log_file = kwargs.get('file') + ".log"
|
log_file = kwargs.get('file') + ".log"
|
||||||
if log_file == value:
|
if log_file == value:
|
||||||
|
@ -1495,7 +1494,6 @@ def subprocess_execute(cmd):
|
||||||
|
|
||||||
|
|
||||||
def show_backends(server_ip, **kwargs):
|
def show_backends(server_ip, **kwargs):
|
||||||
import json
|
|
||||||
import sql
|
import sql
|
||||||
hap_sock_p = sql.get_setting('haproxy_sock_port')
|
hap_sock_p = sql.get_setting('haproxy_sock_port')
|
||||||
cmd = 'echo "show backend" |nc %s %s' % (server_ip, hap_sock_p)
|
cmd = 'echo "show backend" |nc %s %s' % (server_ip, hap_sock_p)
|
||||||
|
@ -1520,22 +1518,22 @@ def show_backends(server_ip, **kwargs):
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def get_files(dir=get_config_var('configs', 'haproxy_save_configs_dir'), format='cfg'):
|
def get_files(folder=get_config_var('configs', 'haproxy_save_configs_dir'), file_format='cfg'):
|
||||||
import glob
|
import glob
|
||||||
if format == 'log':
|
if file_format == 'log':
|
||||||
file = []
|
file = []
|
||||||
else:
|
else:
|
||||||
file = set()
|
file = set()
|
||||||
return_files = set()
|
return_files = set()
|
||||||
i = 0
|
i = 0
|
||||||
for files in sorted(glob.glob(os.path.join(dir, '*.' + format + '*'))):
|
for files in sorted(glob.glob(os.path.join(folder, '*.' + file_format + '*'))):
|
||||||
if format == 'log':
|
if file_format == 'log':
|
||||||
file += [(i, files.split('/')[5])]
|
file += [(i, files.split('/')[5])]
|
||||||
else:
|
else:
|
||||||
file.add(files.split('/')[-1])
|
file.add(files.split('/')[-1])
|
||||||
i += 1
|
i += 1
|
||||||
files = file
|
files = file
|
||||||
if format == 'cfg' or format == 'conf':
|
if file_format == 'cfg' or file_format == 'conf':
|
||||||
for file in files:
|
for file in files:
|
||||||
ip = file.split("-")
|
ip = file.split("-")
|
||||||
if serv == ip[0]:
|
if serv == ip[0]:
|
||||||
|
@ -1593,20 +1591,23 @@ def check_new_version(service):
|
||||||
if proxy is not None and proxy != '' and proxy != 'None':
|
if proxy is not None and proxy != '' and proxy != 'None':
|
||||||
proxy_dict = {"https": proxy, "http": proxy}
|
proxy_dict = {"https": proxy, "http": proxy}
|
||||||
response = requests.get(f'https://roxy-wi.org/version/get/{service}', timeout=1, proxies=proxy_dict)
|
response = requests.get(f'https://roxy-wi.org/version/get/{service}', timeout=1, proxies=proxy_dict)
|
||||||
requests.get(f'https://roxy-wi.org/version/send/{current_ver}', timeout=1, proxies=proxy_dict)
|
if service == 'roxy-wi':
|
||||||
response_status = requests.get(f'https://roxy-wi.org/user-name/{user_name}', timeout=1, proxies=proxy_dict)
|
requests.get(f'https://roxy-wi.org/version/send/{current_ver}', timeout=1, proxies=proxy_dict)
|
||||||
|
response_status = requests.get(f'https://roxy-wi.org/user-name/{user_name}', timeout=1, proxies=proxy_dict)
|
||||||
else:
|
else:
|
||||||
response = requests.get(f'https://roxy-wi.org/version/get/{service}', timeout=1)
|
response = requests.get(f'https://roxy-wi.org/version/get/{service}', timeout=1)
|
||||||
requests.get(f'https://roxy-wi.org/version/send/{current_ver}', timeout=1)
|
if service == 'roxy-wi':
|
||||||
response_status = requests.get(f'https://roxy-wi.org/user-name/{user_name}', timeout=1)
|
requests.get(f'https://roxy-wi.org/version/send/{current_ver}', timeout=1)
|
||||||
|
response_status = requests.get(f'https://roxy-wi.org/user-name/{user_name}', timeout=1)
|
||||||
|
|
||||||
res = response.content.decode(encoding='UTF-8')
|
res = response.content.decode(encoding='UTF-8')
|
||||||
try:
|
if service == 'roxy-wi':
|
||||||
status = response_status.content.decode(encoding='UTF-8')
|
try:
|
||||||
status = status.split(' ')
|
status = response_status.content.decode(encoding='UTF-8')
|
||||||
sql.update_user_status(status[0], status[1].strip(), status[2].strip())
|
status = status.split(' ')
|
||||||
except Exception:
|
sql.update_user_status(status[0], status[1].strip(), status[2].strip())
|
||||||
pass
|
except Exception:
|
||||||
|
pass
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
logging('localhost', ' ' + str(e), haproxywi=1)
|
logging('localhost', ' ' + str(e), haproxywi=1)
|
||||||
|
|
||||||
|
@ -1655,7 +1656,6 @@ def get_hash(value):
|
||||||
|
|
||||||
|
|
||||||
def get_users_params(**kwargs):
|
def get_users_params(**kwargs):
|
||||||
import http.cookies
|
|
||||||
import sql
|
import sql
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
|
|
||||||
|
@ -1667,6 +1667,11 @@ def get_users_params(**kwargs):
|
||||||
user_services = sql.select_user_services(user_id)
|
user_services = sql.select_user_services(user_id)
|
||||||
token = sql.get_token(user_uuid.value)
|
token = sql.get_token(user_uuid.value)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
user = ''
|
||||||
|
role = ''
|
||||||
|
user_uuid = ''
|
||||||
|
user_services = ''
|
||||||
|
token = ''
|
||||||
print('<meta http-equiv="refresh" content="0; url=/app/login.py">')
|
print('<meta http-equiv="refresh" content="0; url=/app/login.py">')
|
||||||
|
|
||||||
if kwargs.get('virt') and kwargs.get('haproxy'):
|
if kwargs.get('virt') and kwargs.get('haproxy'):
|
||||||
|
@ -1693,8 +1698,6 @@ def check_user_group(**kwargs):
|
||||||
user_uuid = kwargs.get('user_uuid')
|
user_uuid = kwargs.get('user_uuid')
|
||||||
user_id = sql.get_user_id_by_uuid(user_uuid)
|
user_id = sql.get_user_id_by_uuid(user_uuid)
|
||||||
else:
|
else:
|
||||||
import http.cookies
|
|
||||||
import os
|
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
user_uuid = cookie.get('uuid')
|
user_uuid = cookie.get('uuid')
|
||||||
group = cookie.get('group')
|
group = cookie.get('group')
|
||||||
|
@ -1825,7 +1828,6 @@ def is_service_active(server_ip: str, service_name: str):
|
||||||
|
|
||||||
|
|
||||||
def get_system_info(server_ip: str) -> bool:
|
def get_system_info(server_ip: str) -> bool:
|
||||||
import json
|
|
||||||
import sql
|
import sql
|
||||||
server_ip = is_ip_or_dns(server_ip)
|
server_ip = is_ip_or_dns(server_ip)
|
||||||
if server_ip == '':
|
if server_ip == '':
|
||||||
|
@ -2083,7 +2085,6 @@ def send_message_to_rabbit(message: str, **kwargs) -> None:
|
||||||
|
|
||||||
def is_restarted(server_ip, action):
|
def is_restarted(server_ip, action):
|
||||||
import sql
|
import sql
|
||||||
import http.cookies
|
|
||||||
|
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
user_uuid = cookie.get('uuid')
|
user_uuid = cookie.get('uuid')
|
||||||
|
@ -2094,7 +2095,7 @@ def is_restarted(server_ip, action):
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
def is_not_allowed_to_restart(server_id: int, service: str) -> bool:
|
def is_not_allowed_to_restart(server_id: int, service: str) -> None:
|
||||||
import sql
|
import sql
|
||||||
is_restart = sql.select_service_setting(server_id, service, 'restart')
|
is_restart = sql.select_service_setting(server_id, service, 'restart')
|
||||||
|
|
||||||
|
@ -2159,11 +2160,11 @@ def send_email(email_to: str, subject: str, message: str) -> None:
|
||||||
msg['To'] = email_to
|
msg['To'] = email_to
|
||||||
|
|
||||||
try:
|
try:
|
||||||
smtpObj = SMTP(mail_smtp_host, mail_smtp_port)
|
smtp_obj = SMTP(mail_smtp_host, mail_smtp_port)
|
||||||
if mail_ssl:
|
if mail_ssl:
|
||||||
smtpObj.starttls()
|
smtp_obj.starttls()
|
||||||
smtpObj.login(mail_smtp_user, mail_smtp_password)
|
smtp_obj.login(mail_smtp_user, mail_smtp_password)
|
||||||
smtpObj.send_message(msg)
|
smtp_obj.send_message(msg)
|
||||||
logging('localhost', 'An email has been sent to ' + email_to, haproxywi=1)
|
logging('localhost', 'An email has been sent to ' + email_to, haproxywi=1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging('localhost', 'error: unable to send email: ' + str(e), haproxywi=1)
|
logging('localhost', 'error: unable to send email: ' + str(e), haproxywi=1)
|
||||||
|
@ -2182,8 +2183,8 @@ def send_email_to_server_group(subject: str, mes: str, group_id: int) -> None:
|
||||||
|
|
||||||
|
|
||||||
def alert_routing(
|
def alert_routing(
|
||||||
server_ip: str, service_id: int, group_id: int, level: str, mes: str, alert_type: str) -> None:
|
server_ip: str, service_id: int, group_id: int, level: str, mes: str, alert_type: str
|
||||||
import json
|
) -> None:
|
||||||
import sql
|
import sql
|
||||||
|
|
||||||
subject: str = level + ': ' + mes
|
subject: str = level + ': ' + mes
|
||||||
|
|
|
@ -20,10 +20,11 @@ serv = funct.is_ip_or_dns(form.getvalue('serv'))
|
||||||
service = funct.checkAjaxInput(form.getvalue('service'))
|
service = funct.checkAjaxInput(form.getvalue('service'))
|
||||||
autorefresh = 0
|
autorefresh = 0
|
||||||
servers_waf = ()
|
servers_waf = ()
|
||||||
title = "HAProxy servers overview"
|
title = ''
|
||||||
cmd = "ps ax |grep -e 'keep_alive.py' |grep -v grep |wc -l"
|
cmd = "ps ax |grep -e 'keep_alive.py' |grep -v grep |wc -l"
|
||||||
keep_alive, stderr = funct.subprocess_execute(cmd)
|
keep_alive, stderr = funct.subprocess_execute(cmd)
|
||||||
is_restart = ''
|
is_restart = ''
|
||||||
|
service_desc = ''
|
||||||
restart_settings = ''
|
restart_settings = ''
|
||||||
|
|
||||||
if service in ('haproxy', 'nginx', 'keepalived', 'apache'):
|
if service in ('haproxy', 'nginx', 'keepalived', 'apache'):
|
||||||
|
@ -177,6 +178,6 @@ template = template.render(
|
||||||
h2=1, autorefresh=autorefresh, title=title, role=role, user=user, servers=servers_with_status1,
|
h2=1, autorefresh=autorefresh, title=title, role=role, user=user, servers=servers_with_status1,
|
||||||
keep_alive=''.join(keep_alive), serv=serv, service=service, services=services, user_services=user_services,
|
keep_alive=''.join(keep_alive), serv=serv, service=service, services=services, user_services=user_services,
|
||||||
docker_settings=docker_settings, user_status=user_status, user_plan=user_plan, servers_waf=servers_waf,
|
docker_settings=docker_settings, user_status=user_status, user_plan=user_plan, servers_waf=servers_waf,
|
||||||
restart_settings=restart_settings, token=token
|
restart_settings=restart_settings, service_desc=service_desc, token=token
|
||||||
)
|
)
|
||||||
print(template)
|
print(template)
|
||||||
|
|
175
app/options.py
175
app/options.py
|
@ -2,6 +2,10 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import json
|
||||||
|
import http.cookies
|
||||||
|
|
||||||
|
from jinja2 import Environment, FileSystemLoader
|
||||||
|
|
||||||
import funct
|
import funct
|
||||||
import sql
|
import sql
|
||||||
|
@ -249,8 +253,6 @@ if form.getvalue('table_serv_select') is not None:
|
||||||
print(funct.get_all_stick_table())
|
print(funct.get_all_stick_table())
|
||||||
|
|
||||||
if form.getvalue('table_select') is not None:
|
if form.getvalue('table_select') is not None:
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates'), autoescape=True,
|
env = Environment(loader=FileSystemLoader('templates'), autoescape=True,
|
||||||
extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do'], trim_blocks=True, lstrip_blocks=True)
|
extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do'], trim_blocks=True, lstrip_blocks=True)
|
||||||
table = form.getvalue('table_select')
|
table = form.getvalue('table_select')
|
||||||
|
@ -302,8 +304,6 @@ if form.getvalue('list_serv_select') is not None:
|
||||||
print(output)
|
print(output)
|
||||||
|
|
||||||
if form.getvalue('list_select_id') is not None:
|
if form.getvalue('list_select_id') is not None:
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True,
|
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True,
|
||||||
extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do'], trim_blocks=True, lstrip_blocks=True)
|
extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do'], trim_blocks=True, lstrip_blocks=True)
|
||||||
template = env.get_template('ajax/list.html')
|
template = env.get_template('ajax/list.html')
|
||||||
|
@ -378,8 +378,6 @@ if form.getvalue('list_ip_for_add') is not None:
|
||||||
service='haproxy')
|
service='haproxy')
|
||||||
|
|
||||||
if form.getvalue('sessions_select') is not None:
|
if form.getvalue('sessions_select') is not None:
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates'), autoescape=True,
|
env = Environment(loader=FileSystemLoader('templates'), autoescape=True,
|
||||||
extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do'], trim_blocks=True, lstrip_blocks=True)
|
extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do'], trim_blocks=True, lstrip_blocks=True)
|
||||||
serv = funct.checkAjaxInput(form.getvalue('sessions_select'))
|
serv = funct.checkAjaxInput(form.getvalue('sessions_select'))
|
||||||
|
@ -592,8 +590,6 @@ if form.getvalue('action_service') is not None:
|
||||||
funct.logging('localhost', ' The service ' + serv + ' has been ' + action + 'ed', haproxywi=1, login=1)
|
funct.logging('localhost', ' The service ' + serv + ' has been ' + action + 'ed', haproxywi=1, login=1)
|
||||||
|
|
||||||
if act == "overviewHapserverBackends":
|
if act == "overviewHapserverBackends":
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
||||||
template = env.get_template('haproxyservers_backends.html')
|
template = env.get_template('haproxyservers_backends.html')
|
||||||
service = form.getvalue('service')
|
service = form.getvalue('service')
|
||||||
|
@ -608,7 +604,7 @@ if act == "overviewHapserverBackends":
|
||||||
|
|
||||||
if service != 'nginx' and service != 'apache':
|
if service != 'nginx' and service != 'apache':
|
||||||
try:
|
try:
|
||||||
sections = funct.get_sections(configs_dir + funct.get_files(dir=configs_dir, format=format_file)[0], service=service)
|
sections = funct.get_sections(configs_dir + funct.get_files(configs_dir, format_file)[0], service=service)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
funct.logging('localhost', str(e), haproxywi=1)
|
funct.logging('localhost', str(e), haproxywi=1)
|
||||||
|
|
||||||
|
@ -639,7 +635,7 @@ if form.getvalue('show_userlists'):
|
||||||
format_file = 'cfg'
|
format_file = 'cfg'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sections = funct.get_userlists(configs_dir + funct.get_files(dir=configs_dir, format=format_file)[0])
|
sections = funct.get_userlists(configs_dir + funct.get_files(configs_dir, format_file)[0])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
funct.logging('localhost', str(e), haproxywi=1)
|
funct.logging('localhost', str(e), haproxywi=1)
|
||||||
try:
|
try:
|
||||||
|
@ -673,8 +669,6 @@ if act == "overviewHapservers":
|
||||||
|
|
||||||
if act == "overview":
|
if act == "overview":
|
||||||
import asyncio
|
import asyncio
|
||||||
import http.cookies
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
async def async_get_overview(serv1, serv2, user_uuid, server_id):
|
async def async_get_overview(serv1, serv2, user_uuid, server_id):
|
||||||
user_id = sql.get_user_id_by_uuid(user_uuid)
|
user_id = sql.get_user_id_by_uuid(user_uuid)
|
||||||
|
@ -753,9 +747,6 @@ if act == "overview":
|
||||||
ioloop.close()
|
ioloop.close()
|
||||||
|
|
||||||
if act == "overviewwaf":
|
if act == "overviewwaf":
|
||||||
import http.cookies
|
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
env = Environment(
|
env = Environment(
|
||||||
loader=FileSystemLoader('templates/ajax'), autoescape=True,
|
loader=FileSystemLoader('templates/ajax'), autoescape=True,
|
||||||
extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do']
|
extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do']
|
||||||
|
@ -846,8 +837,6 @@ if act == "overviewServers":
|
||||||
return server_status
|
return server_status
|
||||||
|
|
||||||
async def get_runner_overviewServers(**kwargs):
|
async def get_runner_overviewServers(**kwargs):
|
||||||
import http.cookies
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/ajax'),
|
env = Environment(loader=FileSystemLoader('templates/ajax'),
|
||||||
extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do'])
|
extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do'])
|
||||||
template = env.get_template('overviewServers.html')
|
template = env.get_template('overviewServers.html')
|
||||||
|
@ -933,8 +922,6 @@ if serv is not None and act == "stats":
|
||||||
|
|
||||||
data = response.content
|
data = response.content
|
||||||
if form.getvalue('service') == 'nginx':
|
if form.getvalue('service') == 'nginx':
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
||||||
template = env.get_template('ajax/nginx_stats.html')
|
template = env.get_template('ajax/nginx_stats.html')
|
||||||
|
|
||||||
|
@ -1226,8 +1213,6 @@ if form.getvalue('servaction') is not None:
|
||||||
funct.logging(serv, action)
|
funct.logging(serv, action)
|
||||||
|
|
||||||
if act == "showCompareConfigs":
|
if act == "showCompareConfigs":
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
||||||
template = env.get_template('ajax/show_compare_configs.html')
|
template = env.get_template('ajax/show_compare_configs.html')
|
||||||
left = form.getvalue('left')
|
left = form.getvalue('left')
|
||||||
|
@ -1247,8 +1232,6 @@ if act == "showCompareConfigs":
|
||||||
print(template)
|
print(template)
|
||||||
|
|
||||||
if serv is not None and form.getvalue('right') is not None:
|
if serv is not None and form.getvalue('right') is not None:
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
left = funct.checkAjaxInput(form.getvalue('left'))
|
left = funct.checkAjaxInput(form.getvalue('left'))
|
||||||
right = funct.checkAjaxInput(form.getvalue('right'))
|
right = funct.checkAjaxInput(form.getvalue('right'))
|
||||||
|
|
||||||
|
@ -1273,8 +1256,6 @@ if serv is not None and form.getvalue('right') is not None:
|
||||||
print(stderr)
|
print(stderr)
|
||||||
|
|
||||||
if serv is not None and act == "configShow":
|
if serv is not None and act == "configShow":
|
||||||
import http.cookies
|
|
||||||
|
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
user_uuid = cookie.get('uuid')
|
user_uuid = cookie.get('uuid')
|
||||||
role_id = sql.get_user_role_by_uuid(user_uuid.value)
|
role_id = sql.get_user_role_by_uuid(user_uuid.value)
|
||||||
|
@ -1317,9 +1298,6 @@ if serv is not None and act == "configShow":
|
||||||
is_serv_protected = sql.is_serv_protected(serv)
|
is_serv_protected = sql.is_serv_protected(serv)
|
||||||
server_id = sql.select_server_id_by_ip(serv)
|
server_id = sql.select_server_id_by_ip(serv)
|
||||||
is_restart = sql.select_service_setting(server_id, service, 'restart')
|
is_restart = sql.select_service_setting(server_id, service, 'restart')
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True, trim_blocks=True, lstrip_blocks=True,
|
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True, trim_blocks=True, lstrip_blocks=True,
|
||||||
extensions=["jinja2.ext.loopcontrols", "jinja2.ext.do"])
|
extensions=["jinja2.ext.loopcontrols", "jinja2.ext.do"])
|
||||||
template = env.get_template('config_show.html')
|
template = env.get_template('config_show.html')
|
||||||
|
@ -1351,8 +1329,6 @@ if act == 'configShowFiles':
|
||||||
print(return_files)
|
print(return_files)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
return_files += ' ' + sql.get_setting(service + '_config_path')
|
return_files += ' ' + sql.get_setting(service + '_config_path')
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
||||||
template = env.get_template('ajax/show_configs_files.html')
|
template = env.get_template('ajax/show_configs_files.html')
|
||||||
template = template.render(serv=serv, service=service, return_files=return_files,
|
template = template.render(serv=serv, service=service, return_files=return_files,
|
||||||
|
@ -1366,7 +1342,6 @@ if act == 'showRemoteLogFiles':
|
||||||
if 'error: ' in return_files:
|
if 'error: ' in return_files:
|
||||||
print(return_files)
|
print(return_files)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
||||||
template = env.get_template('ajax/show_log_files.html')
|
template = env.get_template('ajax/show_log_files.html')
|
||||||
|
@ -1408,8 +1383,8 @@ if form.getvalue('master'):
|
||||||
commands = [
|
commands = [
|
||||||
"chmod +x " + script + " && ./" + script + " PROXY=" + proxy_serv + " SSH_PORT=" + ssh_port + " router_id=" + router_id
|
"chmod +x " + script + " && ./" + script + " PROXY=" + proxy_serv + " SSH_PORT=" + ssh_port + " router_id=" + router_id
|
||||||
+ " ETH=" + ETH + " IP=" + str(IP) + " MASTER=MASTER" + " ETH_SLAVE=" + ETH_SLAVE + " keepalived_path_logs=" + keepalived_path_logs
|
+ " ETH=" + ETH + " IP=" + str(IP) + " MASTER=MASTER" + " ETH_SLAVE=" + ETH_SLAVE + " keepalived_path_logs=" + keepalived_path_logs
|
||||||
+ " RETURN_TO_MASTER=" + return_to_master + " SYN_FLOOD=" + syn_flood + " HOST=" + str(master)
|
+ " RETURN_TO_MASTER=" + return_to_master + " SYN_FLOOD=" + syn_flood + " HOST=" + str(master) + " HAPROXY=" + haproxy
|
||||||
+ " USER=" + str(ssh_user_name) + " PASS='" + str(ssh_user_password) + "' KEY=" + str(ssh_key_name)
|
+ " NGINX=" + nginx + " USER=" + str(ssh_user_name) + " PASS='" + str(ssh_user_password) + "' KEY=" + str(ssh_key_name)
|
||||||
]
|
]
|
||||||
|
|
||||||
output, error = funct.subprocess_execute(commands[0])
|
output, error = funct.subprocess_execute(commands[0])
|
||||||
|
@ -1433,6 +1408,8 @@ if form.getvalue('master_slave'):
|
||||||
ETH_SLAVE = form.getvalue('slave_interface')
|
ETH_SLAVE = form.getvalue('slave_interface')
|
||||||
IP = form.getvalue('vrrpip')
|
IP = form.getvalue('vrrpip')
|
||||||
syn_flood = form.getvalue('syn_flood')
|
syn_flood = form.getvalue('syn_flood')
|
||||||
|
haproxy = form.getvalue('hap')
|
||||||
|
nginx = form.getvalue('nginx')
|
||||||
router_id = form.getvalue('router_id')
|
router_id = form.getvalue('router_id')
|
||||||
script = "install_keepalived.sh"
|
script = "install_keepalived.sh"
|
||||||
proxy = sql.get_setting('proxy')
|
proxy = sql.get_setting('proxy')
|
||||||
|
@ -1457,7 +1434,7 @@ if form.getvalue('master_slave'):
|
||||||
commands = [
|
commands = [
|
||||||
"chmod +x " + script + " && ./" + script + " PROXY=" + proxy_serv + " SSH_PORT=" + ssh_port + " router_id=" + router_id
|
"chmod +x " + script + " && ./" + script + " PROXY=" + proxy_serv + " SSH_PORT=" + ssh_port + " router_id=" + router_id
|
||||||
+ " ETH=" + ETH + " IP=" + IP + " MASTER=BACKUP" + " ETH_SLAVE=" + ETH_SLAVE + " keepalived_path_logs=" + keepalived_path_logs
|
+ " ETH=" + ETH + " IP=" + IP + " MASTER=BACKUP" + " ETH_SLAVE=" + ETH_SLAVE + " keepalived_path_logs=" + keepalived_path_logs
|
||||||
+ " HOST=" + str(slave) + " USER=" + str(ssh_user_name) + " PASS='" + str(ssh_user_password)
|
+ " HAPROXY=" + HAPROXY + " NGINX=" + nginx + " HOST=" + str(slave) + " USER=" + str(ssh_user_name) + " PASS='" + str(ssh_user_password)
|
||||||
+ "' KEY=" + str(ssh_key_name)
|
+ "' KEY=" + str(ssh_key_name)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1575,6 +1552,7 @@ if form.getvalue('master_slave_nginx'):
|
||||||
if form.getvalue('install_grafana'):
|
if form.getvalue('install_grafana'):
|
||||||
script = "install_grafana.sh"
|
script = "install_grafana.sh"
|
||||||
proxy = sql.get_setting('proxy')
|
proxy = sql.get_setting('proxy')
|
||||||
|
host = os.environ.get('HTTP_HOST', '')
|
||||||
|
|
||||||
os.system("cp scripts/%s ." % script)
|
os.system("cp scripts/%s ." % script)
|
||||||
|
|
||||||
|
@ -1589,10 +1567,9 @@ if form.getvalue('install_grafana'):
|
||||||
|
|
||||||
if error:
|
if error:
|
||||||
funct.logging('localhost', error, haproxywi=1)
|
funct.logging('localhost', error, haproxywi=1)
|
||||||
import socket
|
|
||||||
|
|
||||||
print(
|
print(
|
||||||
'success: Grafana and Prometheus servers were installed. You can find Grafana on http://' + socket.gethostname() + ':3000<br>')
|
f'success: Grafana and Prometheus servers were installed. You can find Grafana on http://{host}:3000<br>')
|
||||||
else:
|
else:
|
||||||
for line in output:
|
for line in output:
|
||||||
if any(s in line for s in ("Traceback", "FAILED")):
|
if any(s in line for s in ("Traceback", "FAILED")):
|
||||||
|
@ -1603,10 +1580,8 @@ if form.getvalue('install_grafana'):
|
||||||
print(output)
|
print(output)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
import socket
|
|
||||||
|
|
||||||
print(
|
print(
|
||||||
'success: Grafana and Prometheus servers were installed. You can find Grafana on http://' + socket.gethostname() + ':3000<br>')
|
f'success: Grafana and Prometheus servers were installed. You can find Grafana on http://{host}:3000<br>')
|
||||||
|
|
||||||
os.system("rm -f %s" % script)
|
os.system("rm -f %s" % script)
|
||||||
|
|
||||||
|
@ -1778,8 +1753,6 @@ if form.getvalue('backup') or form.getvalue('deljob') or form.getvalue('backupup
|
||||||
else:
|
else:
|
||||||
if not deljob and not update:
|
if not deljob and not update:
|
||||||
if sql.insert_backup_job(serv, rserver, rpath, backup_type, time, cred, description):
|
if sql.insert_backup_job(serv, rserver, rpath, backup_type, time, cred, description):
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
||||||
template = env.get_template('new_backup.html')
|
template = env.get_template('new_backup.html')
|
||||||
template = template.render(
|
template = template.render(
|
||||||
|
@ -1858,8 +1831,6 @@ if form.getvalue('git_backup'):
|
||||||
server_id=server_id, service_id=service_id, repo=repo, branch=branch,
|
server_id=server_id, service_id=service_id, repo=repo, branch=branch,
|
||||||
period=period, cred=cred, description=description
|
period=period, cred=cred, description=description
|
||||||
):
|
):
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
gits = sql.select_gits(server_id=server_id, service_id=service_id)
|
gits = sql.select_gits(server_id=server_id, service_id=service_id)
|
||||||
sshs = sql.select_ssh()
|
sshs = sql.select_ssh()
|
||||||
|
|
||||||
|
@ -1914,7 +1885,6 @@ if form.getvalue('table_metrics'):
|
||||||
metrics = sql.select_service_table_metrics(service)
|
metrics = sql.select_service_table_metrics(service)
|
||||||
else:
|
else:
|
||||||
metrics = sql.select_table_metrics()
|
metrics = sql.select_table_metrics()
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
||||||
template = env.get_template('table_metrics.html')
|
template = env.get_template('table_metrics.html')
|
||||||
|
@ -1923,8 +1893,6 @@ if form.getvalue('table_metrics'):
|
||||||
print(template)
|
print(template)
|
||||||
|
|
||||||
if form.getvalue('metrics_hapwi_ram'):
|
if form.getvalue('metrics_hapwi_ram'):
|
||||||
import json
|
|
||||||
|
|
||||||
ip = form.getvalue('ip')
|
ip = form.getvalue('ip')
|
||||||
metrics = {'chartData': {}}
|
metrics = {'chartData': {}}
|
||||||
rams = ''
|
rams = ''
|
||||||
|
@ -1956,8 +1924,6 @@ if form.getvalue('metrics_hapwi_cpu'):
|
||||||
cpus = ''
|
cpus = ''
|
||||||
|
|
||||||
if ip == '1':
|
if ip == '1':
|
||||||
# cmd = "top -b -n 1 |grep Cpu |awk -F':' '{print $2}'|awk -F' ' 'BEGIN{ORS=\" \";} { for (i=1;i<=NF;i+=2) print $i}'"
|
|
||||||
# metric, error = funct.subprocess_execute(cmd)
|
|
||||||
import psutil
|
import psutil
|
||||||
|
|
||||||
cpus_list = psutil.cpu_times_percent(interval=1, percpu=False)
|
cpus_list = psutil.cpu_times_percent(interval=1, percpu=False)
|
||||||
|
@ -1979,8 +1945,6 @@ if form.getvalue('metrics_hapwi_cpu'):
|
||||||
|
|
||||||
metrics['chartData']['cpus'] = cpus
|
metrics['chartData']['cpus'] = cpus
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
print(json.dumps(metrics))
|
print(json.dumps(metrics))
|
||||||
|
|
||||||
if form.getvalue('new_metrics'):
|
if form.getvalue('new_metrics'):
|
||||||
|
@ -2011,8 +1975,6 @@ if form.getvalue('new_metrics'):
|
||||||
metrics['chartData']['sess_rate'] = sess_rate
|
metrics['chartData']['sess_rate'] = sess_rate
|
||||||
metrics['chartData']['server'] = hostname + ' (' + server + ')'
|
metrics['chartData']['server'] = hostname + ' (' + server + ')'
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
print(json.dumps(metrics))
|
print(json.dumps(metrics))
|
||||||
|
|
||||||
if form.getvalue('new_http_metrics'):
|
if form.getvalue('new_http_metrics'):
|
||||||
|
@ -2046,8 +2008,6 @@ if form.getvalue('new_http_metrics'):
|
||||||
metrics['chartData']['http_5xx'] = http_5xx
|
metrics['chartData']['http_5xx'] = http_5xx
|
||||||
metrics['chartData']['server'] = hostname + ' (' + server + ')'
|
metrics['chartData']['server'] = hostname + ' (' + server + ')'
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
print(json.dumps(metrics))
|
print(json.dumps(metrics))
|
||||||
|
|
||||||
if any((form.getvalue('new_nginx_metrics'), form.getvalue('new_apache_metrics'), form.getvalue('new_waf_metrics'))):
|
if any((form.getvalue('new_nginx_metrics'), form.getvalue('new_apache_metrics'), form.getvalue('new_waf_metrics'))):
|
||||||
|
@ -2080,8 +2040,6 @@ if any((form.getvalue('new_nginx_metrics'), form.getvalue('new_apache_metrics'),
|
||||||
metrics['chartData']['curr_con'] = curr_con
|
metrics['chartData']['curr_con'] = curr_con
|
||||||
metrics['chartData']['server'] = hostname + ' (' + serv + ')'
|
metrics['chartData']['server'] = hostname + ' (' + serv + ')'
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
print(json.dumps(metrics))
|
print(json.dumps(metrics))
|
||||||
|
|
||||||
if form.getvalue('get_hap_v'):
|
if form.getvalue('get_hap_v'):
|
||||||
|
@ -2225,7 +2183,7 @@ if form.getvalue('bwlists_delete'):
|
||||||
if form.getvalue('get_lists'):
|
if form.getvalue('get_lists'):
|
||||||
lib_path = funct.get_config_var('main', 'lib_path')
|
lib_path = funct.get_config_var('main', 'lib_path')
|
||||||
list_path = lib_path + "/" + sql.get_setting('lists_path') + "/" + form.getvalue('group') + "/" + form.getvalue('color')
|
list_path = lib_path + "/" + sql.get_setting('lists_path') + "/" + form.getvalue('group') + "/" + form.getvalue('color')
|
||||||
lists = funct.get_files(dir=list_path, format="lst")
|
lists = funct.get_files(list_path, "lst")
|
||||||
for l in lists:
|
for l in lists:
|
||||||
print(l)
|
print(l)
|
||||||
|
|
||||||
|
@ -2296,8 +2254,6 @@ if form.getvalue('newuser') is not None:
|
||||||
if funct.check_user_group():
|
if funct.check_user_group():
|
||||||
if funct.is_admin(level=role_id):
|
if funct.is_admin(level=role_id):
|
||||||
if sql.add_user(new_user, email, password, role, activeuser, group):
|
if sql.add_user(new_user, email, password, role, activeuser, group):
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
||||||
template = env.get_template('ajax/new_user.html')
|
template = env.get_template('ajax/new_user.html')
|
||||||
|
|
||||||
|
@ -2424,8 +2380,6 @@ if form.getvalue('newserver') is not None:
|
||||||
user_status, user_plan = 0, 0
|
user_status, user_plan = 0, 0
|
||||||
funct.logging('localhost', 'Cannot get a user plan: ' + str(e), haproxywi=1)
|
funct.logging('localhost', 'Cannot get a user plan: ' + str(e), haproxywi=1)
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
||||||
template = env.get_template('ajax/new_server.html')
|
template = env.get_template('ajax/new_server.html')
|
||||||
|
|
||||||
|
@ -2504,8 +2458,6 @@ if form.getvalue('newgroup') is not None:
|
||||||
print(error_mess)
|
print(error_mess)
|
||||||
else:
|
else:
|
||||||
if sql.add_group(newgroup, desc):
|
if sql.add_group(newgroup, desc):
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/ajax/'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/ajax/'), autoescape=True)
|
||||||
template = env.get_template('/new_group.html')
|
template = env.get_template('/new_group.html')
|
||||||
|
|
||||||
|
@ -2550,8 +2502,6 @@ if form.getvalue('new_ssh'):
|
||||||
print(error_mess)
|
print(error_mess)
|
||||||
else:
|
else:
|
||||||
if sql.insert_new_ssh(name, enable, group, username, password):
|
if sql.insert_new_ssh(name, enable, group, username, password):
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
||||||
template = env.get_template('/new_ssh.html')
|
template = env.get_template('/new_ssh.html')
|
||||||
output_from_parsed_template = template.render(groups=sql.select_groups(), sshs=sql.select_ssh(name=name),
|
output_from_parsed_template = template.render(groups=sql.select_groups(), sshs=sql.select_ssh(name=name),
|
||||||
|
@ -2621,13 +2571,14 @@ if form.getvalue('ssh_cert'):
|
||||||
key = paramiko.pkey.load_private_key(form.getvalue('ssh_cert'))
|
key = paramiko.pkey.load_private_key(form.getvalue('ssh_cert'))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('error: Cannot save SSH key file: ', str(e))
|
print('error: Cannot save SSH key file: ', str(e))
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
lib_path = funct.get_config_var('main', 'lib_path')
|
lib_path = funct.get_config_var('main', 'lib_path')
|
||||||
full_dir = lib_path + '/keys/'
|
full_dir = lib_path + '/keys/'
|
||||||
ssh_keys = name + '.pem'
|
ssh_keys = name + '.pem'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
split_name = name.split('_')[1]
|
check_split = name.split('_')[1]
|
||||||
split_name = True
|
split_name = True
|
||||||
except Exception:
|
except Exception:
|
||||||
split_name = False
|
split_name = False
|
||||||
|
@ -2644,6 +2595,7 @@ if form.getvalue('ssh_cert'):
|
||||||
key.write_private_key_file(ssh_keys)
|
key.write_private_key_file(ssh_keys)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('error: Cannot save SSH key file: ', str(e))
|
print('error: Cannot save SSH key file: ', str(e))
|
||||||
|
sys.exit()
|
||||||
else:
|
else:
|
||||||
print('success: SSH key has been saved into: %s ' % ssh_keys)
|
print('success: SSH key has been saved into: %s ' % ssh_keys)
|
||||||
|
|
||||||
|
@ -2666,8 +2618,6 @@ if form.getvalue('newtelegram'):
|
||||||
print(error_mess)
|
print(error_mess)
|
||||||
else:
|
else:
|
||||||
if sql.insert_new_telegram(token, channel, group):
|
if sql.insert_new_telegram(token, channel, group):
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
||||||
template = env.get_template('/new_telegram.html')
|
template = env.get_template('/new_telegram.html')
|
||||||
output_from_parsed_template = template.render(groups=sql.select_groups(),
|
output_from_parsed_template = template.render(groups=sql.select_groups(),
|
||||||
|
@ -2686,8 +2636,6 @@ if form.getvalue('newslack'):
|
||||||
print(error_mess)
|
print(error_mess)
|
||||||
else:
|
else:
|
||||||
if sql.insert_new_slack(token, channel, group):
|
if sql.insert_new_slack(token, channel, group):
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
||||||
template = env.get_template('/new_slack.html')
|
template = env.get_template('/new_slack.html')
|
||||||
output_from_parsed_template = template.render(groups=sql.select_groups(),
|
output_from_parsed_template = template.render(groups=sql.select_groups(),
|
||||||
|
@ -2751,7 +2699,6 @@ if form.getvalue('getuserservices'):
|
||||||
services = sql.select_services()
|
services = sql.select_services()
|
||||||
for g in u_g:
|
for g in u_g:
|
||||||
groups.append(g.user_group_id)
|
groups.append(g.user_group_id)
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
||||||
template = env.get_template('/show_user_services.html')
|
template = env.get_template('/show_user_services.html')
|
||||||
|
@ -2764,7 +2711,6 @@ if form.getvalue('getusergroups'):
|
||||||
u_g = sql.select_user_groups(user_id)
|
u_g = sql.select_user_groups(user_id)
|
||||||
for g in u_g:
|
for g in u_g:
|
||||||
groups.append(g.user_group_id)
|
groups.append(g.user_group_id)
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
||||||
template = env.get_template('/show_user_groups.html')
|
template = env.get_template('/show_user_groups.html')
|
||||||
|
@ -2801,16 +2747,11 @@ if form.getvalue('changeUserCurrentGroupId') is not None:
|
||||||
print('error: Cannot change group')
|
print('error: Cannot change group')
|
||||||
|
|
||||||
if form.getvalue('getcurrentusergroup') is not None:
|
if form.getvalue('getcurrentusergroup') is not None:
|
||||||
import http.cookies
|
|
||||||
|
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
user_id = cookie.get('uuid')
|
user_id = cookie.get('uuid')
|
||||||
group = cookie.get('group')
|
group = cookie.get('group')
|
||||||
group_id = sql.get_user_id_by_uuid(user_id.value)
|
group_id = sql.get_user_id_by_uuid(user_id.value)
|
||||||
groups = sql.select_user_groups_with_names(group_id)
|
groups = sql.select_user_groups_with_names(group_id)
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
||||||
template = env.get_template('/show_user_current_group.html')
|
template = env.get_template('/show_user_current_group.html')
|
||||||
template = template.render(groups=groups, group=group.value, id=group_id)
|
template = template.render(groups=groups, group=group.value, id=group_id)
|
||||||
|
@ -2846,7 +2787,6 @@ if form.getvalue('newsmon') is not None:
|
||||||
|
|
||||||
last_id = sql.insert_smon(server, port, enable, http, uri, body, group, desc, telegram, slack, user_group)
|
last_id = sql.insert_smon(server, port, enable, http, uri, body, group, desc, telegram, slack, user_group)
|
||||||
if last_id:
|
if last_id:
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
env = Environment(loader=FileSystemLoader('templates'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates'), autoescape=True)
|
||||||
template = env.get_template('ajax/show_new_smon.html')
|
template = env.get_template('ajax/show_new_smon.html')
|
||||||
template = template.render(
|
template = template.render(
|
||||||
|
@ -2868,9 +2808,6 @@ if form.getvalue('smondel') is not None:
|
||||||
if form.getvalue('showsmon') is not None:
|
if form.getvalue('showsmon') is not None:
|
||||||
user_group = funct.get_user_group(id=1)
|
user_group = funct.get_user_group(id=1)
|
||||||
sort = form.getvalue('sort')
|
sort = form.getvalue('sort')
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates'), autoescape=True)
|
||||||
template = env.get_template('ajax/smon_dashboard.html')
|
template = env.get_template('ajax/smon_dashboard.html')
|
||||||
template = template.render(smon=sql.smon_list(user_group), sort=sort)
|
template = template.render(smon=sql.smon_list(user_group), sort=sort)
|
||||||
|
@ -2916,17 +2853,14 @@ if form.getvalue('showBytes') is not None:
|
||||||
bit_in, stderr = funct.subprocess_execute(cmd)
|
bit_in, stderr = funct.subprocess_execute(cmd)
|
||||||
bin_bout.append(bit_in[0])
|
bin_bout.append(bit_in[0])
|
||||||
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)
|
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)
|
||||||
bout, stderr = funct.subprocess_execute(cmd)
|
bout, stderr1 = funct.subprocess_execute(cmd)
|
||||||
bin_bout.append(bout[0])
|
bin_bout.append(bout[0])
|
||||||
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)
|
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)
|
||||||
cin, stderr = funct.subprocess_execute(cmd)
|
cin, stderr2 = funct.subprocess_execute(cmd)
|
||||||
bin_bout.append(cin[0])
|
bin_bout.append(cin[0])
|
||||||
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)
|
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)
|
||||||
cout, stderr = funct.subprocess_execute(cmd)
|
cout, stderr3 = funct.subprocess_execute(cmd)
|
||||||
bin_bout.append(cout[0])
|
bin_bout.append(cout[0])
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates'), autoescape=True)
|
||||||
template = env.get_template('ajax/bin_bout.html')
|
template = env.get_template('ajax/bin_bout.html')
|
||||||
template = template.render(bin_bout=bin_bout, serv=serv)
|
template = template.render(bin_bout=bin_bout, serv=serv)
|
||||||
|
@ -2951,8 +2885,6 @@ if form.getvalue('nginxConnections'):
|
||||||
if num == 2:
|
if num == 2:
|
||||||
bin_bout.append(line.split(' ')[3])
|
bin_bout.append(line.split(' ')[3])
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates'))
|
env = Environment(loader=FileSystemLoader('templates'))
|
||||||
template = env.get_template('ajax/bin_bout.html')
|
template = env.get_template('ajax/bin_bout.html')
|
||||||
template = template.render(bin_bout=bin_bout, serv=serv, service='nginx')
|
template = template.render(bin_bout=bin_bout, serv=serv, service='nginx')
|
||||||
|
@ -3139,8 +3071,6 @@ if form.getvalue('scan_ports') is not None:
|
||||||
if stderr != '':
|
if stderr != '':
|
||||||
print(stderr)
|
print(stderr)
|
||||||
else:
|
else:
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates'), autoescape=True)
|
||||||
template = env.get_template('ajax/scan_ports.html')
|
template = env.get_template('ajax/scan_ports.html')
|
||||||
template = template.render(ports=stdout, info=stdout1)
|
template = template.render(ports=stdout, info=stdout1)
|
||||||
|
@ -3165,9 +3095,6 @@ if form.getvalue('viewFirewallRules') is not None:
|
||||||
|
|
||||||
IN_public_allow = funct.ssh_command(serv, cmd1, raw=1)
|
IN_public_allow = funct.ssh_command(serv, cmd1, raw=1)
|
||||||
output_chain = funct.ssh_command(serv, cmd2, raw=1)
|
output_chain = funct.ssh_command(serv, cmd2, raw=1)
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates'))
|
env = Environment(loader=FileSystemLoader('templates'))
|
||||||
template = env.get_template('ajax/firewall_rules.html')
|
template = env.get_template('ajax/firewall_rules.html')
|
||||||
template = template.render(input=input_chain2, IN_public_allow=IN_public_allow, output=output_chain)
|
template = template.render(input=input_chain2, IN_public_allow=IN_public_allow, output=output_chain)
|
||||||
|
@ -3352,8 +3279,6 @@ if form.getvalue('portscanner_history_server_id'):
|
||||||
print('ok')
|
print('ok')
|
||||||
|
|
||||||
if form.getvalue('show_versions'):
|
if form.getvalue('show_versions'):
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates'))
|
env = Environment(loader=FileSystemLoader('templates'))
|
||||||
template = env.get_template('ajax/check_version.html')
|
template = env.get_template('ajax/check_version.html')
|
||||||
template = template.render(versions=funct.versions())
|
template = template.render(versions=funct.versions())
|
||||||
|
@ -3392,10 +3317,6 @@ if any((form.getvalue('do_new_name'), form.getvalue('aws_new_name'), form.getval
|
||||||
is_add = True
|
is_add = True
|
||||||
|
|
||||||
if is_add:
|
if is_add:
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
import http.cookies
|
|
||||||
import os
|
|
||||||
|
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
user_uuid = cookie.get('uuid')
|
user_uuid = cookie.get('uuid')
|
||||||
role_id = sql.get_user_role_by_uuid(user_uuid.value)
|
role_id = sql.get_user_role_by_uuid(user_uuid.value)
|
||||||
|
@ -3570,9 +3491,6 @@ if form.getvalue('doworkspace'):
|
||||||
region, size, privet_net, floating_ip, ssh_ids, ssh_name, workspace, oss, firewall, monitoring,
|
region, size, privet_net, floating_ip, ssh_ids, ssh_name, workspace, oss, firewall, monitoring,
|
||||||
backup, provider, group, 'Creating'
|
backup, provider, group, 'Creating'
|
||||||
):
|
):
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
user, user_id, role, token, servers, user_services = funct.get_users_params()
|
user, user_id, role, token, servers, user_services = funct.get_users_params()
|
||||||
new_server = sql.select_provisioned_servers(new=workspace, group=group, type='do')
|
new_server = sql.select_provisioned_servers(new=workspace, group=group, type='do')
|
||||||
params = sql.select_provisioning_params()
|
params = sql.select_provisioning_params()
|
||||||
|
@ -3666,9 +3584,6 @@ if form.getvalue('awsworkspace'):
|
||||||
region, size, public_ip, floating_ip, volume_size, ssh_name, workspace, oss, firewall,
|
region, size, public_ip, floating_ip, volume_size, ssh_name, workspace, oss, firewall,
|
||||||
provider, group, 'Creating', delete_on_termination, volume_type
|
provider, group, 'Creating', delete_on_termination, volume_type
|
||||||
):
|
):
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
user, user_id, role, token, servers, user_services = funct.get_users_params()
|
user, user_id, role, token, servers, user_services = funct.get_users_params()
|
||||||
new_server = sql.select_provisioned_servers(new=workspace, group=group, type='aws')
|
new_server = sql.select_provisioned_servers(new=workspace, group=group, type='aws')
|
||||||
params = sql.select_provisioning_params()
|
params = sql.select_provisioning_params()
|
||||||
|
@ -3940,9 +3855,6 @@ if form.getvalue('gcoreworkspace'):
|
||||||
project, region, size, network_type, network_name, volume_size, ssh_name, workspace, oss, firewall,
|
project, region, size, network_type, network_name, volume_size, ssh_name, workspace, oss, firewall,
|
||||||
provider, group, 'Creating', delete_on_termination, volume_type
|
provider, group, 'Creating', delete_on_termination, volume_type
|
||||||
):
|
):
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
user, user_id, role, token, servers, user_services = funct.get_users_params()
|
user, user_id, role, token, servers, user_services = funct.get_users_params()
|
||||||
new_server = sql.select_provisioned_servers(new=workspace, group=group, type='gcore')
|
new_server = sql.select_provisioned_servers(new=workspace, group=group, type='gcore')
|
||||||
params = sql.select_provisioning_params()
|
params = sql.select_provisioning_params()
|
||||||
|
@ -4003,8 +3915,6 @@ if form.getvalue('editAwsServer'):
|
||||||
params = sql.select_provisioning_params()
|
params = sql.select_provisioning_params()
|
||||||
providers = sql.select_providers(int(user_group))
|
providers = sql.select_providers(int(user_group))
|
||||||
server = sql.select_gcore_server(server_id=server_id)
|
server = sql.select_gcore_server(server_id=server_id)
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(extensions=["jinja2.ext.do"], loader=FileSystemLoader('templates'))
|
env = Environment(extensions=["jinja2.ext.do"], loader=FileSystemLoader('templates'))
|
||||||
template = env.get_template('ajax/provisioning/aws_edit_dialog.html')
|
template = env.get_template('ajax/provisioning/aws_edit_dialog.html')
|
||||||
template = template.render(server=server, providers=providers, params=params)
|
template = template.render(server=server, providers=providers, params=params)
|
||||||
|
@ -4017,8 +3927,6 @@ if form.getvalue('editGcoreServer'):
|
||||||
params = sql.select_provisioning_params()
|
params = sql.select_provisioning_params()
|
||||||
providers = sql.select_providers(int(user_group))
|
providers = sql.select_providers(int(user_group))
|
||||||
server = sql.select_gcore_server(server_id=server_id)
|
server = sql.select_gcore_server(server_id=server_id)
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(extensions=["jinja2.ext.do"], loader=FileSystemLoader('templates'))
|
env = Environment(extensions=["jinja2.ext.do"], loader=FileSystemLoader('templates'))
|
||||||
template = env.get_template('ajax/provisioning/gcore_edit_dialog.html')
|
template = env.get_template('ajax/provisioning/gcore_edit_dialog.html')
|
||||||
template = template.render(server=server, providers=providers, params=params)
|
template = template.render(server=server, providers=providers, params=params)
|
||||||
|
@ -4031,8 +3939,6 @@ if form.getvalue('editDoServer'):
|
||||||
params = sql.select_provisioning_params()
|
params = sql.select_provisioning_params()
|
||||||
providers = sql.select_providers(int(user_group))
|
providers = sql.select_providers(int(user_group))
|
||||||
server = sql.select_do_server(server_id=server_id)
|
server = sql.select_do_server(server_id=server_id)
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(extensions=["jinja2.ext.do"], loader=FileSystemLoader('templates'))
|
env = Environment(extensions=["jinja2.ext.do"], loader=FileSystemLoader('templates'))
|
||||||
template = env.get_template('ajax/provisioning/do_edit_dialog.html')
|
template = env.get_template('ajax/provisioning/do_edit_dialog.html')
|
||||||
template = template.render(server=server, providers=providers, params=params)
|
template = template.render(server=server, providers=providers, params=params)
|
||||||
|
@ -4071,7 +3977,6 @@ if form.getvalue('edit_aws_provider'):
|
||||||
funct.logging('localhost', 'Provider has been renamed. New name is ' + new_name, provisioning=1)
|
funct.logging('localhost', 'Provider has been renamed. New name is ' + new_name, provisioning=1)
|
||||||
|
|
||||||
if form.getvalue('loadservices'):
|
if form.getvalue('loadservices'):
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
env = Environment(loader=FileSystemLoader('templates'))
|
env = Environment(loader=FileSystemLoader('templates'))
|
||||||
template = env.get_template('ajax/load_services.html')
|
template = env.get_template('ajax/load_services.html')
|
||||||
services = funct.get_services_status()
|
services = funct.get_services_status()
|
||||||
|
@ -4080,7 +3985,6 @@ if form.getvalue('loadservices'):
|
||||||
print(template)
|
print(template)
|
||||||
|
|
||||||
if form.getvalue('loadchecker'):
|
if form.getvalue('loadchecker'):
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
env = Environment(loader=FileSystemLoader('templates'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates'), autoescape=True)
|
||||||
template = env.get_template('ajax/load_telegram.html')
|
template = env.get_template('ajax/load_telegram.html')
|
||||||
services = funct.get_services_status()
|
services = funct.get_services_status()
|
||||||
|
@ -4134,7 +4038,6 @@ if form.getvalue('loadchecker'):
|
||||||
print(template)
|
print(template)
|
||||||
|
|
||||||
if form.getvalue('load_update_hapwi'):
|
if form.getvalue('load_update_hapwi'):
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
env = Environment(loader=FileSystemLoader('templates'))
|
env = Environment(loader=FileSystemLoader('templates'))
|
||||||
template = env.get_template('ajax/load_updatehapwi.html')
|
template = env.get_template('ajax/load_updatehapwi.html')
|
||||||
|
|
||||||
|
@ -4159,7 +4062,6 @@ if form.getvalue('load_update_hapwi'):
|
||||||
|
|
||||||
if form.getvalue('loadopenvpn'):
|
if form.getvalue('loadopenvpn'):
|
||||||
import distro
|
import distro
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
env = Environment(loader=FileSystemLoader('templates'))
|
env = Environment(loader=FileSystemLoader('templates'))
|
||||||
template = env.get_template('ajax/load_openvpn.html')
|
template = env.get_template('ajax/load_openvpn.html')
|
||||||
openvpn_configs = ''
|
openvpn_configs = ''
|
||||||
|
@ -4197,9 +4099,6 @@ if form.getvalue('check_slack'):
|
||||||
funct.slack_send_mess(mess, slack_channel_id=slack_id)
|
funct.slack_send_mess(mess, slack_channel_id=slack_id)
|
||||||
|
|
||||||
if form.getvalue('check_rabbitmq_alert'):
|
if form.getvalue('check_rabbitmq_alert'):
|
||||||
import json
|
|
||||||
import http.cookies
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
user_group_id = cookie.get('group')
|
user_group_id = cookie.get('group')
|
||||||
|
@ -4216,7 +4115,6 @@ if form.getvalue('check_rabbitmq_alert'):
|
||||||
print(f'error: Cannot send a message {error}')
|
print(f'error: Cannot send a message {error}')
|
||||||
|
|
||||||
if form.getvalue('check_email_alert'):
|
if form.getvalue('check_email_alert'):
|
||||||
import http.cookies
|
|
||||||
subject = 'test message'
|
subject = 'test message'
|
||||||
message = 'Test message from Roxy-WI'
|
message = 'Test message from Roxy-WI'
|
||||||
|
|
||||||
|
@ -4251,7 +4149,7 @@ if form.getvalue('getoption'):
|
||||||
for i in options:
|
for i in options:
|
||||||
a[v] = i.options
|
a[v] = i.options
|
||||||
v = v + 1
|
v = v + 1
|
||||||
import json
|
|
||||||
print(json.dumps(a))
|
print(json.dumps(a))
|
||||||
|
|
||||||
|
|
||||||
|
@ -4262,8 +4160,6 @@ if form.getvalue('newtoption'):
|
||||||
print(error_mess)
|
print(error_mess)
|
||||||
else:
|
else:
|
||||||
if sql.insert_new_option(option, group):
|
if sql.insert_new_option(option, group):
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
||||||
template = env.get_template('/new_option.html')
|
template = env.get_template('/new_option.html')
|
||||||
|
|
||||||
|
@ -4299,7 +4195,7 @@ if form.getvalue('getsavedserver'):
|
||||||
a[v]['value'] = i.server
|
a[v]['value'] = i.server
|
||||||
a[v]['desc'] = i.description
|
a[v]['desc'] = i.description
|
||||||
v = v + 1
|
v = v + 1
|
||||||
import json
|
|
||||||
print(json.dumps(a))
|
print(json.dumps(a))
|
||||||
|
|
||||||
|
|
||||||
|
@ -4311,8 +4207,6 @@ if form.getvalue('newsavedserver'):
|
||||||
print(error_mess)
|
print(error_mess)
|
||||||
else:
|
else:
|
||||||
if sql.insert_new_savedserver(savedserver, description, group):
|
if sql.insert_new_savedserver(savedserver, description, group):
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
||||||
template = env.get_template('/new_saved_servers.html')
|
template = env.get_template('/new_saved_servers.html')
|
||||||
|
|
||||||
|
@ -4335,8 +4229,6 @@ if form.getvalue('savedserverdel') is not None:
|
||||||
print("Ok")
|
print("Ok")
|
||||||
|
|
||||||
if form.getvalue('show_users_ovw') is not None:
|
if form.getvalue('show_users_ovw') is not None:
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
||||||
template = env.get_template('/show_users_ovw.html')
|
template = env.get_template('/show_users_ovw.html')
|
||||||
|
|
||||||
|
@ -4356,8 +4248,6 @@ if form.getvalue('show_users_ovw') is not None:
|
||||||
if form.getvalue('serverSettings') is not None:
|
if form.getvalue('serverSettings') is not None:
|
||||||
server_id = form.getvalue('serverSettings')
|
server_id = form.getvalue('serverSettings')
|
||||||
service = form.getvalue('serverSettingsService')
|
service = form.getvalue('serverSettingsService')
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
||||||
template = env.get_template('ajax/show_service_settings.html')
|
template = env.get_template('ajax/show_service_settings.html')
|
||||||
|
|
||||||
|
@ -4459,9 +4349,7 @@ if act == 'showListOfVersion':
|
||||||
if service == 'haproxy':
|
if service == 'haproxy':
|
||||||
files = funct.get_files()
|
files = funct.get_files()
|
||||||
else:
|
else:
|
||||||
files = funct.get_files(dir=configs_dir, format='conf')
|
files = funct.get_files(configs_dir, 'conf')
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True,
|
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True,
|
||||||
extensions=["jinja2.ext.loopcontrols", "jinja2.ext.do"])
|
extensions=["jinja2.ext.loopcontrols", "jinja2.ext.do"])
|
||||||
|
@ -4487,7 +4375,6 @@ if act == 'getSystemInfo':
|
||||||
print('error: IP or DNS name is not valid')
|
print('error: IP or DNS name is not valid')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True,
|
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True,
|
||||||
extensions=["jinja2.ext.loopcontrols", "jinja2.ext.do"])
|
extensions=["jinja2.ext.loopcontrols", "jinja2.ext.do"])
|
||||||
env.globals['string_to_dict'] = funct.string_to_dict
|
env.globals['string_to_dict'] = funct.string_to_dict
|
||||||
|
@ -4518,8 +4405,6 @@ if act == 'updateSystemInfo':
|
||||||
|
|
||||||
sql.delete_system_info(server_id)
|
sql.delete_system_info(server_id)
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True,
|
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True,
|
||||||
extensions=["jinja2.ext.loopcontrols", "jinja2.ext.do"])
|
extensions=["jinja2.ext.loopcontrols", "jinja2.ext.do"])
|
||||||
env.globals['string_to_dict'] = funct.string_to_dict
|
env.globals['string_to_dict'] = funct.string_to_dict
|
||||||
|
@ -4550,7 +4435,9 @@ if act == 'findInConfigs':
|
||||||
print(return_find)
|
print(return_find)
|
||||||
|
|
||||||
if act == 'check_service':
|
if act == 'check_service':
|
||||||
import http.cookies
|
import socket
|
||||||
|
from contextlib import closing
|
||||||
|
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
user_uuid = cookie.get('uuid')
|
user_uuid = cookie.get('uuid')
|
||||||
user_id = sql.get_user_id_by_uuid(user_uuid.value)
|
user_id = sql.get_user_id_by_uuid(user_uuid.value)
|
||||||
|
@ -4571,9 +4458,6 @@ if act == 'check_service':
|
||||||
print('down')
|
print('down')
|
||||||
if '2' in user_services:
|
if '2' in user_services:
|
||||||
if service == 'nginx':
|
if service == 'nginx':
|
||||||
import socket
|
|
||||||
from contextlib import closing
|
|
||||||
|
|
||||||
nginx_stats_port = sql.get_setting('nginx_stats_port')
|
nginx_stats_port = sql.get_setting('nginx_stats_port')
|
||||||
|
|
||||||
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
|
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
|
||||||
|
@ -4588,9 +4472,6 @@ if act == 'check_service':
|
||||||
print('down')
|
print('down')
|
||||||
if '4' in user_services:
|
if '4' in user_services:
|
||||||
if service == 'apache':
|
if service == 'apache':
|
||||||
import socket
|
|
||||||
from contextlib import closing
|
|
||||||
|
|
||||||
apache_stats_port = sql.get_setting('apache_stats_port')
|
apache_stats_port = sql.get_setting('apache_stats_port')
|
||||||
|
|
||||||
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
|
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
|
||||||
|
@ -4605,8 +4486,6 @@ if act == 'check_service':
|
||||||
print('down' + str(e))
|
print('down' + str(e))
|
||||||
|
|
||||||
if form.getvalue('show_sub_ovw'):
|
if form.getvalue('show_sub_ovw'):
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
||||||
template = env.get_template('ajax/show_sub_ovw.html')
|
template = env.get_template('ajax/show_sub_ovw.html')
|
||||||
template = template.render(sub=sql.select_user_all())
|
template = template.render(sub=sql.select_user_all())
|
||||||
|
|
107
app/overview.py
107
app/overview.py
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import os
|
import os
|
||||||
|
import psutil
|
||||||
|
|
||||||
import funct
|
import funct
|
||||||
import sql
|
import sql
|
||||||
|
@ -13,57 +14,50 @@ print('Content-type: text/html\n')
|
||||||
|
|
||||||
funct.check_login()
|
funct.check_login()
|
||||||
|
|
||||||
|
grafana = 0
|
||||||
|
metrics_worker = 0
|
||||||
|
checker_worker = 0
|
||||||
|
is_checker_worker = 0
|
||||||
|
is_metrics_worker = 0
|
||||||
|
servers_group = []
|
||||||
|
host = os.environ.get('HTTP_HOST', '')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
user, user_id, role, token, servers, user_services = funct.get_users_params()
|
user, user_id, role, token, servers, user_services = funct.get_users_params()
|
||||||
groups = sql.select_groups()
|
groups = sql.select_groups()
|
||||||
user_group = funct.get_user_group(id=1)
|
user_group = funct.get_user_group(id=1)
|
||||||
|
|
||||||
if (role == 2 or role == 3) and int(user_group) != 1:
|
if (role == 2 or role == 3) and int(user_group) != 1:
|
||||||
servers_for_grep = ''
|
|
||||||
i = 1
|
|
||||||
servers_len = len(servers)
|
|
||||||
|
|
||||||
for s in servers:
|
for s in servers:
|
||||||
if i != servers_len:
|
servers_group.append(s[2])
|
||||||
servers_for_grep += s[2] + '\|'
|
|
||||||
else:
|
|
||||||
servers_for_grep += s[2]
|
|
||||||
|
|
||||||
i += 1
|
is_checker_worker = len(sql.select_all_alerts(group=user_group))
|
||||||
|
is_metrics_worker = len(sql.select_servers_metrics_for_master(group=user_group))
|
||||||
|
|
||||||
cmd = "ps ax |grep '[m]etrics_worker\|[m]etrics_waf_worker.py\|[m]etrics_nginx_worker.py'|grep '%s' |wc -l" % servers_for_grep
|
for pids in psutil.pids():
|
||||||
metrics_worker, stderr = funct.subprocess_execute(cmd)
|
if pids < 300:
|
||||||
cmd = "ps ax |grep '[c]hecker_worker\|[c]hecker_nginx\|[c]hecker_apache\|[c]hecker_keepalived'|grep -v grep |grep '%s' |wc -l" % servers_for_grep
|
continue
|
||||||
checker_worker, stderr = funct.subprocess_execute(cmd)
|
try:
|
||||||
i = 0
|
pid = psutil.Process(pids)
|
||||||
for s in sql.select_all_alerts(group=user_group):
|
cmdline_out = pid.cmdline()
|
||||||
i += 1
|
if len(cmdline_out) > 2:
|
||||||
is_checker_worker = i
|
if 'checker_' in cmdline_out[1]:
|
||||||
is_metrics_workers = sql.select_servers_metrics_for_master(group=user_group)
|
if len(servers_group) > 0:
|
||||||
i = 0
|
if cmdline_out[2] in servers_group:
|
||||||
for s in is_metrics_workers:
|
checker_worker += 1
|
||||||
i += 1
|
else:
|
||||||
is_metrics_worker = i
|
checker_worker += 1
|
||||||
grafana = ''
|
elif 'metrics_' in cmdline_out[1]:
|
||||||
prometheus = ''
|
if len(servers_group) > 0:
|
||||||
host = ''
|
if cmdline_out[2] in servers_group:
|
||||||
else:
|
metrics_worker += 1
|
||||||
cmd = "ps ax |grep '[m]etrics_worker\|[m]etrics_waf_worker.py\|[m]etrics_nginx_worker.py' |wc -l"
|
else:
|
||||||
metrics_worker, stderr = funct.subprocess_execute(cmd)
|
metrics_worker += 1
|
||||||
cmd = "ps ax |grep '[c]hecker_worker\|[c]hecker_nginx\|[c]hecker_apache\|[c]hecker_keepalived' |wc -l"
|
if len(servers_group) == 0:
|
||||||
checker_worker, stderr = funct.subprocess_execute(cmd)
|
if 'grafana' in cmdline_out[1]:
|
||||||
i = 0
|
grafana += 1
|
||||||
for s in sql.select_all_alerts():
|
except psutil.NoSuchProcess:
|
||||||
i += 1
|
pass
|
||||||
is_checker_worker = i
|
|
||||||
is_metrics_workers = sql.select_servers_metrics_for_master()
|
|
||||||
i = 0
|
|
||||||
for s in is_metrics_workers:
|
|
||||||
i += 1
|
|
||||||
is_metrics_worker = i
|
|
||||||
cmd = "ps ax |egrep [g]rafana|wc -l"
|
|
||||||
grafana, stderr = funct.subprocess_execute(cmd)
|
|
||||||
host = os.environ.get('HTTP_HOST', '')
|
|
||||||
|
|
||||||
cmd = "systemctl is-active roxy-wi-metrics"
|
cmd = "systemctl is-active roxy-wi-metrics"
|
||||||
metrics_master, stderr = funct.subprocess_execute(cmd)
|
metrics_master, stderr = funct.subprocess_execute(cmd)
|
||||||
|
@ -78,41 +72,32 @@ try:
|
||||||
cmd = "systemctl is-active roxy-wi-socket"
|
cmd = "systemctl is-active roxy-wi-socket"
|
||||||
socket, stderr = funct.subprocess_execute(cmd)
|
socket, stderr = funct.subprocess_execute(cmd)
|
||||||
|
|
||||||
except Exception:
|
except Exception as e:
|
||||||
role = ''
|
role = ''
|
||||||
user = ''
|
user = ''
|
||||||
users = ''
|
|
||||||
groups = ''
|
groups = ''
|
||||||
roles = ''
|
roles = ''
|
||||||
metrics_master = ''
|
metrics_master = ''
|
||||||
metrics_worker = ''
|
|
||||||
checker_master = ''
|
checker_master = ''
|
||||||
checker_worker = ''
|
|
||||||
keep_alive = ''
|
keep_alive = ''
|
||||||
smon = ''
|
smon = ''
|
||||||
grafana = ''
|
|
||||||
socket = ''
|
socket = ''
|
||||||
versions = ''
|
|
||||||
haproxy_wi_log = ''
|
|
||||||
servers = ''
|
servers = ''
|
||||||
stderr = ''
|
stderr = ''
|
||||||
is_checker_worker = ''
|
|
||||||
is_metrics_worker = ''
|
|
||||||
token = ''
|
token = ''
|
||||||
|
print(str(e))
|
||||||
|
|
||||||
rendered_template = template.render(
|
rendered_template = template.render(
|
||||||
h2=1, autorefresh=1, title="Overview", role=role, user=user, groups=groups, roles=sql.select_roles(),
|
h2=1, autorefresh=1, title="Overview", role=role, user=user, groups=groups, roles=sql.select_roles(),
|
||||||
metrics_master=''.join(metrics_master), metrics_worker=''.join(metrics_worker), checker_master=''.join(checker_master),
|
metrics_master=''.join(metrics_master), metrics_worker=metrics_worker, checker_master=''.join(checker_master),
|
||||||
checker_worker=''.join(checker_worker), keep_alive=''.join(keep_alive), smon=''.join(smon),
|
checker_worker=checker_worker, keep_alive=''.join(keep_alive), smon=''.join(smon),
|
||||||
port_scanner=''.join(port_scanner), grafana=''.join(grafana), socket=''.join(socket),
|
port_scanner=''.join(port_scanner), grafana=grafana, socket=''.join(socket),
|
||||||
roxy_wi_log_id=funct.roxy_wi_log(log_id=1, file="roxy-wi-", with_date=1),
|
roxy_wi_log_id=funct.roxy_wi_log(log_id=1, file="roxy-wi-"),
|
||||||
metrics_log_id=funct.roxy_wi_log(log_id=1, file="metrics", with_date=1),
|
metrics_log_id=funct.roxy_wi_log(log_id=1, file="metrics"),
|
||||||
checker_log_id=funct.roxy_wi_log(log_id=1, file="checker", with_date=1),
|
checker_log_id=funct.roxy_wi_log(log_id=1, file="checker"),
|
||||||
keep_alive_log_id=funct.roxy_wi_log(log_id=1, file="keep_alive"),
|
keep_alive_log_id=funct.roxy_wi_log(log_id=1, file="keep_alive"),
|
||||||
socket_log_id=funct.roxy_wi_log(log_id=1, file="socket"),
|
socket_log_id=funct.roxy_wi_log(log_id=1, file="socket"), error=stderr,
|
||||||
metrics_error_log_id=funct.roxy_wi_log(log_id=1, file="metrics-error"), error=stderr,
|
roxy_wi_log=funct.roxy_wi_log(), servers=servers, is_checker_worker=is_checker_worker,
|
||||||
haproxy_wi_log=funct.roxy_wi_log(), servers=servers, is_checker_worker=is_checker_worker,
|
|
||||||
is_metrics_worker=is_metrics_worker, host=host, user_services=user_services, token=token
|
is_metrics_worker=is_metrics_worker, host=host, user_services=user_services, token=token
|
||||||
)
|
)
|
||||||
print(rendered_template)
|
print(rendered_template)
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
---
|
---
|
||||||
- name: restart keepalived
|
|
||||||
service: name=keepalived state=restarted
|
|
||||||
|
|
||||||
- name: restart rsyslog
|
- name: restart rsyslog
|
||||||
service: name=restart state=restarted
|
service: name=restart state=restarted
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
global_defs {
|
global_defs {
|
||||||
router_id LVS_DEVEL
|
router_id LVS_DEVEL
|
||||||
}
|
}
|
||||||
|
{%- if NGINX == '1' %}
|
||||||
|
{% set check_service = 'nginx' %}
|
||||||
|
{% else %}
|
||||||
|
{% set check_service = 'haproxy' %}
|
||||||
|
{% endif %}
|
||||||
#health-check for keepalive
|
#health-check for keepalive
|
||||||
vrrp_script chk_haproxy {
|
vrrp_script chk_service {
|
||||||
script "systemctl is-active --quiet haproxy"
|
script "systemctl is-active --quiet {{ check_service }}"
|
||||||
interval 2
|
interval 2
|
||||||
weight 3
|
weight 3
|
||||||
}
|
}
|
||||||
|
@ -16,7 +21,7 @@ vrrp_instance VI_1 {
|
||||||
|
|
||||||
#check if we are still running
|
#check if we are still running
|
||||||
track_script {
|
track_script {
|
||||||
chk_haproxy
|
chk_service
|
||||||
}
|
}
|
||||||
|
|
||||||
advert_int 1
|
advert_int 1
|
||||||
|
|
|
@ -21,6 +21,8 @@ do
|
||||||
RETURN_TO_MASTER) RETURN_TO_MASTER=${VALUE} ;;
|
RETURN_TO_MASTER) RETURN_TO_MASTER=${VALUE} ;;
|
||||||
ADD_VRRP) ADD_VRRP=${VALUE} ;;
|
ADD_VRRP) ADD_VRRP=${VALUE} ;;
|
||||||
SSH_PORT) SSH_PORT=${VALUE} ;;
|
SSH_PORT) SSH_PORT=${VALUE} ;;
|
||||||
|
HAPROXY) HAPROXY=${VALUE} ;;
|
||||||
|
NGINX) NGINX=${VALUE} ;;
|
||||||
*)
|
*)
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@ -36,9 +38,9 @@ PWD=$PWD/scripts/ansible/
|
||||||
echo "$HOST ansible_port=$SSH_PORT" > $PWD/$HOST
|
echo "$HOST ansible_port=$SSH_PORT" > $PWD/$HOST
|
||||||
|
|
||||||
if [[ $KEY == "" ]]; then
|
if [[ $KEY == "" ]]; then
|
||||||
ansible-playbook $PWD/roles/keepalived.yml -e "ansible_user=$USER ansible_ssh_pass='$PASS' variable_host=$HOST SYN_FLOOD=$SYN_FLOOD PROXY=$PROXY MASTER=$MASTER ETH=$ETH ETH_SLAVE=$ETH_SLAVE keepalived_path_logs=$keepalived_path_logs IP=$IP RESTART=$RESTART RETURN_TO_MASTER=$RETURN_TO_MASTER ADD_VRRP=$ADD_VRRP router_id=$router_id SSH_PORT=$SSH_PORT" -i $PWD/$HOST
|
ansible-playbook $PWD/roles/keepalived.yml -e "ansible_user=$USER ansible_ssh_pass='$PASS' variable_host=$HOST SYN_FLOOD=$SYN_FLOOD PROXY=$PROXY MASTER=$MASTER ETH=$ETH ETH_SLAVE=$ETH_SLAVE keepalived_path_logs=$keepalived_path_logs IP=$IP RESTART=$RESTART RETURN_TO_MASTER=$RETURN_TO_MASTER ADD_VRRP=$ADD_VRRP router_id=$router_id HAPROXY=$HAPROXY NGINX=$NGINX SSH_PORT=$SSH_PORT" -i $PWD/$HOST
|
||||||
else
|
else
|
||||||
ansible-playbook $PWD/roles/keepalived.yml --key-file $KEY -e "ansible_user=$USER variable_host=$HOST SYN_FLOOD=$SYN_FLOOD PROXY=$PROXY MASTER=$MASTER ETH=$ETH ETH_SLAVE=$ETH_SLAVE keepalived_path_logs=$keepalived_path_logs IP=$IP RESTART=$RESTART RETURN_TO_MASTER=$RETURN_TO_MASTER ADD_VRRP=$ADD_VRRP router_id=$router_id SSH_PORT=$SSH_PORT" -i $PWD/$HOST
|
ansible-playbook $PWD/roles/keepalived.yml --key-file $KEY -e "ansible_user=$USER variable_host=$HOST SYN_FLOOD=$SYN_FLOOD PROXY=$PROXY MASTER=$MASTER ETH=$ETH ETH_SLAVE=$ETH_SLAVE keepalived_path_logs=$keepalived_path_logs IP=$IP RESTART=$RESTART RETURN_TO_MASTER=$RETURN_TO_MASTER ADD_VRRP=$ADD_VRRP router_id=$router_id HAPROXY=$HAPROXY NGINX=$NGINX SSH_PORT=$SSH_PORT" -i $PWD/$HOST
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $? -gt 0 ]
|
if [ $? -gt 0 ]
|
||||||
|
|
26
app/sql.py
26
app/sql.py
|
@ -1554,7 +1554,7 @@ def insert_new_waf_rule(rule_name: str, rule_file: str, rule_description: str, s
|
||||||
out_error(e)
|
out_error(e)
|
||||||
else:
|
else:
|
||||||
return last_id
|
return last_id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def delete_waf_server(server_id):
|
def delete_waf_server(server_id):
|
||||||
|
@ -3765,3 +3765,27 @@ def select_service(slug: str) -> str:
|
||||||
return 'there is no service'
|
return 'there is no service'
|
||||||
else:
|
else:
|
||||||
return query_res
|
return query_res
|
||||||
|
|
||||||
|
|
||||||
|
def select_checker_service_status(server_id: int, service_id: int, service_check: str) -> int:
|
||||||
|
try:
|
||||||
|
service_check_status = ServiceStatus.get(
|
||||||
|
(ServiceStatus.server_id == server_id)
|
||||||
|
& (ServiceStatus.service_id == service_id)
|
||||||
|
& (ServiceStatus.service_check == service_check)
|
||||||
|
).status
|
||||||
|
except Exception as e:
|
||||||
|
return out_error(e)
|
||||||
|
else:
|
||||||
|
return service_check_status
|
||||||
|
|
||||||
|
|
||||||
|
def inset_or_update_service_status(
|
||||||
|
server_id: int, service_id: int, service_check: str, status: int
|
||||||
|
) -> None:
|
||||||
|
try:
|
||||||
|
ServiceStatus.insert(
|
||||||
|
server_id=server_id, service_id=service_id, service_check=service_check, status=status
|
||||||
|
).on_conflict('replace').execute()
|
||||||
|
except Exception as e:
|
||||||
|
out_error(e)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<p class="accordion-expand-holder">
|
<p class="accordion-expand-holder">
|
||||||
{% if role <= 3 %}
|
{% if role <= 3 %}
|
||||||
{% if not is_serv_protected or role <= 2 %}
|
{% if not is_serv_protected or role <= 2 %}
|
||||||
<a class="ui-button ui-widget ui-corner-all" title="Edit this run config" href="config.py?service={{service}}&serv={{serv}}&open=open&config_file_name={{config_file_name}}">Edit</a>
|
<a class="ui-button ui-widget ui-corner-all" title="Edit this run config" id="edit_link" href="config.py?service={{service}}&serv={{serv}}&open=open&config_file_name={{config_file_name}}">Edit</a>
|
||||||
{% if service == 'haproxy' %}
|
{% if service == 'haproxy' %}
|
||||||
<a class="ui-button ui-widget ui-corner-all" title="Add proxy" href="add.py#proxy">Add</a>
|
<a class="ui-button ui-widget ui-corner-all" title="Add proxy" href="add.py#proxy">Add</a>
|
||||||
{% elif service == 'keepalived' %}
|
{% elif service == 'keepalived' %}
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a class="accordion-expand-all ui-button ui-widget ui-corner-all" href="#">Expand all</a>
|
<a class="accordion-expand-all ui-button ui-widget ui-corner-all" id="expand_link" href="#">Expand all</a>
|
||||||
<button id="raw">Raw</button>
|
<button id="raw">Raw</button>
|
||||||
<button id="according" style="display: none;">According</button>
|
<button id="according" style="display: none;">According</button>
|
||||||
</p>
|
</p>
|
||||||
|
@ -382,4 +382,26 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="alert alert-info"><b>Note:</b> If you reconfigure Master server, Slave will be reconfigured automatically</div>
|
<div class="alert alert-info"><b>Note:</b> If you reconfigure Master server, Slave will be reconfigured automatically</div>
|
||||||
</center>
|
</center>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<script>
|
||||||
|
{% if role <= 3 %}
|
||||||
|
{% if not is_serv_protected or role <= 2 %}
|
||||||
|
$(document).bind('keydown', 'e', function (){
|
||||||
|
window.location = document.getElementById('edit_link').href;
|
||||||
|
});
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
$(document).on('keydown', null, 'r', raw_button);
|
||||||
|
function raw_button(event) {
|
||||||
|
$("#raw").trigger("click");
|
||||||
|
}
|
||||||
|
$(document).on('keydown', null, 'a', according_button);
|
||||||
|
function according_button(event) {
|
||||||
|
$("#according").click();
|
||||||
|
}
|
||||||
|
$(document).on('keydown', null, 'x', expand_button);
|
||||||
|
function expand_button(event) {
|
||||||
|
$("#expand_link").click();
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<table style="min-width: 40%;" id="body_table_metrics">
|
<table style="min-width: 40%;" id="body_table_metrics">
|
||||||
|
{% if service == 'haproxy' %}
|
||||||
<tr>
|
<tr>
|
||||||
<th class="padding10 first-collumn overviewTr" rowspan=2>Server</th>
|
<th class="padding10 first-collumn overviewTr" rowspan=2>Server</th>
|
||||||
<th colspan=3>Average sessions</th>
|
<th colspan=3>Average sessions</th>
|
||||||
|
@ -37,4 +38,30 @@
|
||||||
<td>{{ state.13 }}</td>
|
<td>{{ state.13 }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
<tr>
|
||||||
|
<th class="padding10 first-collumn overviewTr" rowspan=2>Server</th>
|
||||||
|
<th colspan=3>Average connections</th>
|
||||||
|
<th colspan=3>Peak connections</th>
|
||||||
|
</tr>
|
||||||
|
<tr class="overviewHead">
|
||||||
|
<th>1 hour</th>
|
||||||
|
<th>24 hours</th>
|
||||||
|
<th>3 days</th>
|
||||||
|
<th>1 hour</th>
|
||||||
|
<th>24 hours</th>
|
||||||
|
<th>3 days</th>
|
||||||
|
</tr>
|
||||||
|
{% for state in table_stat %}
|
||||||
|
<tr class="{{ loop.cycle('odd', 'even') }}">
|
||||||
|
<td class="padding10 first-collumn"><span title="{{ state.0 }}">{{ state.1 }}</span></td>
|
||||||
|
<td>{{ state.2 }}</td>
|
||||||
|
<td>{{ state.3 }}</td>
|
||||||
|
<td>{{ state.4 }}</td>
|
||||||
|
<td>{{ state.5 }}</td>
|
||||||
|
<td>{{ state.6 }}</td>
|
||||||
|
<td>{{ state.7 }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
</table>
|
</table>
|
|
@ -1,6 +1,6 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>{{title}} - Roxy-WI</title>
|
<title>{{title}}</title>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||||
<meta http-equiv="Pragma" content="no-cache" />
|
<meta http-equiv="Pragma" content="no-cache" />
|
||||||
|
@ -49,6 +49,7 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<input type="hidden" id="token" value="{{ token }}">
|
<input type="hidden" id="token" value="{{ token }}">
|
||||||
|
<script>show_version();</script>
|
||||||
<div class="top-menu">
|
<div class="top-menu">
|
||||||
<div class="LogoText">
|
<div class="LogoText">
|
||||||
<span id="logo_text">
|
<span id="logo_text">
|
||||||
|
@ -70,13 +71,13 @@
|
||||||
<li><a href="/app/config.py?service=haproxy" title="Working with HAProxy configs" class="edit head-submenu">Configs</a></li>
|
<li><a href="/app/config.py?service=haproxy" title="Working with HAProxy configs" class="edit head-submenu">Configs</a></li>
|
||||||
<li><a href="/app/statsview.py?service=haproxy" title="HAProxy statistics " class="stats head-submenu">Stats</a></li>
|
<li><a href="/app/statsview.py?service=haproxy" title="HAProxy statistics " class="stats head-submenu">Stats</a></li>
|
||||||
<li><a href="/app/logs.py?service=haproxy" title="HAProxy logs " class="logs head-submenu">Logs</a></li>
|
<li><a href="/app/logs.py?service=haproxy" title="HAProxy logs " class="logs head-submenu">Logs</a></li>
|
||||||
<li><a href="/app/runtimeapi.py" title="Runtime API - Roxy-WI" class="runtime head-submenu">Runtime API</a></li>
|
<li><a href="/app/runtimeapi.py" title="Runtime API" class="runtime head-submenu">Runtime API</a></li>
|
||||||
<li><a href="/app/metrics.py?service=haproxy" title="HAProxy's metrics" class="metrics head-submenu">Metrics</a></li>
|
<li><a href="/app/metrics.py?service=haproxy" title="HAProxy's metrics" class="metrics head-submenu">Metrics</a></li>
|
||||||
{% if role <= 3 %}
|
{% if role <= 3 %}
|
||||||
<li><a href="/app/add.py#proxy" title="Add proxy: Create proxy - Roxy-WI" class="add-proxy head-submenu" id="add1">Add proxy</a></li>
|
<li><a href="/app/add.py#proxy" title="Add proxy: Create proxy" class="add-proxy head-submenu" id="add1">Add proxy</a></li>
|
||||||
<li><a href="/app/versions.py?service=haproxy" title="Working with versions HAProxy configs" class="version head-submenu">Versions</a></li>
|
<li><a href="/app/versions.py?service=haproxy" title="Working with versions HAProxy configs" class="version head-submenu">Versions</a></li>
|
||||||
<li><a href="/app/add.py#ssl" title="Add proxy: Upload SSL certificates - Roxy-WI" class="cert head-submenu" id="add3">SSL</a></li>
|
<li><a href="/app/add.py#ssl" title="Add proxy: Upload SSL certificates" class="cert head-submenu" id="add3">SSL</a></li>
|
||||||
<li><a href="/app/add.py#lists" title="Add proxy: Create and upload whitelists or blacklists - Roxy-WI" class="lists head-submenu" id="add7">Lists</a></li>
|
<li><a href="/app/add.py#lists" title="Add proxy: Create and upload whitelists or blacklists" class="lists head-submenu" id="add7">Lists</a></li>
|
||||||
<li><a href="/app/waf.py?service=haproxy" title="Web application firewall" class="waf-menu head-submenu">WAF</a> </li>
|
<li><a href="/app/waf.py?service=haproxy" title="Web application firewall" class="waf-menu head-submenu">WAF</a> </li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -93,7 +94,7 @@
|
||||||
<li><a href="/app/metrics.py?service=nginx" title="NGINX's metrics" class="metrics head-submenu">Metrics</a></li>
|
<li><a href="/app/metrics.py?service=nginx" title="NGINX's metrics" class="metrics head-submenu">Metrics</a></li>
|
||||||
{% if role <= 3 %}
|
{% if role <= 3 %}
|
||||||
<li><a href="/app/versions.py?service=nginx" title="Working with versions NGINX configs" class="version head-submenu">Versions</a></li>
|
<li><a href="/app/versions.py?service=nginx" title="Working with versions NGINX configs" class="version head-submenu">Versions</a></li>
|
||||||
<li><a href="/app/add.py?service=nginx#ssl" title="Add proxy: Upload SSL certificates - Roxy-WI" class="cert head-submenu" id="add3">SSL</a></li>
|
<li><a href="/app/add.py?service=nginx#ssl" title="Add proxy: Upload SSL certificates" class="cert head-submenu" id="add3">SSL</a></li>
|
||||||
<li><a href="/app/waf.py?service=nginx" title="Web application firewall" class="waf-menu head-submenu">WAF</a> </li>
|
<li><a href="/app/waf.py?service=nginx" title="Web application firewall" class="waf-menu head-submenu">WAF</a> </li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -110,7 +111,7 @@
|
||||||
<li><a href="/app/metrics.py?service=apache" title="Apache's metrics" class="metrics head-submenu">Metrics</a></li>
|
<li><a href="/app/metrics.py?service=apache" title="Apache's metrics" class="metrics head-submenu">Metrics</a></li>
|
||||||
{% if role <= 3 %}
|
{% if role <= 3 %}
|
||||||
<li><a href="/app/versions.py?service=apache" title="Working with versions Apache configs" class="version head-submenu">Versions</a></li>
|
<li><a href="/app/versions.py?service=apache" title="Working with versions Apache configs" class="version head-submenu">Versions</a></li>
|
||||||
<li><a href="/app/add.py?service=apache#ssl" title="Add proxy: Upload SSL certificates - Roxy-WI" class="cert head-submenu" id="add3">SSL</a></li>
|
<li><a href="/app/add.py?service=apache#ssl" title="Add proxy: Upload SSL certificates" class="cert head-submenu" id="add3">SSL</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
@ -121,7 +122,7 @@
|
||||||
<a href="/app/hapservers.py?service=keepalived" title="Overview Keepalived servers" class="ha">Keepalived</a>
|
<a href="/app/hapservers.py?service=keepalived" title="Overview Keepalived servers" class="ha">Keepalived</a>
|
||||||
<ul class="v_menu">
|
<ul class="v_menu">
|
||||||
<li><a href="/app/hapservers.py?service=keepalived" title="Overview Keepalived servers" class="overview-link head-submenu">Overview</a> </li>
|
<li><a href="/app/hapservers.py?service=keepalived" title="Overview Keepalived servers" class="overview-link head-submenu">Overview</a> </li>
|
||||||
<li><a href="/app/ha.py" title="Create and configure HA cluster - Roxy-WI" class="keepalived head-submenu">HA</a></li>
|
<li><a href="/app/ha.py" title="Create and configure HA cluster" class="keepalived head-submenu">HA</a></li>
|
||||||
<li><a href="/app/config.py?service=keepalived" title="Working with Keepalived configs" class="edit head-submenu">Configs</a></li>
|
<li><a href="/app/config.py?service=keepalived" title="Working with Keepalived configs" class="edit head-submenu">Configs</a></li>
|
||||||
<li><a href="/app/logs.py?service=keepalived" title="Keepalived logs " class="logs head-submenu">Logs</a></li>
|
<li><a href="/app/logs.py?service=keepalived" title="Keepalived logs " class="logs head-submenu">Logs</a></li>
|
||||||
<li><a href="/app/versions.py?service=keepalived" title="Working with versions Keepalived configs" class="version head-submenu keepalived_versions">Versions</a></li>
|
<li><a href="/app/versions.py?service=keepalived" title="Working with versions Keepalived configs" class="version head-submenu keepalived_versions">Versions</a></li>
|
||||||
|
@ -146,16 +147,16 @@
|
||||||
<li class="p_menu">
|
<li class="p_menu">
|
||||||
<a title="Servers manage" class="runtime">Servers</a>
|
<a title="Servers manage" class="runtime">Servers</a>
|
||||||
<ul class="v_menu">
|
<ul class="v_menu">
|
||||||
<li><a href="/app/servers.py#users" title="Servers: Manage users - Roxy-WI" class="users head-submenu">Users</a></li>
|
<li><a href="/app/servers.py#users" title="Servers: Manage users" class="users head-submenu">Users</a></li>
|
||||||
<li><a href="/app/servers.py#servers" title="Servers: Manage servers - Roxy-WI" class="runtime servers head-submenu">Servers</a></li>
|
<li><a href="/app/servers.py#servers" title="Servers: Manage servers" class="runtime servers head-submenu">Servers</a></li>
|
||||||
<li><a href="/app/servers.py#ssh" title="Servers: Manage SSH credentials - Roxy-WI" class="admin ssh head-submenu">SSH credentials</a></li>
|
<li><a href="/app/servers.py#ssh" title="Servers: Manage SSH credentials" class="admin ssh head-submenu">SSH credentials</a></li>
|
||||||
<li><a href="/app/servers.py#checker" title="Servers: Manage Checker - Roxy-WI" class="checker head-submenu">Checker</a></li>
|
<li><a href="/app/servers.py#checker" title="Servers: Manage Checker" class="checker head-submenu">Checker</a></li>
|
||||||
<li><a href="/app/servers.py#settings" title="Servers: Manage Roxy-WI settings - Roxy-WI" class="settings head-submenu">Settings</a></li>
|
<li><a href="/app/servers.py#settings" title="Servers: Manage Roxy-WI settings" class="settings head-submenu">Settings</a></li>
|
||||||
<li><a href="/app/servers.py#installproxy" title="Servers: Proxy service installation - Roxy-WI" class="hap-menu installproxy head-submenu">Proxy installation</a> </li>
|
<li><a href="/app/servers.py#installproxy" title="Servers: Proxy service installation" class="hap-menu installproxy head-submenu">Proxy installation</a> </li>
|
||||||
<li><a href="/app/servers.py#installmon" title="Servers: Monitoring service installation - Roxy-WI" class="hap1 installmon head-submenu">Monitoring installation</a> </li>
|
<li><a href="/app/servers.py#installmon" title="Servers: Monitoring service installation" class="hap1 installmon head-submenu">Monitoring installation</a> </li>
|
||||||
<li><a href="/app/provisioning.py" title="Servers: Provisioning - Roxy-WI" class="hap1 head-submenu">Server provisioning</a> </li>
|
<li><a href="/app/provisioning.py" title="Servers: Provisioning" class="hap1 head-submenu">Server provisioning</a> </li>
|
||||||
<li><a href="/app/viewlogs.py?type=2" title="Servers: View internal logs - Roxy-WI" class="logs head-submenu">Internal logs</a></li>
|
<li><a href="/app/viewlogs.py?type=2" title="Servers: View internal logs" class="logs head-submenu">Internal logs</a></li>
|
||||||
<li><a href="/app/servers.py#backup" title="Servers: Backup configs - Roxy-WI" class="backup head-submenu">Backups</a> </li>
|
<li><a href="/app/servers.py#backup" title="Servers: Backup configs" class="backup head-submenu">Backups</a> </li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -163,15 +164,15 @@
|
||||||
<li class="p_menu">
|
<li class="p_menu">
|
||||||
<a title="Admin area" class="admin">Admin area</a>
|
<a title="Admin area" class="admin">Admin area</a>
|
||||||
<ul class="v_menu">
|
<ul class="v_menu">
|
||||||
<li><a href="/app/users.py#users" title="Admin area: Manage users - Roxy-WI" class="users head-submenu">Users</a></li>
|
<li><a href="/app/users.py#users" title="Admin area: Manage users" class="users head-submenu">Users</a></li>
|
||||||
<li><a href="/app/users.py#groups" title="Admin area: Manage groups - Roxy-WI" class="group groups head-submenu">Groups</a></li>
|
<li><a href="/app/users.py#groups" title="Admin area: Manage groups" class="group groups head-submenu">Groups</a></li>
|
||||||
<li><a href="/app/users.py#servers" title="Admin area: Manage servers - Roxy-WI" class="runtime servers head-submenu">Servers</a></li>
|
<li><a href="/app/users.py#servers" title="Admin area: Manage servers" class="runtime servers head-submenu">Servers</a></li>
|
||||||
<li><a href="/app/users.py#ssh" title="Admin area: Manage SSH credentials - Roxy-WI" class="admin ssh head-submenu">SSH credentials</a></li>
|
<li><a href="/app/users.py#ssh" title="Admin area: Manage SSH credentials" class="admin ssh head-submenu">SSH credentials</a></li>
|
||||||
<li><a href="/app/users.py#checker" title="Admin area: Checker - Roxy-WI" class="checker head-submenu">Checker</a></li>
|
<li><a href="/app/users.py#checker" title="Admin area: Checker" class="checker head-submenu">Checker</a></li>
|
||||||
<li><a href="/app/users.py#settings" title="Admin area: Manage Roxy-WI settings - Roxy-WI" class="settings head-submenu">Settings</a></li>
|
<li><a href="/app/users.py#settings" title="Admin area: Manage Roxy-WI settings" class="settings head-submenu">Settings</a></li>
|
||||||
<li><a href="/app/users.py#services" title="Admin area: Manage Roxy-WI services - Roxy-WI" class="services head-submenu">Services</a></li>
|
<li><a href="/app/users.py#services" title="Admin area: Manage Roxy-WI services" class="services head-submenu">Services</a></li>
|
||||||
<li><a href="/app/viewlogs.py" title="Admin area: View internal logs - Roxy-WI" class="logs head-submenu">Internal logs</a></li>
|
<li><a href="/app/viewlogs.py" title="Admin area: View internal logs" class="logs head-submenu">Internal logs</a></li>
|
||||||
<li><a href="/app/users.py#updatehapwi" title="Admin area: Update Roxy-WI - Roxy-WI" class="upload updatehapwi head-submenu">Update</a></li>
|
<li><a href="/app/users.py#updatehapwi" title="Admin area: Update Roxy-WI" class="upload updatehapwi head-submenu">Update</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -92,7 +92,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</center>
|
</center>
|
||||||
<script>
|
<script>
|
||||||
if (cur_url[1].split('&')[1] == 'showMap') {
|
if (cur_url[1].split('&')[2] == 'showMap') {
|
||||||
showMap();
|
showMap();
|
||||||
}
|
}
|
||||||
if (cur_url[1].split('&')[1] == 'showCompare' || cur_url[1].split('&')[2] == 'showCompare') {
|
if (cur_url[1].split('&')[1] == 'showCompare' || cur_url[1].split('&')[2] == 'showCompare') {
|
||||||
|
@ -170,6 +170,20 @@
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
myCodeMirror.refresh();
|
myCodeMirror.refresh();
|
||||||
|
$(document).bind('keydown', 'ctrl+s', function (){
|
||||||
|
$("[type='submit'][value='save']").click();
|
||||||
|
});
|
||||||
|
$(document).bind('keydown', 'ctrl+d', function (){
|
||||||
|
$("[type='submit'][value='test']").click();
|
||||||
|
});
|
||||||
|
$(document).bind('keydown', 'ctrl+e', function (){
|
||||||
|
$("[type='submit'][value='reload']").click();
|
||||||
|
});
|
||||||
|
{% if is_restart|int == 0 %}
|
||||||
|
$(document).bind('keydown', 'ctrl+r', function (){
|
||||||
|
$("[type='submit'][value='restart']").click();
|
||||||
|
});
|
||||||
|
{% endif %}
|
||||||
</script>
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -130,7 +130,7 @@
|
||||||
</table>
|
</table>
|
||||||
<div id="ajax"></div>
|
<div id="ajax"></div>
|
||||||
<div class="add-note alert addName alert-info" style="width: inherit; margin-right: 15px;">
|
<div class="add-note alert addName alert-info" style="width: inherit; margin-right: 15px;">
|
||||||
Read <a href="https://roxy-wi.org/howto.py/ha_cluster" title="How to create high available cluster" target="_blank">How to create high available cluster</a>
|
Read <a href="https://roxy-wi.org/howto/ha-cluster" title="How to create high available cluster" target="_blank">How to create high available cluster</a>
|
||||||
</div>
|
</div>
|
||||||
<div id="server_creating" style="display: none;">
|
<div id="server_creating" style="display: none;">
|
||||||
<ul style="padding: 20px 20px 0px 20px;font-size: 15px;">
|
<ul style="padding: 20px 20px 0px 20px;font-size: 15px;">
|
||||||
|
|
|
@ -55,14 +55,20 @@
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<div id="up-pannel" {%if not serv%} class="sortable"{%endif%}>
|
<div id="up-pannel" {%if not serv%} class="sortable"{%endif%}>
|
||||||
{% for s in servers %}
|
{%- for s in servers %}
|
||||||
{% if serv %}
|
{%- if serv %}
|
||||||
|
{% set config_id = 'id=config_link' %}
|
||||||
|
{% set compare_id = 'id=compare_link' %}
|
||||||
|
{% set map_id = 'id=map_link' %}
|
||||||
|
{% set stats_id = 'id=stats_link' %}
|
||||||
|
{% set logs_id = 'id=logs_link' %}
|
||||||
|
{% set versions_id = 'id=versions_link' %}
|
||||||
<script>
|
<script>
|
||||||
var server_ip = '{{s.2}}'
|
var server_ip = '{{s.2}}'
|
||||||
function showMetrics() {
|
function showMetrics() {
|
||||||
{% if service == 'haproxy' %}
|
{%- if service == 'haproxy' %}
|
||||||
{% for s in servers %}
|
{%- for s in servers %}
|
||||||
{% if s.8.0.9 %}
|
{%- if s.8.0.9 %}
|
||||||
getChartData(server_ip)
|
getChartData(server_ip)
|
||||||
getHttpChartData(server_ip)
|
getHttpChartData(server_ip)
|
||||||
getWafChartData(server_ip)
|
getWafChartData(server_ip)
|
||||||
|
@ -70,16 +76,16 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
showOverviewServer('{{s.1}}', server_ip, '{{s.0}}', '{{service}}');
|
showOverviewServer('{{s.1}}', server_ip, '{{s.0}}', '{{service}}');
|
||||||
{% if service == 'nginx' %}
|
{%- if service == 'nginx' %}
|
||||||
showNginxConnections(server_ip)
|
showNginxConnections(server_ip)
|
||||||
{% if s.8.0.21 %}
|
{% if s.8.0.21 %}
|
||||||
getNginxChartData(server_ip)
|
getNginxChartData(server_ip)
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elif service == 'apache' %}
|
{%- elif service == 'apache' %}
|
||||||
{% if s.8.0.27 %}
|
{% if s.8.0.27 %}
|
||||||
getApacheChartData(server_ip)
|
getApacheChartData(server_ip)
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elif service == 'haproxy' %}
|
{%- elif service == 'haproxy' %}
|
||||||
showBytes(server_ip)
|
showBytes(server_ip)
|
||||||
{% endif %}
|
{% endif %}
|
||||||
}
|
}
|
||||||
|
@ -104,23 +110,62 @@
|
||||||
metrics.then();
|
metrics.then();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
$(document).on('keydown', null, 'a', start_button);
|
||||||
|
function start_button(event) {
|
||||||
|
confirmAjaxAction('start', '{{service}}', '{{s.2}}');
|
||||||
|
}
|
||||||
|
$(document).on('keydown', null, 's', stop_button);
|
||||||
|
function stop_button(event) {
|
||||||
|
confirmAjaxAction('stop', '{{service}}', '{{s.2}}');
|
||||||
|
}
|
||||||
|
$(document).on('keydown', null, 'e', reload_button);
|
||||||
|
function reload_button(event) {
|
||||||
|
confirmAjaxAction('reload', '{{service}}', '{{s.2}}');
|
||||||
|
}
|
||||||
|
{% for set in restart_settings %}
|
||||||
|
{% if set.server_id == s.0 and set.setting == 'restart' and set.value|int == 0 %}
|
||||||
|
$(document).on('keydown', null, 'r', restart_button);
|
||||||
|
function restart_button(event) {
|
||||||
|
confirmAjaxAction('restart', '{{service}}', '{{s.2}}', '{{s.1}}');
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
$(document).on('keydown', null, 'k', metrics_button);
|
||||||
|
function metrics_button(event) {
|
||||||
|
showMetrics();
|
||||||
|
}
|
||||||
|
$(document).bind('keydown', 'o', function (){
|
||||||
|
window.location = document.getElementById('compare_link').href;
|
||||||
|
});
|
||||||
|
$(document).bind('keydown', 'c', function (){
|
||||||
|
window.location = document.getElementById('config_link').href;
|
||||||
|
});
|
||||||
|
$(document).bind('keydown', 'm', function (){
|
||||||
|
window.location = document.getElementById('map_link').href;
|
||||||
|
});
|
||||||
|
$(document).bind('keydown', 't', function (){
|
||||||
|
window.location = document.getElementById('stats_link').href;
|
||||||
|
});
|
||||||
|
$(document).bind('keydown', 'l', function (){
|
||||||
|
window.location = document.getElementById('logs_link').href;
|
||||||
|
});
|
||||||
|
$(document).bind('keydown', 'v', function (){
|
||||||
|
window.location = document.getElementById('versions_link').href;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% set checker_desc = "Checker monitors " +service_desc.service + " services. If " + service_desc.service + " service changes its status, Checker will alert via Telegram, Slack, Email, Web" %}
|
||||||
{% if service == 'nginx' %}
|
{% if service == 'nginx' %}
|
||||||
{% set checker_desc = 'Checker monitors Nginx services. If Nginx service is down, Checker will alert via Telegram and/or Slack' %}
|
|
||||||
{% set is_auto_start_enabled = s.8.0.17 %}
|
{% set is_auto_start_enabled = s.8.0.17 %}
|
||||||
{% set is_checker_enabled = s.8.0.19 %}
|
{% set is_checker_enabled = s.8.0.19 %}
|
||||||
{% set is_metrics_enabled = s.8.0.21 %}
|
{% set is_metrics_enabled = s.8.0.21 %}
|
||||||
{% set action_service = 'nginx' %}
|
|
||||||
{% if s.5.0.1 == 'active' or s.5.0.1 == 'Up' %}
|
{% if s.5.0.1 == 'active' or s.5.0.1 == 'Up' %}
|
||||||
{% set additional_status_class = 'div-server-head-up' %}
|
{% set additional_status_class = 'div-server-head-up' %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set additional_status_class = 'div-server-head-down' %}
|
{% set additional_status_class = 'div-server-head-down' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elif service == 'keepalived' %}
|
{% elif service == 'keepalived' %}
|
||||||
{% set checker_desc = 'Checker monitors Keepalived services. If Keepalived service is down, Checker will alert via Telegram and/or Slack' %}
|
|
||||||
{% set is_auto_start_enabled = s.8.0.22 %}
|
{% set is_auto_start_enabled = s.8.0.22 %}
|
||||||
{% set action_service = 'keepalived' %}
|
|
||||||
{% set is_checker_enabled = s.8.0.23 %}
|
{% set is_checker_enabled = s.8.0.23 %}
|
||||||
{% if s.5.0.1 == 'active' %}
|
{% if s.5.0.1 == 'active' %}
|
||||||
{% set additional_status_class = 'div-server-head-up' %}
|
{% set additional_status_class = 'div-server-head-up' %}
|
||||||
|
@ -128,9 +173,7 @@
|
||||||
{% set additional_status_class = 'div-server-head-down' %}
|
{% set additional_status_class = 'div-server-head-down' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elif service == 'apache' %}
|
{% elif service == 'apache' %}
|
||||||
{% set checker_desc = 'Checker monitors Apache services. If Apache service is down, Checker will alert via Telegram and/or Slack' %}
|
|
||||||
{% set is_auto_start_enabled = s.8.0.25 %}
|
{% set is_auto_start_enabled = s.8.0.25 %}
|
||||||
{% set action_service = 'apache' %}
|
|
||||||
{% set is_checker_enabled = s.8.0.26 %}
|
{% set is_checker_enabled = s.8.0.26 %}
|
||||||
{% set is_metrics_enabled = s.8.0.27 %}
|
{% set is_metrics_enabled = s.8.0.27 %}
|
||||||
{% if 'Apache' in s.4.0 %}
|
{% if 'Apache' in s.4.0 %}
|
||||||
|
@ -139,11 +182,9 @@
|
||||||
{% set additional_status_class = 'div-server-head-down' %}
|
{% set additional_status_class = 'div-server-head-down' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elif service == 'haproxy' %}
|
{% elif service == 'haproxy' %}
|
||||||
{% set checker_desc = 'Checker monitors HAProxy services, its backends and maxconn. If some backend or HAProxy service is down, Checker will alert via Telegram and/or Slack' %}
|
|
||||||
{% set is_auto_start_enabled = s.8.0.12 %}
|
{% set is_auto_start_enabled = s.8.0.12 %}
|
||||||
{% set is_checker_enabled = s.8.0.8 %}
|
{% set is_checker_enabled = s.8.0.8 %}
|
||||||
{% set is_metrics_enabled = s.8.0.9 %}
|
{% set is_metrics_enabled = s.8.0.9 %}
|
||||||
{% set action_service = 'hap' %}
|
|
||||||
{% if s.5 != False %}
|
{% if s.5 != False %}
|
||||||
{% set additional_status_class = 'div-server-head-up' %}
|
{% set additional_status_class = 'div-server-head-up' %}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -179,27 +220,27 @@
|
||||||
{% if role <= 3 %}
|
{% if role <= 3 %}
|
||||||
<span class="server-action">
|
<span class="server-action">
|
||||||
<a id="start-{{ s.2 }}" class="start" title="Start {{service}} service">
|
<a id="start-{{ s.2 }}" class="start" title="Start {{service}} service">
|
||||||
<span class="service-start" onclick="confirmAjaxAction('start', '{{action_service}}', '{{s.2}}')"></span>
|
<span class="service-start" onclick="confirmAjaxAction('start', '{{service}}', '{{s.2}}')"></span>
|
||||||
</a>
|
</a>
|
||||||
{% if service != 'keepalived' %}
|
{% if service != 'keepalived' %}
|
||||||
<a id="reload-{{ s.2 }}" class="reload" title="Reload {{service}} service">
|
<a id="reload-{{ s.2 }}" class="reload" title="Reload {{service}} service">
|
||||||
<span class="service-reload" onclick="confirmAjaxAction('reload', '{{action_service}}', '{{s.2}}', '{{s.1}}')"></span>
|
<span class="service-reload" onclick="confirmAjaxAction('reload', '{{service}}', '{{s.2}}', '{{s.1}}')"></span>
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for set in restart_settings %}
|
{% for set in restart_settings %}
|
||||||
{% if set.server_id == s.0 and set.setting == 'restart' and set.value|int == 0 %}
|
{% if set.server_id == s.0 and set.setting == 'restart' and set.value|int == 0 %}
|
||||||
<a id="restart-{{ s.2 }}" class="restart" title="Restart {{service}} service">
|
<a id="restart-{{ s.2 }}" class="restart" title="Restart {{service}} service">
|
||||||
<span class="service-reload service-restart" onclick="confirmAjaxAction('restart', '{{action_service}}', '{{s.2}}')"></span>
|
<span class="service-reload service-restart" onclick="confirmAjaxAction('restart', '{{service}}', '{{s.2}}')"></span>
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if restart_settings|length == 0 %}
|
{% if restart_settings|length == 0 %}
|
||||||
<a id="restart-{{ s.2 }}" class="restart" title="Restart {{service}} service">
|
<a id="restart-{{ s.2 }}" class="restart" title="Restart {{service}} service">
|
||||||
<span class="service-reload service-restart" onclick="confirmAjaxAction('restart', '{{action_service}}', '{{s.2}}')"></span>
|
<span class="service-reload service-restart" onclick="confirmAjaxAction('restart', '{{service}}', '{{s.2}}')"></span>
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a id="stop-{{ s.2 }}" class="stop" title="Stop {{service}} service">
|
<a id="stop-{{ s.2 }}" class="stop" title="Stop {{service}} service">
|
||||||
<span class="service-stop" onclick="confirmAjaxAction('stop', '{{action_service}}', '{{s.2}}')"></span>
|
<span class="service-stop" onclick="confirmAjaxAction('stop', '{{service}}', '{{s.2}}')"></span>
|
||||||
</a>
|
</a>
|
||||||
<a href="history.py?service={{service}}&serv={{s.2}}" title="View history for this service" class="history" style="margin: 0 5px 0 10px;"></a>
|
<a href="history.py?service={{service}}&serv={{s.2}}" title="View history for this service" class="history" style="margin: 0 5px 0 10px;"></a>
|
||||||
{% if service != 'keepalived' %}
|
{% if service != 'keepalived' %}
|
||||||
|
@ -288,20 +329,20 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="server-act-links">
|
<div class="server-act-links">
|
||||||
{% if service == 'nginx' or service == 'apache' %}
|
{% if service == 'nginx' or service == 'apache' %}
|
||||||
<a href="/app/config.py?service={{service}}&serv={{s.2}}&showConfigFiles" class="ui-button ui-widget ui-corner-all" title="Open running configs">Configs</a>
|
<a href="/app/config.py?service={{service}}&serv={{s.2}}&showConfigFiles" {{config_id}} class="ui-button ui-widget ui-corner-all" title="Open running configs">Configs</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="/app/config.py?service={{service}}&serv={{s.2}}&showConfig" class="ui-button ui-widget ui-corner-all" title="Open running config">Config</a>
|
<a href="/app/config.py?service={{service}}&serv={{s.2}}&showConfig" {{config_id}} class="ui-button ui-widget ui-corner-all" title="Open running config">Config</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a href="/app/config.py?service={{service}}&serv={{s.2}}&showCompare" class="ui-button ui-widget ui-corner-all" title="Compare configs">Compare</a>
|
<a href="/app/config.py?service={{service}}&serv={{s.2}}&showCompare" {{compare_id}} class="ui-button ui-widget ui-corner-all" title="Compare configs">Compare</a>
|
||||||
{% if service != 'nginx' and service != 'keepalived' and service != 'apache' %}
|
{% if service == 'haproxy' %}
|
||||||
<a href="/app/config.py?serv={{s.2}}&showMap" class="ui-button ui-widget ui-corner-all" title="Show map">Map</a>
|
<a href="/app/config.py?service={{service}}&serv={{s.2}}&showMap" class="ui-button ui-widget ui-corner-all" {{map_id}} title="Show map">Map</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if service != 'keepalived' %}
|
{% if service != 'keepalived' %}
|
||||||
<a href="/app/statsview.py?service={{service}}&serv={{s.2}}" class="ui-button ui-widget ui-corner-all" title="View {{service}} statistics">Stats</a>
|
<a href="/app/statsview.py?service={{service}}&serv={{s.2}}" class="ui-button ui-widget ui-corner-all" {{stats_id}} title="View {{service}} statistics">Stats</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a href="/app/logs.py?service={{service}}&serv={{s.2}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" class="ui-button ui-widget ui-corner-all" title="View {{service}} logs">Logs</a>
|
<a href="/app/logs.py?service={{service}}&serv={{s.2}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" {{logs_id}} class="ui-button ui-widget ui-corner-all" title="View {{service}} logs">Logs</a>
|
||||||
{% if role <= 2 %}
|
{% if role <= 2 %}
|
||||||
<a href="/app/versions.py?service={{service}}&serv={{s.2}}&open=open" class="ui-button ui-widget ui-corner-all" title="View/Rollback to previous config">Versions</a>
|
<a href="/app/versions.py?service={{service}}&serv={{s.2}}&open=open" class="ui-button ui-widget ui-corner-all" {{versions_id}} title="View/Rollback to previous config">Versions</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -54,12 +54,9 @@ try:
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
user, user_id, role, token, servers, user_services = funct.get_users_params()
|
||||||
user, user_id, role, token, servers, user_services = funct.get_users_params()
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
selects = funct.get_files(log_path, format="log")
|
selects = funct.get_files(log_path, "log")
|
||||||
if form.getvalue('type') is None:
|
if form.getvalue('type') is None:
|
||||||
selects.append(['fail2ban.log', 'fail2ban.log'])
|
selects.append(['fail2ban.log', 'fail2ban.log'])
|
||||||
selects.append(['roxy-wi.error.log', 'error.log'])
|
selects.append(['roxy-wi.error.log', 'error.log'])
|
||||||
|
|
|
@ -2,20 +2,21 @@
|
||||||
AddDefaultCharset UTF-8
|
AddDefaultCharset UTF-8
|
||||||
SetEnv PYTHONIOENCODING utf8
|
SetEnv PYTHONIOENCODING utf8
|
||||||
|
|
||||||
SSLEngine on
|
SSLEngine on
|
||||||
SSLCertificateFile /var/www/haproxy-wi/app/certs/haproxy-wi.crt
|
SSLCertificateFile /var/www/haproxy-wi/app/certs/haproxy-wi.crt
|
||||||
SSLCertificateKeyFile /var/www/haproxy-wi/app/certs/haproxy-wi.key
|
SSLCertificateKeyFile /var/www/haproxy-wi/app/certs/haproxy-wi.key
|
||||||
|
|
||||||
ServerName haproxy-wi.example.com
|
ServerName haproxy-wi.example.com
|
||||||
ErrorLog /var/log/httpd/roxy-wi.error.log
|
ErrorLog /var/log/httpd/roxy-wi.error.log
|
||||||
CustomLog /var/log/httpd/roxy-wi.access.log combined
|
CustomLog /var/log/httpd/roxy-wi.access.log combined
|
||||||
TimeOut 600
|
TimeOut 600
|
||||||
LimitRequestLine 16380
|
LimitRequestLine 16380
|
||||||
|
|
||||||
|
RewriteEngine On
|
||||||
|
RewriteCond %{HTTP:Upgrade} =websocket [NC]
|
||||||
|
RewriteRule /(.*) ws://localhost:8765/ [P,L]
|
||||||
|
ProxyPassReverse / http://localhost:8765/
|
||||||
|
|
||||||
RewriteEngine On
|
|
||||||
RewriteCond %{HTTP:Upgrade} =websocket [NC]
|
|
||||||
RewriteRule /(.*) ws://localhost:8765/ [P,L]
|
|
||||||
ProxyPassReverse / http://localhost:8765/
|
|
||||||
WSGIDaemonProcess api display-name=%{GROUP} user=apache group=apache processes=1 threads=5
|
WSGIDaemonProcess api display-name=%{GROUP} user=apache group=apache processes=1 threads=5
|
||||||
WSGIScriptAlias /api /var/www/haproxy-wi/api/app.wsgi
|
WSGIScriptAlias /api /var/www/haproxy-wi/api/app.wsgi
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@
|
||||||
ScriptAlias /cgi-bin/ "/var/www/haproxy-wi/app/"
|
ScriptAlias /cgi-bin/ "/var/www/haproxy-wi/app/"
|
||||||
|
|
||||||
<Directory /var/www/haproxy-wi/app>
|
<Directory /var/www/haproxy-wi/app>
|
||||||
AllowOverride FileInfo
|
AllowOverride FileInfo
|
||||||
DirectoryIndex overview.py
|
DirectoryIndex overview.py
|
||||||
Options +ExecCGI
|
Options +ExecCGI
|
||||||
AddHandler cgi-script .py
|
AddHandler cgi-script .py
|
||||||
|
@ -31,46 +32,30 @@
|
||||||
Allow from all
|
Allow from all
|
||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
<Directory /var/www/haproxy-wi/app/certs>
|
<Directory /var/www/haproxy-wi/app/certs>
|
||||||
Options +ExecCGI -Indexes +MultiViews
|
Options +ExecCGI -Indexes +MultiViews
|
||||||
Order Deny,Allow
|
Order Deny,Allow
|
||||||
Deny from all
|
Deny from all
|
||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
<Directory /var/www/haproxy-wi/keys>
|
<Directory /var/www/haproxy-wi/app/scripts/terraform/>
|
||||||
Options +ExecCGI -Indexes +MultiViews
|
Deny from all
|
||||||
Order Deny,Allow
|
|
||||||
Deny from all
|
|
||||||
</Directory>
|
|
||||||
|
|
||||||
<Directory /var/www/haproxy-wi/app/scripts/terraform/>
|
|
||||||
Deny from all
|
|
||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
<Directory /var/www/haproxy-wi/.git/>
|
<Directory /var/www/haproxy-wi/.git/>
|
||||||
Deny from all
|
Deny from all
|
||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
<FilesMatch "\.cfg$">
|
<IfModule mod_headers.c>
|
||||||
Order Deny,Allow
|
Header set X-XSS-Protection: 1;
|
||||||
Deny from all
|
Header set X-Frame-Options: deny
|
||||||
</FilesMatch>
|
Header set X-Content-Type-Options: nosniff
|
||||||
|
Header set Strict-Transport-Security: max-age=3600;
|
||||||
|
Header set Cache-Control no-cache
|
||||||
|
Header set Expires: 0
|
||||||
|
|
||||||
<FilesMatch "\.db$">
|
<filesMatch ".(ico|css|js|gif|jpeg|jpg|png|svg|woff|ttf|eot)$">
|
||||||
Order Deny,Allow
|
Header set Cache-Control "max-age=86400, public"
|
||||||
Deny from all
|
</filesMatch>
|
||||||
</FilesMatch>
|
|
||||||
|
|
||||||
<IfModule mod_headers.c>
|
|
||||||
Header set X-XSS-Protection: 1;
|
|
||||||
Header set X-Frame-Options: deny
|
|
||||||
Header set X-Content-Type-Options: nosniff
|
|
||||||
Header set Strict-Transport-Security: max-age=3600;
|
|
||||||
Header set Cache-Control no-cache
|
|
||||||
Header set Expires: 0
|
|
||||||
|
|
||||||
<filesMatch ".(ico|css|js|gif|jpeg|jpg|png|svg|woff|ttf|eot)$">
|
|
||||||
Header set Cache-Control "max-age=86400, public"
|
|
||||||
</filesMatch>
|
|
||||||
</IfModule>
|
</IfModule>
|
||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
|
|
|
@ -38,12 +38,6 @@
|
||||||
Deny from all
|
Deny from all
|
||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
<Directory /var/www/haproxy-wi/keys>
|
|
||||||
Options +ExecCGI -Indexes +MultiViews
|
|
||||||
Order Deny,Allow
|
|
||||||
Deny from all
|
|
||||||
</Directory>
|
|
||||||
|
|
||||||
<Directory /var/www/haproxy-wi/app/scripts/terraform/>
|
<Directory /var/www/haproxy-wi/app/scripts/terraform/>
|
||||||
Deny from all
|
Deny from all
|
||||||
</Directory>
|
</Directory>
|
||||||
|
@ -52,26 +46,16 @@
|
||||||
Deny from all
|
Deny from all
|
||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
<FilesMatch "\.cfg$">
|
<IfModule mod_headers.c>
|
||||||
Order Deny,Allow
|
Header set X-XSS-Protection: 1;
|
||||||
Deny from all
|
Header set X-Frame-Options: deny
|
||||||
</FilesMatch>
|
Header set X-Content-Type-Options: nosniff
|
||||||
|
Header set Strict-Transport-Security: max-age=3600;
|
||||||
|
Header set Cache-Control no-cache
|
||||||
|
Header set Expires: 0
|
||||||
|
|
||||||
<FilesMatch "\.db$">
|
<filesMatch ".(ico|css|js|gif|jpeg|jpg|png|svg|woff|ttf|eot)$">
|
||||||
Order Deny,Allow
|
Header set Cache-Control "max-age=86400, public"
|
||||||
Deny from all
|
|
||||||
</FilesMatch>
|
|
||||||
|
|
||||||
<IfModule mod_headers.c>
|
|
||||||
Header set X-XSS-Protection: 1;
|
|
||||||
Header set X-Frame-Options: deny
|
|
||||||
Header set X-Content-Type-Options: nosniff
|
|
||||||
Header set Strict-Transport-Security: max-age=3600;
|
|
||||||
Header set Cache-Control no-cache
|
|
||||||
Header set Expires: 0
|
|
||||||
|
|
||||||
<filesMatch ".(ico|css|js|gif|jpeg|jpg|png|svg|woff|ttf|eot)$">
|
|
||||||
Header set Cache-Control "max-age=86400, public"
|
|
||||||
</filesMatch>
|
</filesMatch>
|
||||||
</IfModule>
|
</IfModule>
|
||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
|
|
154
inc/add.js
154
inc/add.js
|
@ -1491,7 +1491,7 @@ function view_ssl(id) {
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
function deleteSsl(id) {
|
function deleteSsl(id) {
|
||||||
if(!checkIsServerFiled('#serv5')) return false;;
|
if(!checkIsServerFiled('#serv5')) return false;
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
url: "options.py",
|
url: "options.py",
|
||||||
data: {
|
data: {
|
||||||
|
@ -1629,68 +1629,59 @@ function editList(list, color) {
|
||||||
}
|
}
|
||||||
function saveList(action, list, color) {
|
function saveList(action, list, color) {
|
||||||
var serv = $( "#serv-"+color+"-list option:selected" ).val();
|
var serv = $( "#serv-"+color+"-list option:selected" ).val();
|
||||||
if (serv == '------') {
|
if(!checkIsServerFiled(serv)) return false;
|
||||||
toastr.warning('Select a server before updating');
|
$.ajax({
|
||||||
} else {
|
url: "options.py",
|
||||||
$.ajax({
|
data: {
|
||||||
url: "options.py",
|
bwlists_save: list,
|
||||||
data: {
|
serv: serv,
|
||||||
bwlists_save: list,
|
bwlists_content: $('#edit_lists').val(),
|
||||||
serv: serv,
|
color: color,
|
||||||
bwlists_content: $('#edit_lists').val(),
|
group: $('#group').val(),
|
||||||
color: color,
|
bwlists_restart: action,
|
||||||
group: $('#group').val(),
|
token: $('#token').val()
|
||||||
bwlists_restart: action,
|
},
|
||||||
token: $('#token').val()
|
type: "POST",
|
||||||
},
|
success: function (data) {
|
||||||
type: "POST",
|
data = data.split(" , ");
|
||||||
success: function (data) {
|
for (i = 0; i < data.length; i++) {
|
||||||
data = data.split(" , ");
|
if (data[i]) {
|
||||||
|
if (data[i].indexOf('error: ') != '-1' || data[i].indexOf('Errno') != '-1') {
|
||||||
for (i = 0; i < data.length; i++) {
|
toastr.error(data[i]);
|
||||||
if (data[i]) {
|
} else {
|
||||||
if (data[i].indexOf('error: ') != '-1' || data[i].indexOf('Errno') != '-1') {
|
toastr.success(data[i]);
|
||||||
toastr.error(data[i]);
|
|
||||||
} else {
|
|
||||||
toastr.success(data[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
function deleteList(list, color) {
|
function deleteList(list, color) {
|
||||||
var serv = $( "#serv-"+color+"-list option:selected" ).val();
|
var serv = $( "#serv-"+color+"-list option:selected" ).val();
|
||||||
if (serv == '------') {
|
if(!checkIsServerFiled(serv)) return false;
|
||||||
toastr.warning('Choose a server before deleting');
|
$.ajax({
|
||||||
} else {
|
url: "options.py",
|
||||||
$.ajax({
|
data: {
|
||||||
url: "options.py",
|
bwlists_delete: list,
|
||||||
data: {
|
serv: serv,
|
||||||
bwlists_delete: list,
|
color: color,
|
||||||
serv: serv,
|
group: $('#group').val(),
|
||||||
color: color,
|
token: $('#token').val()
|
||||||
group: $('#group').val(),
|
},
|
||||||
token: $('#token').val()
|
type: "POST",
|
||||||
},
|
success: function (data) {
|
||||||
type: "POST",
|
if (data.indexOf('error:') != '-1' || data.indexOf('Failed') != '-1' || data.indexOf('Errno') != '-1') {
|
||||||
success: function (data) {
|
toastr.error(data);
|
||||||
if (data.indexOf('error:') != '-1' || data.indexOf('Failed') != '-1' || data.indexOf('Errno') != '-1') {
|
} else if (data.indexOf('Info') != '-1' ){
|
||||||
toastr.error(data);
|
toastr.clear();
|
||||||
} else if (data.indexOf('Info') != '-1' ){
|
toastr.info(data);
|
||||||
toastr.clear();
|
} else if (data.indexOf('success') != '-1' ) {
|
||||||
toastr.info(data);
|
toastr.clear();
|
||||||
} else if (data.indexOf('success') != '-1' ) {
|
toastr.success('List has been deleted');
|
||||||
toastr.clear();
|
setTimeout(function () {location.reload();}, 2500);
|
||||||
toastr.success('List has been deleted');
|
|
||||||
setTimeout(function () {
|
|
||||||
location.reload();
|
|
||||||
}, 2500);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
function generateConfig(form_name) {
|
function generateConfig(form_name) {
|
||||||
var frm = $('#'+form_name);
|
var frm = $('#'+form_name);
|
||||||
|
@ -1901,7 +1892,7 @@ var acl_option = '<p id="new_acl_p" style="border-bottom: 1px solid #ddd; paddin
|
||||||
'\t<option value="7">Set-header</option>\n' +
|
'\t<option value="7">Set-header</option>\n' +
|
||||||
'</select>\n' +
|
'</select>\n' +
|
||||||
'<b class="padding10">value</b>\n' +
|
'<b class="padding10">value</b>\n' +
|
||||||
'<input type="text" name="acl_then_value" class="form-control" value="" title="Required if \"then\" is \"Use backend\" or \"Redirect\"">\n' +
|
'<input type="text" name="acl_then_value" class="form-control" value="" title="Required if\" then\" is \"Use backend\" or \"Redirect\"">\n' +
|
||||||
'<span class="minus minus-style" id="new_acl_rule_minus" title="Delete this ACL"></span>' +
|
'<span class="minus minus-style" id="new_acl_rule_minus" title="Delete this ACL"></span>' +
|
||||||
'</p>'
|
'</p>'
|
||||||
function make_actions_for_adding_acl_rule(section_id) {
|
function make_actions_for_adding_acl_rule(section_id) {
|
||||||
|
@ -1969,34 +1960,31 @@ function makeid(length) {
|
||||||
}
|
}
|
||||||
function showUserlists() {
|
function showUserlists() {
|
||||||
var serv = $( "#existing_userlist_serv option:selected" ).val();
|
var serv = $( "#existing_userlist_serv option:selected" ).val();
|
||||||
if (serv == 'Choose server') {
|
if(!checkIsServerFiled(serv)) return false;
|
||||||
toastr.warning('Choose a server before');
|
$.ajax({
|
||||||
} else {
|
url: "options.py",
|
||||||
$.ajax({
|
data: {
|
||||||
url: "options.py",
|
show_userlists: 1,
|
||||||
data: {
|
serv: serv,
|
||||||
show_userlists: 1,
|
token: $('#token').val()
|
||||||
serv: serv,
|
},
|
||||||
token: $('#token').val()
|
type: "POST",
|
||||||
},
|
success: function (data) {
|
||||||
type: "POST",
|
if (data.indexOf('error:') != '-1' || data.indexOf('Failed') != '-1') {
|
||||||
success: function (data) {
|
toastr.error(data);
|
||||||
if (data.indexOf('error:') != '-1' || data.indexOf('Failed') != '-1') {
|
} else {
|
||||||
toastr.error(data);
|
$('#existing_userlist_tr').show();
|
||||||
} else {
|
$('#existing_userlist_ajax').text('');
|
||||||
$('#existing_userlist_tr').show();
|
data = data.split(",");
|
||||||
$('#existing_userlist_ajax').text('');
|
for (i = 0; i < data.length; i++) {
|
||||||
data = data.split(",");
|
var existing_userlist_ajax = $.find("#existing_userlist_ajax");
|
||||||
for (i = 0; i < data.length; i++) {
|
existing_userlist_ajax = existing_userlist_ajax[0].id;
|
||||||
var existing_userlist_ajax = $.find("#existing_userlist_ajax");
|
data[i] = escapeHtml(data[i]);
|
||||||
existing_userlist_ajax = existing_userlist_ajax[0].id;
|
$('#'+existing_userlist_ajax).append('<a href="sections.py?serv='+serv+'§ion='+data[i]+'" title="Edit/Delete this userlist" target="_blank">'+data[i]+'</a> ');
|
||||||
data[i] = escapeHtml(data[i]);
|
|
||||||
$('#'+existing_userlist_ajax).append('<a href="sections.py?serv='+serv+'§ion='+data[i]+'" title="Edit/Delete this userlist" target="_blank">'+data[i]+'</a> ');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
function changePortCheckFromServerPort() {
|
function changePortCheckFromServerPort() {
|
||||||
$('[name=server_port]').on('input', function (){
|
$('[name=server_port]').on('input', function (){
|
||||||
|
|
|
@ -0,0 +1,204 @@
|
||||||
|
/*jslint browser: true*/
|
||||||
|
/*jslint jquery: true*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* jQuery Hotkeys Plugin
|
||||||
|
* Copyright 2010, John Resig
|
||||||
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||||
|
*
|
||||||
|
* Based upon the plugin by Tzury Bar Yochay:
|
||||||
|
* https://github.com/tzuryby/jquery.hotkeys
|
||||||
|
*
|
||||||
|
* Original idea by:
|
||||||
|
* Binny V A, http://www.openjs.com/scripts/events/keyboard_shortcuts/
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* One small change is: now keys are passed by object { keys: '...' }
|
||||||
|
* Might be useful, when you want to pass some other data to your handler
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function(jQuery) {
|
||||||
|
|
||||||
|
jQuery.hotkeys = {
|
||||||
|
version: "0.2.0",
|
||||||
|
|
||||||
|
specialKeys: {
|
||||||
|
8: "backspace",
|
||||||
|
9: "tab",
|
||||||
|
10: "return",
|
||||||
|
13: "return",
|
||||||
|
16: "shift",
|
||||||
|
17: "ctrl",
|
||||||
|
18: "alt",
|
||||||
|
19: "pause",
|
||||||
|
20: "capslock",
|
||||||
|
27: "esc",
|
||||||
|
32: "space",
|
||||||
|
33: "pageup",
|
||||||
|
34: "pagedown",
|
||||||
|
35: "end",
|
||||||
|
36: "home",
|
||||||
|
37: "left",
|
||||||
|
38: "up",
|
||||||
|
39: "right",
|
||||||
|
40: "down",
|
||||||
|
45: "insert",
|
||||||
|
46: "del",
|
||||||
|
59: ";",
|
||||||
|
61: "=",
|
||||||
|
96: "0",
|
||||||
|
97: "1",
|
||||||
|
98: "2",
|
||||||
|
99: "3",
|
||||||
|
100: "4",
|
||||||
|
101: "5",
|
||||||
|
102: "6",
|
||||||
|
103: "7",
|
||||||
|
104: "8",
|
||||||
|
105: "9",
|
||||||
|
106: "*",
|
||||||
|
107: "+",
|
||||||
|
109: "-",
|
||||||
|
110: ".",
|
||||||
|
111: "/",
|
||||||
|
112: "f1",
|
||||||
|
113: "f2",
|
||||||
|
114: "f3",
|
||||||
|
115: "f4",
|
||||||
|
116: "f5",
|
||||||
|
117: "f6",
|
||||||
|
118: "f7",
|
||||||
|
119: "f8",
|
||||||
|
120: "f9",
|
||||||
|
121: "f10",
|
||||||
|
122: "f11",
|
||||||
|
123: "f12",
|
||||||
|
144: "numlock",
|
||||||
|
145: "scroll",
|
||||||
|
173: "-",
|
||||||
|
186: ";",
|
||||||
|
187: "=",
|
||||||
|
188: ",",
|
||||||
|
189: "-",
|
||||||
|
190: ".",
|
||||||
|
191: "/",
|
||||||
|
192: "`",
|
||||||
|
219: "[",
|
||||||
|
220: "\\",
|
||||||
|
221: "]",
|
||||||
|
222: "'"
|
||||||
|
},
|
||||||
|
|
||||||
|
shiftNums: {
|
||||||
|
"`": "~",
|
||||||
|
"1": "!",
|
||||||
|
"2": "@",
|
||||||
|
"3": "#",
|
||||||
|
"4": "$",
|
||||||
|
"5": "%",
|
||||||
|
"6": "^",
|
||||||
|
"7": "&",
|
||||||
|
"8": "*",
|
||||||
|
"9": "(",
|
||||||
|
"0": ")",
|
||||||
|
"-": "_",
|
||||||
|
"=": "+",
|
||||||
|
";": ": ",
|
||||||
|
"'": "\"",
|
||||||
|
",": "<",
|
||||||
|
".": ">",
|
||||||
|
"/": "?",
|
||||||
|
"\\": "|"
|
||||||
|
},
|
||||||
|
|
||||||
|
// excludes: button, checkbox, file, hidden, image, password, radio, reset, search, submit, url
|
||||||
|
textAcceptingInputTypes: [
|
||||||
|
"text", "password", "number", "email", "url", "range", "date", "month", "week", "time", "datetime",
|
||||||
|
"datetime-local", "search", "color", "tel"],
|
||||||
|
|
||||||
|
// default input types not to bind to unless bound directly
|
||||||
|
textInputTypes: /textarea|input|select/i,
|
||||||
|
|
||||||
|
options: {
|
||||||
|
filterInputAcceptingElements: true,
|
||||||
|
filterTextInputs: true,
|
||||||
|
filterContentEditable: true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function keyHandler(handleObj) {
|
||||||
|
if (typeof handleObj.data === "string") {
|
||||||
|
handleObj.data = {
|
||||||
|
keys: handleObj.data
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only care when a possible input has been specified
|
||||||
|
if (!handleObj.data || !handleObj.data.keys || typeof handleObj.data.keys !== "string") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var origHandler = handleObj.handler,
|
||||||
|
keys = handleObj.data.keys.toLowerCase().split(" ");
|
||||||
|
|
||||||
|
handleObj.handler = function(event) {
|
||||||
|
// Don't fire in text-accepting inputs that we didn't directly bind to
|
||||||
|
if (this !== event.target &&
|
||||||
|
(jQuery.hotkeys.options.filterInputAcceptingElements &&
|
||||||
|
jQuery.hotkeys.textInputTypes.test(event.target.nodeName) ||
|
||||||
|
(jQuery.hotkeys.options.filterContentEditable && jQuery(event.target).attr('contenteditable')) ||
|
||||||
|
(jQuery.hotkeys.options.filterTextInputs &&
|
||||||
|
jQuery.inArray(event.target.type, jQuery.hotkeys.textAcceptingInputTypes) > -1))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var special = event.type !== "keypress" && jQuery.hotkeys.specialKeys[event.which],
|
||||||
|
character = String.fromCharCode(event.which).toLowerCase(),
|
||||||
|
modif = "",
|
||||||
|
possible = {};
|
||||||
|
|
||||||
|
jQuery.each(["alt", "ctrl", "shift"], function(index, specialKey) {
|
||||||
|
|
||||||
|
if (event[specialKey + 'Key'] && special !== specialKey) {
|
||||||
|
modif += specialKey + '+';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// metaKey is triggered off ctrlKey erronously
|
||||||
|
if (event.metaKey && !event.ctrlKey && special !== "meta") {
|
||||||
|
modif += "meta+";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.metaKey && special !== "meta" && modif.indexOf("alt+ctrl+shift+") > -1) {
|
||||||
|
modif = modif.replace("alt+ctrl+shift+", "hyper+");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (special) {
|
||||||
|
possible[modif + special] = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
possible[modif + character] = true;
|
||||||
|
possible[modif + jQuery.hotkeys.shiftNums[character]] = true;
|
||||||
|
|
||||||
|
// "$" can be triggered as "Shift+4" or "Shift+$" or just "$"
|
||||||
|
if (modif === "shift+") {
|
||||||
|
possible[jQuery.hotkeys.shiftNums[character]] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0, l = keys.length; i < l; i++) {
|
||||||
|
if (possible[keys[i]]) {
|
||||||
|
return origHandler.apply(this, arguments);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
jQuery.each(["keydown", "keyup", "keypress"], function() {
|
||||||
|
jQuery.event.special[this] = {
|
||||||
|
add: keyHandler
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
})(jQuery || this.jQuery || window.jQuery);
|
|
@ -322,10 +322,15 @@ function getApacheChartData(server) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function loadMetrics() {
|
function loadMetrics() {
|
||||||
|
var service = findGetParameter('service');
|
||||||
|
if (!service) {
|
||||||
|
service = 'haproxy';
|
||||||
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "options.py",
|
url: "options.py",
|
||||||
data: {
|
data: {
|
||||||
table_metrics: '1',
|
table_metrics: '1',
|
||||||
|
service: service,
|
||||||
token: $('#token').val()
|
token: $('#token').val()
|
||||||
},
|
},
|
||||||
beforeSend: function() {
|
beforeSend: function() {
|
||||||
|
|
|
@ -395,7 +395,7 @@ function confirmAjaxAction(action, service, id) {
|
||||||
buttons: {
|
buttons: {
|
||||||
"Sure": function() {
|
"Sure": function() {
|
||||||
$( this ).dialog( "close" );
|
$( this ).dialog( "close" );
|
||||||
if(service == "hap") {
|
if(service == "haproxy") {
|
||||||
ajaxActionServers(action, id);
|
ajaxActionServers(action, id);
|
||||||
if(action == "restart" || action == "reload") {
|
if(action == "restart" || action == "reload") {
|
||||||
if(localStorage.getItem('restart')) {
|
if(localStorage.getItem('restart')) {
|
||||||
|
|
|
@ -466,7 +466,7 @@ function showMap() {
|
||||||
} else {
|
} else {
|
||||||
toastr.clear();
|
toastr.clear();
|
||||||
$("#ajax").html(data);
|
$("#ajax").html(data);
|
||||||
window.history.pushState("Show map", "Show map", cur_url[0] + '?serv=' + $("#serv").val() + '&showMap');
|
window.history.pushState("Show map", "Show map", cur_url[0] + '?service=haproxy&serv=' + $("#serv").val() + '&showMap');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
@ -724,34 +724,6 @@ function viewLogs() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$( function() {
|
$( function() {
|
||||||
NProgress.configure({showSpinner: false});
|
|
||||||
$.ajax( {
|
|
||||||
url: "options.py",
|
|
||||||
data: {
|
|
||||||
show_versions: 1,
|
|
||||||
token: $('#token').val()
|
|
||||||
},
|
|
||||||
type: "POST",
|
|
||||||
success: function( data ) {
|
|
||||||
$('#version').html(data);
|
|
||||||
var showUpdates = $( "#show-updates" ).dialog({
|
|
||||||
autoOpen: false,
|
|
||||||
width: 600,
|
|
||||||
modal: true,
|
|
||||||
title: 'There is a new version Roxy-WI',
|
|
||||||
buttons: {
|
|
||||||
Close: function() {
|
|
||||||
$( this ).dialog( "close" );
|
|
||||||
clearTips();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$('#show-updates-button').click(function() {
|
|
||||||
showUpdates.dialog('open');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
NProgress.configure({showSpinner: true});
|
|
||||||
$('a').click(function(e) {
|
$('a').click(function(e) {
|
||||||
try {
|
try {
|
||||||
var cur_path = window.location.pathname;
|
var cur_path = window.location.pathname;
|
||||||
|
@ -1535,3 +1507,33 @@ function returnNiceCheckingConfig(data) {
|
||||||
toastr.success('<b>' + server_name2 + ' Configuration file is valid</b>');
|
toastr.success('<b>' + server_name2 + ' Configuration file is valid</b>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function show_version() {
|
||||||
|
NProgress.configure({showSpinner: false});
|
||||||
|
$.ajax( {
|
||||||
|
url: "options.py",
|
||||||
|
data: {
|
||||||
|
show_versions: 1,
|
||||||
|
token: $('#token').val()
|
||||||
|
},
|
||||||
|
type: "POST",
|
||||||
|
success: function( data ) {
|
||||||
|
$('#version').html(data);
|
||||||
|
var showUpdates = $( "#show-updates" ).dialog({
|
||||||
|
autoOpen: false,
|
||||||
|
width: 600,
|
||||||
|
modal: true,
|
||||||
|
title: 'There is a new Roxy-WI version',
|
||||||
|
buttons: {
|
||||||
|
Close: function() {
|
||||||
|
$( this ).dialog( "close" );
|
||||||
|
clearTips();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#show-updates-button').click(function() {
|
||||||
|
showUpdates.dialog('open');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
NProgress.configure({showSpinner: true});
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue