60
README.md
|
@ -15,36 +15,36 @@ Web interface(user-friendly web GUI, alerting, monitoring and secure) for managi
|
|||
![alt text](image/haproxy-wi-config-show.png "Show config page")
|
||||
|
||||
# Features:
|
||||
1. Configure HAProxy and Keepalived In a jiffy with HAProxy-WI
|
||||
2. View and analyse Status of all Frontend/backend server via HAProxy-WI from a single control panel.
|
||||
3. Enable/disable servers through stats page without rebooting HAProxy
|
||||
4. View/Analyse HAproxy logs straight from the HAProxy-WI web interface
|
||||
5. Create and visualise the HAProxy workflow from Web Ui.
|
||||
6. Push Your changes to your HAProxy and Keepalived servers with a single click through web interface
|
||||
7. Get info on past changes, evaluate your config files and restore a previous stable config anytime with a single click straight from Web interface
|
||||
8. Add/Edit Frontend or backend servers via web interface with a click of a button.
|
||||
9. Edit config of HAProxy, Keepalived and push changes to All Master/Slave server with a single click
|
||||
10. Add Multiple server to ensure Config Sync between servers.
|
||||
11. Auto management of ports assigned to Fronted.
|
||||
12. Evaluate the changes of recent configs pushed to HAProxy and Keepalived instances straight from web ui
|
||||
13. Multiple User Roles support for privileged based Viewing and editing of Config
|
||||
14. Create Groups and add /remove servers to ensure proper identification for your HAProxy Clusters
|
||||
15. Send notifications to telegram directly from HAProxy-WI
|
||||
16. HAProxy-WI supports high Availability to ensure uptime to all Master slave servers configured
|
||||
17. SSL certificate support.
|
||||
18. SSH Key support for managing multiple HAProxy Servers straight from HAProxy-WI
|
||||
19. SYN flood protect
|
||||
20. Alerting about changes backends state
|
||||
21. Alerting about HAProxy service state
|
||||
22. Metrics incoming connections
|
||||
23. Web acceleration settings
|
||||
24. Web application firewall
|
||||
25. LDAP support
|
||||
26. Keep active HAProxy service
|
||||
27. Ability to hide parts of the config with tags for users with "guest" role: "HideBlockStart" and "HideBlockEnd"
|
||||
28. Mobile-ready desing
|
||||
29. REST API
|
||||
30. Installation and Upgrading HAProxy service via HAProxy-WI
|
||||
1. Installation and updating HAProxy, Nginx and Keepalived with HAProxy-WI
|
||||
2. Configure HAProxy, Nginx and Keepalived In a jiffy with HAProxy-WI
|
||||
3. View and analyse Status of all Frontend/backend server via HAProxy-WI from a single control panel.
|
||||
4. Enable/disable servers through stats page without rebooting HAProxy
|
||||
5. View/Analyse HAproxy, Nginx logs straight from the HAProxy-WI web interface
|
||||
6. Create and visualise the HAProxy workflow from Web Ui.
|
||||
7. Push Your changes to your HAProxy, Nginx and Keepalived servers with a single click through web interface
|
||||
8. Get info on past changes, evaluate your config files and restore a previous stable config anytime with a single click straight from Web interface
|
||||
9. Add/Edit Frontend or backend servers via web interface with a click of a button.
|
||||
10. Edit config of HAProxy, Nginx, Keepalived and push changes to All Master/Slave server with a single click
|
||||
11. Add Multiple server to ensure Config Sync between servers.
|
||||
12. Auto management of ports assigned to Fronted.
|
||||
13. Evaluate the changes of recent configs pushed to HAProxy, Nginx and Keepalived instances straight from web ui
|
||||
14. Multiple User Roles support for privileged based Viewing and editing of Config
|
||||
15. Create Groups and add /remove servers to ensure proper identification for your HAProxy Clusters
|
||||
16. Send notifications to telegram directly from HAProxy-WI
|
||||
17. HAProxy-WI supports high Availability to ensure uptime to all Master slave servers configured
|
||||
18. SSL certificate support.
|
||||
19. SSH Key support for managing multiple HAProxy Servers straight from HAProxy-WI
|
||||
20. SYN flood protect
|
||||
21. Alerting about changes backends state
|
||||
22. Alerting about HAProxy service state
|
||||
23. Metrics incoming connections
|
||||
24. Web acceleration settings
|
||||
25. Web application firewall
|
||||
26. LDAP support
|
||||
27. Keep active HAProxy service
|
||||
28. Ability to hide parts of the config with tags for users with "guest" role: "HideBlockStart" and "HideBlockEnd"
|
||||
29. Mobile-ready desing
|
||||
30. REST API
|
||||
31. Backup HAProxy's and Keepalived's config files through HAProxy-WI
|
||||
|
||||
![alt text](image/haproxy-wi-metrics.png "Merics")
|
||||
|
|
|
@ -35,15 +35,19 @@ if service == 'keepalived':
|
|||
action = "config.py?service=keepalived"
|
||||
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
||||
format = 'conf'
|
||||
servers = sql.get_dick_permit()
|
||||
keepalived = 1
|
||||
servers = sql.get_dick_permit(keepalived=1)
|
||||
elif service == 'nginx':
|
||||
title = "Working with Nginx configs"
|
||||
action = "config.py?service=nginx"
|
||||
configs_dir = funct.get_config_var('configs', 'nginx_save_configs_dir')
|
||||
format = 'conf'
|
||||
servers = sql.get_dick_permit(nginx=1)
|
||||
else:
|
||||
title = "Working with HAProxy configs"
|
||||
action = "config.py"
|
||||
configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
format = 'cfg'
|
||||
servers = sql.get_dick_permit()
|
||||
keepalived = 0
|
||||
|
||||
if serv is not None:
|
||||
cfg = configs_dir + serv + "-" + funct.get_data('config') + "."+format
|
||||
|
@ -53,13 +57,19 @@ if serv is not None and form.getvalue('open') is not None :
|
|||
if service == 'keepalived':
|
||||
error = funct.get_config(serv, cfg, keepalived=1)
|
||||
try:
|
||||
funct.logging(serv, "keepalivedconfig.py open config")
|
||||
funct.logging(serv, " Keepalived config has opened for ")
|
||||
except:
|
||||
pass
|
||||
elif service == 'nginx':
|
||||
error = funct.get_config(serv, cfg, nginx=1)
|
||||
try:
|
||||
funct.logging(serv, " Nginx config has opened ")
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
error = funct.get_config(serv, cfg)
|
||||
try:
|
||||
funct.logging(serv, "config.py open config")
|
||||
funct.logging(serv, " HAProxy config has opened ")
|
||||
except:
|
||||
pass
|
||||
|
||||
|
@ -90,6 +100,8 @@ if serv is not None and form.getvalue('config') is not None:
|
|||
|
||||
if service == 'keepalived':
|
||||
stderr = funct.upload_and_restart(serv, cfg, just_save=save, keepalived=1)
|
||||
elif service == 'nginx':
|
||||
stderr = funct.master_slave_upload_and_restart(serv, cfg, just_save=save, nginx=1)
|
||||
else:
|
||||
stderr = funct.master_slave_upload_and_restart(serv, cfg, just_save=save)
|
||||
|
||||
|
@ -112,6 +124,6 @@ template = template.render(h2 = 1, title = title,
|
|||
error = error,
|
||||
note = 1,
|
||||
versions = funct.versions(),
|
||||
keepalived = keepalived,
|
||||
service = service,
|
||||
token = token)
|
||||
print(template)
|
||||
|
|
|
@ -165,7 +165,10 @@ def update_db_v_31(**kwargs):
|
|||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('proxy', '', 'main', 'Proxy server. Use proto://ip:port');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('session_ttl', '5', 'main', 'Time to live users sessions. In days');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('token_ttl', '5', 'main', 'Time to live users tokens. In days');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('local_path_logs', '/var/log/haproxy.log', 'logs', 'Logs save locally, disable by default');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('tmp_config_path', '/tmp/', 'main', 'Temp store configs, for check');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('cert_path', '/etc/ssl/certs/', 'main', 'Path to SSL dir');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('lists_path', 'lists', 'main', 'Path to black/white lists. This is a relative path, begins with $HOME_HAPROXY-WI');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('local_path_logs', '/var/log/haproxy.log', 'logs', 'Logs save locally, enabled by default');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('syslog_server_enable', '0', 'logs', 'If exist syslog server for HAproxy logs, enable this option');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('syslog_server', '0', 'logs', 'IP address syslog server');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('log_time_storage', '14', 'logs', 'Time of storage of logs of user activity, in days');")
|
||||
|
@ -181,10 +184,7 @@ def update_db_v_31(**kwargs):
|
|||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('server_state_file', '/etc/haproxy/haproxy.state', 'haproxy', 'Path to HAProxy state file');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('haproxy_sock', '/var/run/haproxy.sock', 'haproxy', 'Path to HAProxy sock file');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('haproxy_sock_port', '1999', 'haproxy', 'HAProxy sock port');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('tmp_config_path', '/tmp/', 'haproxy', 'Temp store configs, for haproxy check');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('cert_path', '/etc/ssl/certs/', 'haproxy', 'Path to SSL dir');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('firewall_enable', '0', 'haproxy', 'If enable this option Haproxy-wi will be configure firewalld based on config port');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('lists_path', 'lists', 'main', 'Path to black/white lists. This is a relative path, begins with $HOME_HAPROXY-WI');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('apache_log_path', '/var/log/httpd/', 'logs', 'Path to Apache logs');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('ldap_enable', '0', 'ldap', 'If 1 ldap enabled');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('ldap_server', '', 'ldap', 'IP address ldap server');")
|
||||
|
@ -371,12 +371,85 @@ def update_db_v_3_13(**kwargs):
|
|||
except sqltool.Error as e:
|
||||
if kwargs.get('silent') != 1:
|
||||
if e.args[0] == 'duplicate column name: keepalived' or e == " 1060 (42S21): Duplicate column name 'keepalived' ":
|
||||
print('DB was update to 3.13.0')
|
||||
print('Updating... go to version 4.0.0')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
return False
|
||||
else:
|
||||
print("DB was update to 3.13.0")
|
||||
print("Updating... go to version 4.0.0")
|
||||
return True
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def update_db_v_4(**kwargs):
|
||||
con, cur = get_cur()
|
||||
sql = list()
|
||||
sql.append("update settings set section = 'main', `desc` = 'Temp store configs, for check' where param = 'tmp_config_path';")
|
||||
sql.append("update settings set section = 'main' where param = 'cert_path';")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_path_error_logs', '/var/log/nginx/error.log', 'nginx', 'Nginx error log');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_stats_user', 'admin', 'nginx', 'Username for Stats web page Nginx');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_stats_password', 'password', 'nginx', 'Password for Stats web page Nginx');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_stats_port', '8086', 'nginx', 'Stats port for web page Nginx');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_stats_page', 'stats', 'nginx', 'URI Stats for web page Nginx');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_restart_command', 'systemctl restart nginx', 'nginx', 'Command for restart Nginx service');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_reload_command', 'systemctl reload nginx', 'nginx', 'Command for reload Nginx service');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_status_command', 'systemctl status nginx', 'nginx', 'Command for status check Nginx service');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_dir', '/etc/nginx/conf.d/', 'nginx', 'Path to Nginx dir');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_config_path', '/etc/nginx/conf.d/default.conf', 'nginx', 'Path to Nginx config');")
|
||||
for i in sql:
|
||||
try:
|
||||
cur.execute(i)
|
||||
con.commit()
|
||||
except sqltool.Error as e:
|
||||
pass
|
||||
else:
|
||||
if kwargs.get('silent') != 1:
|
||||
print('Updating... one more for version 4.0.0')
|
||||
return True
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def update_db_v_41(**kwargs):
|
||||
con, cur = get_cur()
|
||||
sql = """
|
||||
ALTER TABLE `servers` ADD COLUMN nginx INTEGER NOT NULL DEFAULT 0;
|
||||
"""
|
||||
try:
|
||||
cur.execute(sql)
|
||||
con.commit()
|
||||
except sqltool.Error as e:
|
||||
if kwargs.get('silent') != 1:
|
||||
if e.args[0] == 'duplicate column name: nginx' or e == " 1060 (42S21): Duplicate column name 'nginx' ":
|
||||
print('Updating... one more for version 4.0.0')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
return False
|
||||
else:
|
||||
print("Updating... one more for version 4.0.0")
|
||||
return True
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def update_db_v_42(**kwargs):
|
||||
con, cur = get_cur()
|
||||
sql = """
|
||||
ALTER TABLE `servers` ADD COLUMN haproxy INTEGER NOT NULL DEFAULT 0;
|
||||
"""
|
||||
try:
|
||||
cur.execute(sql)
|
||||
con.commit()
|
||||
except sqltool.Error as e:
|
||||
if kwargs.get('silent') != 1:
|
||||
if e.args[0] == 'duplicate column name: nginx' or e == " 1060 (42S21): Duplicate column name 'nginx' ":
|
||||
print('DB was update to 4.0.0')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
return False
|
||||
else:
|
||||
print("DB was update to 4.0.0")
|
||||
return True
|
||||
cur.close()
|
||||
con.close()
|
||||
|
@ -384,7 +457,7 @@ def update_db_v_3_13(**kwargs):
|
|||
|
||||
def update_ver(**kwargs):
|
||||
con, cur = get_cur()
|
||||
sql = """update version set version = '3.13.0.0'; """
|
||||
sql = """update version set version = '4.0.0.0'; """
|
||||
try:
|
||||
cur.execute(sql)
|
||||
con.commit()
|
||||
|
@ -406,6 +479,9 @@ def update_all():
|
|||
update_db_v_3_12()
|
||||
update_db_v_3_12_1()
|
||||
update_db_v_3_13()
|
||||
update_db_v_4()
|
||||
update_db_v_41()
|
||||
update_db_v_42()
|
||||
update_ver()
|
||||
|
||||
|
||||
|
@ -421,6 +497,9 @@ def update_all_silent():
|
|||
update_db_v_3_12(silent=1)
|
||||
update_db_v_3_12_1(silent=1)
|
||||
update_db_v_3_13(silent=1)
|
||||
update_db_v_4(silent=1)
|
||||
update_db_v_41(silent=1)
|
||||
update_db_v_42(silent=1)
|
||||
update_ver()
|
||||
|
||||
|
||||
|
|
107
app/funct.py
|
@ -47,7 +47,6 @@ def logging(serv, action, **kwargs):
|
|||
import sql
|
||||
import http.cookies
|
||||
log_path = get_config_var('main', 'log_path')
|
||||
login = ''
|
||||
|
||||
if not os.path.exists(log_path):
|
||||
os.makedirs(log_path)
|
||||
|
@ -76,7 +75,7 @@ def logging(serv, action, **kwargs):
|
|||
if kwargs.get('login'):
|
||||
mess = get_data('date_in_log') + " from " + IP + " user: " + login + " " + action + " for: " + serv + "\n"
|
||||
else:
|
||||
mess = get_data('date_in_log') + action + "\n"
|
||||
mess = get_data('date_in_log') + action + " from " + IP + "\n"
|
||||
log = open(log_path + "/haproxy-wi-"+get_data('logs')+".log", "a")
|
||||
else:
|
||||
mess = get_data('date_in_log') + " from " + IP + " user: " + login + " " + action + " for: " + serv + "\n"
|
||||
|
@ -230,17 +229,23 @@ def ssh_connect(serv, **kwargs):
|
|||
|
||||
def get_config(serv, cfg, **kwargs):
|
||||
import sql
|
||||
|
||||
config_path = "/etc/keepalived/keepalived.conf" if kwargs.get("keepalived") else sql.get_setting('haproxy_config_path')
|
||||
|
||||
if kwargs.get("keepalived"):
|
||||
config_path = "/etc/keepalived/keepalived.conf"
|
||||
elif kwargs.get("nginx"):
|
||||
config_path = sql.get_setting('nginx_config_path')
|
||||
else:
|
||||
config_path = sql.get_setting('haproxy_config_path')
|
||||
|
||||
ssh = ssh_connect(serv)
|
||||
try:
|
||||
sftp = ssh.open_sftp()
|
||||
except Exception as e:
|
||||
logging('localhost', ssh, haproxywi=1)
|
||||
logging('localhost', str(e), haproxywi=1)
|
||||
try:
|
||||
sftp.get(config_path, cfg)
|
||||
except Exception as e:
|
||||
logging('localhost', ssh, haproxywi=1)
|
||||
logging('localhost', str(e), haproxywi=1)
|
||||
try:
|
||||
sftp.close()
|
||||
ssh.close()
|
||||
|
@ -409,6 +414,7 @@ def install_haproxy(serv, **kwargs):
|
|||
print('success: HAProxy was installed<br>')
|
||||
|
||||
os.system("rm -f %s" % script)
|
||||
sql.update_haproxy(serv)
|
||||
|
||||
|
||||
def waf_install(serv, **kwargs):
|
||||
|
@ -439,6 +445,56 @@ def waf_install(serv, **kwargs):
|
|||
if stderr is None:
|
||||
sql.insert_waf_metrics_enable(serv, "0")
|
||||
|
||||
|
||||
def install_nginx(serv):
|
||||
import sql
|
||||
script = "install_nginx.sh"
|
||||
stats_user = sql.get_setting('nginx_stats_user')
|
||||
stats_password = sql.get_setting('nginx_stats_password')
|
||||
stats_port = sql.get_setting('nginx_stats_port')
|
||||
stats_page = sql.get_setting('nginx_stats_page')
|
||||
config_path = sql.get_setting('nginx_config_path')
|
||||
proxy = sql.get_setting('proxy')
|
||||
ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name = return_ssh_keys_path(serv)
|
||||
|
||||
if ssh_enable == 0:
|
||||
ssh_key_name = ''
|
||||
|
||||
os.system("cp scripts/%s ." % script)
|
||||
|
||||
if proxy is not None and proxy != '' and proxy != 'None':
|
||||
proxy_serv = proxy
|
||||
else:
|
||||
proxy_serv = ''
|
||||
|
||||
syn_flood_protect = '1' if form.getvalue('syn_flood') == "1" else ''
|
||||
|
||||
commands = [ "chmod +x "+script +" && ./"+script +" PROXY=" + proxy_serv+" STATS_USER="+stats_user+" STATS_PASS="+stats_password+
|
||||
" CONFIG_PATH="+config_path+" STAT_PORT="+stats_port+" STAT_PAGE="+stats_page+" SYN_FLOOD="+syn_flood_protect+" HOST="+serv+
|
||||
" USER="+ssh_user_name+" PASS="+ssh_user_password+" KEY="+ssh_key_name ]
|
||||
|
||||
output, error = subprocess_execute(commands[0])
|
||||
|
||||
if error:
|
||||
logging('localhost', error, haproxywi=1)
|
||||
print('error: '+error)
|
||||
else:
|
||||
for l in output:
|
||||
if "msg" in l or "FAILED" in l:
|
||||
try:
|
||||
l = l.split(':')[1]
|
||||
l = l.split('"')[1]
|
||||
print(l+"<br>")
|
||||
break
|
||||
except:
|
||||
print(output)
|
||||
break
|
||||
else:
|
||||
print('success: Nginx was installed<br>')
|
||||
|
||||
os.system("rm -f %s" % script)
|
||||
sql.update_nginx(serv)
|
||||
|
||||
|
||||
def update_haproxy_wi():
|
||||
cmd = 'sudo -S yum -y update haproxy-wi'
|
||||
|
@ -495,7 +551,13 @@ def upload(serv, path, file, **kwargs):
|
|||
|
||||
def upload_and_restart(serv, cfg, **kwargs):
|
||||
import sql
|
||||
tmp_file = sql.get_setting('tmp_config_path') + "/" + get_data('config') + ".cfg"
|
||||
|
||||
if kwargs.get("nginx"):
|
||||
config_path = sql.get_setting('nginx_config_path')
|
||||
tmp_file = sql.get_setting('tmp_config_path') + "/" + get_data('config') + ".conf"
|
||||
else:
|
||||
config_path = sql.get_setting('haproxy_config_path')
|
||||
tmp_file = sql.get_setting('tmp_config_path') + "/" + get_data('config') + ".cfg"
|
||||
error = ""
|
||||
|
||||
try:
|
||||
|
@ -509,15 +571,22 @@ def upload_and_restart(serv, cfg, **kwargs):
|
|||
commands = [ "sudo mv -f " + tmp_file + " /etc/keepalived/keepalived.conf" ]
|
||||
else:
|
||||
commands = [ "sudo mv -f " + tmp_file + " /etc/keepalived/keepalived.conf && sudo systemctl restart keepalived" ]
|
||||
elif kwargs.get("nginx"):
|
||||
if kwargs.get("just_save") == "save":
|
||||
commands = [ "sudo mv -f " + tmp_file + " " + config_path + " && sudo nginx -t -q"]
|
||||
elif kwargs.get("just_save") == "reload":
|
||||
commands = [ "sudo mv -f " + tmp_file + " " + config_path + " && sudo nginx -t -q && sudo " + sql.get_setting('nginx_reload_command') ]
|
||||
else:
|
||||
commands = [ "sudo mv -f " + tmp_file + " " + config_path + " && sudo nginx -t -q && sudo " + sql.get_setting('nginx_restart_command') ]
|
||||
else:
|
||||
if kwargs.get("just_save") == "test":
|
||||
commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo rm -f " + tmp_file ]
|
||||
elif kwargs.get("just_save") == "save":
|
||||
commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + sql.get_setting('haproxy_config_path') ]
|
||||
commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + config_path ]
|
||||
elif kwargs.get("just_save") == "reload":
|
||||
commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + sql.get_setting('haproxy_config_path') + " && sudo " + sql.get_setting('reload_command') ]
|
||||
commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + config_path + " && sudo " + sql.get_setting('reload_command') ]
|
||||
else:
|
||||
commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + sql.get_setting('haproxy_config_path') + " && sudo " + sql.get_setting('restart_command') ]
|
||||
commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + config_path + " && sudo " + sql.get_setting('restart_command') ]
|
||||
if sql.get_setting('firewall_enable') == "1":
|
||||
commands.extend(open_port_firewalld(cfg))
|
||||
error += str(upload(serv, tmp_file, cfg, dir='fullpath'))
|
||||
|
@ -538,9 +607,9 @@ def master_slave_upload_and_restart(serv, cfg, just_save, **kwargs):
|
|||
error = ""
|
||||
for master in MASTERS:
|
||||
if master[0] != None:
|
||||
error += upload_and_restart(master[0], cfg, just_save=just_save)
|
||||
error += upload_and_restart(master[0], cfg, just_save=just_save, nginx=kwargs.get('nginx'))
|
||||
|
||||
error += upload_and_restart(serv, cfg, just_save=just_save)
|
||||
error += upload_and_restart(serv, cfg, just_save=just_save, nginx=kwargs.get('nginx'))
|
||||
|
||||
return error
|
||||
|
||||
|
@ -592,7 +661,7 @@ def show_log(stdout, **kwargs):
|
|||
return out
|
||||
|
||||
|
||||
def show_haproxy_log(serv, rows=10, waf='0', grep=None, hour='00', minut='00', hour1='24', minut1='00', **kwargs):
|
||||
def show_haproxy_log(serv, rows=10, waf='0', grep=None, hour='00', minut='00', hour1='24', minut1='00', service='haproxy', **kwargs):
|
||||
import sql
|
||||
date = hour+':'+minut
|
||||
date1 = hour1+':'+minut1
|
||||
|
@ -604,9 +673,15 @@ def show_haproxy_log(serv, rows=10, waf='0', grep=None, hour='00', minut='00', h
|
|||
|
||||
syslog_server_enable = sql.get_setting('syslog_server_enable')
|
||||
if syslog_server_enable is None or syslog_server_enable == "0":
|
||||
local_path_logs = sql.get_setting('local_path_logs')
|
||||
if service == 'nginx':
|
||||
local_path_logs = sql.get_setting('nginx_path_error_logs')
|
||||
commands = [ "sudo cat %s| awk '$2>\"%s:00\" && $2<\"%s:00\"' |tail -%s %s %s" % (local_path_logs, date, date1, rows, grep_act, grep) ]
|
||||
else:
|
||||
local_path_logs = sql.get_setting('local_path_logs')
|
||||
commands = [ "sudo cat %s| awk '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % (local_path_logs, date, date1, rows, grep_act, grep) ]
|
||||
syslog_server = serv
|
||||
commands = [ "sudo cat %s| awk '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % (local_path_logs, date, date1, rows, grep_act, grep) ]
|
||||
|
||||
|
||||
else:
|
||||
commands = [ "sudo cat /var/log/%s/syslog.log | sed '/ %s:00/,/ %s:00/! d' |tail -%s %s %s" % (serv, date, date1, rows, grep_act, grep) ]
|
||||
syslog_server = sql.get_setting('syslog_server')
|
||||
|
@ -614,7 +689,7 @@ def show_haproxy_log(serv, rows=10, waf='0', grep=None, hour='00', minut='00', h
|
|||
if waf == "1":
|
||||
local_path_logs = '/var/log/modsec_audit.log'
|
||||
commands = [ "sudo cat %s |tail -%s %s %s" % (local_path_logs, rows, grep_act, grep) ]
|
||||
|
||||
logging('localhost', str(commands), haproxywi=1)
|
||||
|
||||
if kwargs.get('html') == 0:
|
||||
a = ssh_command(syslog_server, commands)
|
||||
|
|
|
@ -7,6 +7,7 @@ log_path = ${fullpath}/log/
|
|||
#Dir where configs will be save
|
||||
haproxy_save_configs_dir = ${main:fullpath}/configs/hap_config/
|
||||
kp_save_configs_dir = ${main:fullpath}/configs/kp_config/
|
||||
nginx_save_configs_dir = ${main:fullpath}/configs/nginx_config/
|
||||
|
||||
[mysql]
|
||||
#Enable MySQL DB. Default will be used Sqlite DB. Default disable
|
||||
|
|
|
@ -16,38 +16,60 @@ try:
|
|||
users = sql.select_users()
|
||||
groups = sql.select_groups()
|
||||
token = sql.get_token(user_id.value)
|
||||
cmd = "ps ax |grep -e 'keep_alive.py' |grep -v grep |wc -l"
|
||||
keep_alive, stderr = funct.subprocess_execute(cmd)
|
||||
except:
|
||||
pass
|
||||
|
||||
form = funct.form
|
||||
serv = form.getvalue('serv')
|
||||
service = form.getvalue('service')
|
||||
autorefresh = 0
|
||||
|
||||
if serv:
|
||||
servers = sql.select_servers(server=serv)
|
||||
autorefresh = 1
|
||||
if service == 'nginx':
|
||||
title = "Nginx servers overview"
|
||||
keep_alive = ''
|
||||
stderr = ''
|
||||
servers = sql.get_dick_permit(virt=1, nginx=1)
|
||||
service = 'nginx'
|
||||
else:
|
||||
servers = sql.get_dick_permit()
|
||||
autorefresh = 0
|
||||
title = "HAProxy servers overview"
|
||||
cmd = "ps ax |grep -e 'keep_alive.py' |grep -v grep |wc -l"
|
||||
keep_alive, stderr = funct.subprocess_execute(cmd)
|
||||
service = 'haproxy'
|
||||
if serv:
|
||||
servers = sql.select_servers(server=serv)
|
||||
autorefresh = 1
|
||||
else:
|
||||
servers = sql.get_dick_permit(virt=1, haproxy=1)
|
||||
|
||||
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
|
||||
servers_with_status1 = []
|
||||
out1 = ""
|
||||
out1 = ''
|
||||
for s in servers:
|
||||
servers_with_status = list()
|
||||
cmd = 'echo "show info" |nc %s %s -w 1 |grep -e "Ver\|Uptime:\|Process_num"' % (s[2], haproxy_sock_port)
|
||||
out = funct.subprocess_execute(cmd)
|
||||
servers_with_status.append(s[0])
|
||||
servers_with_status.append(s[1])
|
||||
servers_with_status.append(s[2])
|
||||
servers_with_status.append(s[11])
|
||||
for k in out:
|
||||
if "Ncat:" not in k:
|
||||
out1 = out
|
||||
else:
|
||||
out1 = False
|
||||
servers_with_status.append(out1)
|
||||
if service == 'nginx':
|
||||
cmd = [ "/usr/sbin/nginx -v && systemctl status nginx |grep -e 'Active\|Tasks' |awk '{print $2, $9$10$11$12$13}'" ]
|
||||
out = funct.ssh_command(s[2], cmd)
|
||||
h = ()
|
||||
out1 = []
|
||||
for k in out.split():
|
||||
out1.append(k)
|
||||
h = (out1, )
|
||||
servers_with_status.append(h)
|
||||
servers_with_status.append(h)
|
||||
else:
|
||||
cmd = 'echo "show info" |nc %s %s -w 1 |grep -e "Ver\|Uptime:\|Process_num"' % (s[2], haproxy_sock_port)
|
||||
out = funct.subprocess_execute(cmd)
|
||||
for k in out:
|
||||
if "Ncat:" not in k:
|
||||
out1 = out
|
||||
else:
|
||||
out1 = False
|
||||
servers_with_status.append(out1)
|
||||
|
||||
servers_with_status.append(s[12])
|
||||
servers_with_status.append(sql.is_master(s[2]))
|
||||
servers_with_status.append(sql.select_servers(server=s[2]))
|
||||
|
@ -57,7 +79,7 @@ for s in servers:
|
|||
|
||||
template = template.render(h2 = 1,
|
||||
autorefresh = autorefresh,
|
||||
title = "HAProxy servers overview",
|
||||
title = title,
|
||||
role = sql.get_user_role_by_uuid(user_id.value),
|
||||
user = user,
|
||||
users = users,
|
||||
|
@ -66,5 +88,6 @@ template = template.render(h2 = 1,
|
|||
versions = funct.versions(),
|
||||
keep_alive = ''.join(keep_alive),
|
||||
serv = serv,
|
||||
service = service,
|
||||
token = token)
|
||||
print(template)
|
||||
|
|
44
app/logs.py
|
@ -24,6 +24,7 @@ hour1 = form.getvalue('hour1')
|
|||
minut = form.getvalue('minut')
|
||||
minut1 = form.getvalue('minut1')
|
||||
waf = form.getvalue('waf')
|
||||
service = form.getvalue('service')
|
||||
|
||||
print('Content-type: text/html\n')
|
||||
funct.check_login()
|
||||
|
@ -37,26 +38,31 @@ try:
|
|||
except:
|
||||
pass
|
||||
|
||||
if service == 'nginx':
|
||||
title = "Nginx`s logs"
|
||||
else:
|
||||
title = "HAProxy`s logs"
|
||||
|
||||
output_from_parsed_template = template.render(h2 = 1,
|
||||
autorefresh = 1,
|
||||
title = "HAProxy`s logs",
|
||||
role = sql.get_user_role_by_uuid(user_id.value),
|
||||
user = user,
|
||||
onclick = "showLog()",
|
||||
select_id = "serv",
|
||||
selects = servers,
|
||||
serv = form.getvalue('serv'),
|
||||
rows = rows,
|
||||
grep = grep,
|
||||
hour = hour,
|
||||
hour1 = hour1,
|
||||
minut = minut,
|
||||
minut1 = minut1,
|
||||
waf = waf,
|
||||
versions = funct.versions(),
|
||||
token = token)
|
||||
print(output_from_parsed_template)
|
||||
template = template.render(h2 = 1,
|
||||
autorefresh = 1,
|
||||
title = title,
|
||||
role = sql.get_user_role_by_uuid(user_id.value),
|
||||
user = user,
|
||||
onclick = "showLog()",
|
||||
select_id = "serv",
|
||||
selects = servers,
|
||||
serv = form.getvalue('serv'),
|
||||
rows = rows,
|
||||
grep = grep,
|
||||
hour = hour,
|
||||
hour1 = hour1,
|
||||
minut = minut,
|
||||
minut1 = minut1,
|
||||
waf = waf,
|
||||
versions = funct.versions(),
|
||||
service = service,
|
||||
token = token)
|
||||
print(template)
|
||||
|
||||
|
||||
|
||||
|
|
131
app/options.py
|
@ -50,7 +50,6 @@ if form.getvalue('getcert') is not None and serv is not None:
|
|||
|
||||
|
||||
if serv and form.getvalue('ssl_cert'):
|
||||
#cert_local_dir = funct.get_config_var('main', 'cert_local_dir')
|
||||
cert_local_dir = os.path.dirname(os.getcwd())+"/"+sql.get_setting('ssl_local_path')
|
||||
cert_path = sql.get_setting('cert_path')
|
||||
|
||||
|
@ -111,6 +110,18 @@ if form.getvalue('action_hap') is not None and serv is not None:
|
|||
else:
|
||||
print("Bad config, check please")
|
||||
|
||||
|
||||
if form.getvalue('action_nginx') is not None and serv is not None:
|
||||
action = form.getvalue('action_nginx')
|
||||
|
||||
if funct.check_haproxy_config(serv):
|
||||
commands = [ "sudo systemctl %s nginx" % action ]
|
||||
funct.ssh_command(serv, commands)
|
||||
funct.logging(serv, 'Nginx was '+action, haproxywi=1, login=1)
|
||||
print("Nginx was %s" % action)
|
||||
else:
|
||||
print("Bad config, check please")
|
||||
|
||||
|
||||
if form.getvalue('action_waf') is not None and serv is not None:
|
||||
serv = form.getvalue('serv')
|
||||
|
@ -148,8 +159,11 @@ if act == "overviewHapserverBackends":
|
|||
|
||||
|
||||
if act == "overviewHapservers":
|
||||
haproxy_config_path = sql.get_setting('haproxy_config_path')
|
||||
commands = [ "ls -l %s |awk '{ print $6\" \"$7\" \"$8}'" % haproxy_config_path ]
|
||||
if form.getvalue('service') == 'nginx':
|
||||
config_path = sql.get_setting('nginx_config_path')
|
||||
else:
|
||||
config_path = sql.get_setting('haproxy_config_path')
|
||||
commands = [ "ls -l %s |awk '{ print $6\" \"$7\" \"$8}'" % config_path ]
|
||||
try:
|
||||
print(funct.ssh_command(serv, commands))
|
||||
except:
|
||||
|
@ -168,14 +182,22 @@ if act == "overview":
|
|||
keepalived_process = funct.ssh_command(serv2, command)
|
||||
else:
|
||||
keepalived_process = ''
|
||||
nginx = sql.select_nginx(serv2)
|
||||
if nginx == 1:
|
||||
command = [ "ps ax |grep nginx:|grep -v grep|wc -l" ]
|
||||
nginx_process = funct.ssh_command(serv2, command)
|
||||
else:
|
||||
nginx_process = ''
|
||||
server_status = (serv1,
|
||||
serv2,
|
||||
funct.server_status(funct.subprocess_execute(cmd)),
|
||||
sql.select_servers(server=serv2, keep_alive=1),
|
||||
funct.ssh_command(serv2, commands2),
|
||||
sql.select_waf_servers(serv2),
|
||||
sql.select_keealived(serv2),
|
||||
keepalived_process)
|
||||
keepalived,
|
||||
keepalived_process,
|
||||
nginx,
|
||||
nginx_process)
|
||||
return server_status
|
||||
|
||||
|
||||
|
@ -290,7 +312,7 @@ if act == "overviewHapwi":
|
|||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
|
||||
template = env.get_template('/overviewHapwi.html')
|
||||
cmd = "top -b -n 1 |head -9"
|
||||
cmd = "top -b -n 1 |head -12"
|
||||
server_status, stderr = funct.subprocess_execute(cmd)
|
||||
|
||||
template = template.render(server_status=server_status,stderr=stderr)
|
||||
|
@ -324,10 +346,16 @@ if form.getvalue('action'):
|
|||
if serv is not None and act == "stats":
|
||||
import requests
|
||||
|
||||
haproxy_user = sql.get_setting('stats_user')
|
||||
haproxy_pass = sql.get_setting('stats_password')
|
||||
stats_port = sql.get_setting('stats_port')
|
||||
stats_page = sql.get_setting('stats_page')
|
||||
if form.getvalue('service') == 'nginx':
|
||||
haproxy_user = sql.get_setting('nginx_stats_user')
|
||||
haproxy_pass = sql.get_setting('nginx_stats_password')
|
||||
stats_port = sql.get_setting('nginx_stats_port')
|
||||
stats_page = sql.get_setting('nginx_stats_page')
|
||||
else:
|
||||
haproxy_user = sql.get_setting('stats_user')
|
||||
haproxy_pass = sql.get_setting('stats_password')
|
||||
stats_port = sql.get_setting('stats_port')
|
||||
stats_page = sql.get_setting('stats_page')
|
||||
try:
|
||||
response = requests.get('http://%s:%s/%s' % (serv, stats_port, stats_page), auth=(haproxy_user, haproxy_pass))
|
||||
except requests.exceptions.ConnectTimeout:
|
||||
|
@ -344,7 +372,25 @@ if serv is not None and act == "stats":
|
|||
print ("OOps: Something Else",err)
|
||||
|
||||
data = response.content
|
||||
print(data.decode('utf-8'))
|
||||
if form.getvalue('service') == 'nginx':
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/'))
|
||||
template = env.get_template('ajax/nginx_stats.html')
|
||||
|
||||
servers_with_status = list()
|
||||
h = ()
|
||||
out1 = []
|
||||
for k in data.decode('utf-8').split():
|
||||
out1.append(k)
|
||||
h = (out1, )
|
||||
servers_with_status.append(h)
|
||||
|
||||
template = template.render(out=servers_with_status)
|
||||
print(template)
|
||||
|
||||
|
||||
else:
|
||||
print(data.decode('utf-8'))
|
||||
|
||||
|
||||
if serv is not None and form.getvalue('rows') is not None:
|
||||
|
@ -355,7 +401,8 @@ if serv is not None and form.getvalue('rows') is not None:
|
|||
minut = form.getvalue('minut')
|
||||
hour1 = form.getvalue('hour1')
|
||||
minut1 = form.getvalue('minut1')
|
||||
out = funct.show_haproxy_log(serv, rows=rows, waf=waf, grep=grep, hour=hour, minut=minut, hour1=hour1, minut1=minut1)
|
||||
service = form.getvalue('service')
|
||||
out = funct.show_haproxy_log(serv, rows=rows, waf=waf, grep=grep, hour=hour, minut=minut, hour1=hour1, minut1=minut1, service=service)
|
||||
print(out)
|
||||
|
||||
|
||||
|
@ -550,7 +597,12 @@ if act == "showCompareConfigs":
|
|||
left = form.getvalue('left')
|
||||
right = form.getvalue('right')
|
||||
|
||||
template = template.render(serv=serv, right=right, left=left, return_files=funct.get_files())
|
||||
if form.getvalue('service') == 'nginx':
|
||||
return_files=funct.get_files(funct.get_config_var('configs', 'nginx_save_configs_dir'), 'conf')
|
||||
else:
|
||||
return_files=funct.get_files()
|
||||
|
||||
template = template.render(serv=serv, right=right, left=left, return_files=return_files)
|
||||
print(template)
|
||||
|
||||
|
||||
|
@ -558,8 +610,11 @@ if serv is not None and form.getvalue('right') is not None:
|
|||
from jinja2 import Environment, FileSystemLoader
|
||||
left = form.getvalue('left')
|
||||
right = form.getvalue('right')
|
||||
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
cmd='diff -ub %s%s %s%s' % (hap_configs_dir, left, hap_configs_dir, right)
|
||||
if form.getvalue('service') == 'nginx':
|
||||
configs_dir = funct.get_config_var('configs', 'nginx_save_configs_dir')
|
||||
else:
|
||||
configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
cmd='diff -ub %s%s %s%s' % (configs_dir, left, configs_dir, right)
|
||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True, extensions=["jinja2.ext.loopcontrols", "jinja2.ext.do"])
|
||||
template = env.get_template('ajax/compare.html')
|
||||
|
||||
|
@ -573,6 +628,8 @@ if serv is not None and form.getvalue('right') is not None:
|
|||
if serv is not None and act == "configShow":
|
||||
if form.getvalue('service') == 'keepalived':
|
||||
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
||||
elif form.getvalue('service') == 'nginx':
|
||||
configs_dir = funct.get_config_var('configs', 'nginx_save_configs_dir')
|
||||
else:
|
||||
configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
|
||||
|
@ -581,11 +638,10 @@ if serv is not None and act == "configShow":
|
|||
funct.get_config(serv, cfg)
|
||||
else:
|
||||
cfg = configs_dir + form.getvalue('configver')
|
||||
|
||||
try:
|
||||
conf = open(cfg, "r")
|
||||
except IOError:
|
||||
print('<div class="alert alert-danger">Can\'t read import config file</div>')
|
||||
print('<div class="alert alert-danger">Can\'t read config file</div>')
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True, trim_blocks=True, lstrip_blocks=True, extensions=["jinja2.ext.loopcontrols", "jinja2.ext.do"])
|
||||
|
@ -627,6 +683,10 @@ if form.getvalue('master'):
|
|||
funct.install_haproxy(master)
|
||||
funct.install_haproxy(slave)
|
||||
|
||||
if form.getvalue('nginx') == "1":
|
||||
funct.install_nginx(master)
|
||||
funct.install_nginx(slave)
|
||||
|
||||
commands = [ "chmod +x "+script +" && ./"+script +" PROXY=" + proxy_serv+
|
||||
" ETH="+ETH+" IP="+str(IP)+" MASTER=MASTER"+" SYN_FLOOD="+syn_flood+" HOST="+str(master)+
|
||||
" USER="+str(ssh_user_name)+" PASS="+str(ssh_user_password)+" KEY="+str(ssh_key_name) ]
|
||||
|
@ -827,6 +887,10 @@ if form.getvalue('backup') or form.getvalue('deljob') or form.getvalue('backupup
|
|||
print('Ok')
|
||||
funct.logging('backup ', ' has updated a backup job for server '+server, haproxywi=1, login=1)
|
||||
|
||||
|
||||
if form.getvalue('install_nginx'):
|
||||
funct.install_nginx(form.getvalue('install_nginx'))
|
||||
|
||||
|
||||
if form.getvalue('haproxyaddserv'):
|
||||
funct.install_haproxy(form.getvalue('haproxyaddserv'), syn_flood=form.getvalue('syn_flood'), hapver=form.getvalue('hapver'))
|
||||
|
@ -916,6 +980,11 @@ if form.getvalue('get_hap_v'):
|
|||
print(output)
|
||||
|
||||
|
||||
if form.getvalue('get_nginx_v'):
|
||||
cmd = [ "/usr/sbin/nginx -v" ]
|
||||
print(funct.ssh_command(serv, cmd))
|
||||
|
||||
|
||||
if form.getvalue('bwlists'):
|
||||
list = os.path.dirname(os.getcwd())+"/"+sql.get_setting('lists_path')+"/"+form.getvalue('group')+"/"+form.getvalue('color')+"/"+form.getvalue('bwlists')
|
||||
try:
|
||||
|
@ -1090,18 +1159,17 @@ if form.getvalue('newserver') is not None:
|
|||
ip = form.getvalue('newip')
|
||||
group = form.getvalue('newservergroup')
|
||||
typeip = form.getvalue('typeip')
|
||||
haproxy = form.getvalue('haproxy')
|
||||
nginx = form.getvalue('nginx')
|
||||
enable = form.getvalue('enable')
|
||||
master = form.getvalue('slave')
|
||||
cred = form.getvalue('cred')
|
||||
alert = form.getvalue('alert_en')
|
||||
metrics = form.getvalue('metrics')
|
||||
page = form.getvalue('page')
|
||||
page = page.split("#")[0]
|
||||
port = form.getvalue('newport')
|
||||
desc = form.getvalue('desc')
|
||||
active = form.getvalue('active')
|
||||
desc = form.getvalue('desc')
|
||||
|
||||
if sql.add_server(hostname, ip, group, typeip, enable, master, cred, alert, metrics, port, desc, active):
|
||||
if sql.add_server(hostname, ip, group, typeip, enable, master, cred, port, desc, haproxy, nginx):
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/'))
|
||||
template = env.get_template('ajax/new_server.html')
|
||||
|
@ -1116,23 +1184,32 @@ if form.getvalue('newserver') is not None:
|
|||
funct.logging('a new server '+hostname, ' has created ', haproxywi=1, login=1)
|
||||
|
||||
|
||||
if form.getvalue('updatehapwiserver') is not None:
|
||||
id = form.getvalue('updatehapwiserver')
|
||||
active = form.getvalue('active')
|
||||
alert = form.getvalue('alert_en')
|
||||
metrics = form.getvalue('metrics')
|
||||
sql.update_hapwi_server(id, alert, metrics, active)
|
||||
funct.logging('the server '+name, ' has updated ', haproxywi=1, login=1)
|
||||
|
||||
|
||||
if form.getvalue('updateserver') is not None:
|
||||
name = form.getvalue('updateserver')
|
||||
group = form.getvalue('servergroup')
|
||||
typeip = form.getvalue('typeip')
|
||||
haproxy = form.getvalue('haproxy')
|
||||
nginx = form.getvalue('nginx')
|
||||
enable = form.getvalue('enable')
|
||||
master = form.getvalue('slave')
|
||||
id = form.getvalue('id')
|
||||
cred = form.getvalue('cred')
|
||||
alert = form.getvalue('alert_en')
|
||||
metrics = form.getvalue('metrics')
|
||||
cred = form.getvalue('cred')
|
||||
port = form.getvalue('port')
|
||||
desc = form.getvalue('desc')
|
||||
active = form.getvalue('active')
|
||||
|
||||
if name is None or port is None:
|
||||
print(error_mess)
|
||||
else:
|
||||
sql.update_server(name, group, typeip, enable, master, id, cred, alert, metrics, port, desc, active)
|
||||
sql.update_server(name, group, typeip, enable, master, id, cred, port, desc, haproxy, nginx)
|
||||
funct.logging('the server '+name, ' has updated ', haproxywi=1, login=1)
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
server {
|
||||
listen {{STAT_PORT}} ;
|
||||
server_name localhost;
|
||||
|
||||
location /{{STAT_PAGE}} {
|
||||
stub_status;
|
||||
auth_basic "Resticted Area";
|
||||
auth_basic_user_file /etc/nginx/status_page_passwdfile;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
#charset koi8-r;
|
||||
#access_log /var/log/nginx/host.access.log main;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
|
||||
#error_page 404 /404.html;
|
||||
|
||||
# redirect server error pages to the static page /50x.html
|
||||
#
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
|
||||
#
|
||||
#location ~ \.php$ {
|
||||
# proxy_pass http://127.0.0.1;
|
||||
#}
|
||||
|
||||
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
|
||||
#
|
||||
#location ~ \.php$ {
|
||||
# root html;
|
||||
# fastcgi_pass 127.0.0.1:9000;
|
||||
# fastcgi_index index.php;
|
||||
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
|
||||
# include fastcgi_params;
|
||||
#}
|
||||
|
||||
# deny access to .htaccess files, if Apache's document root
|
||||
# concurs with nginx's one
|
||||
#
|
||||
#location ~ /\.ht {
|
||||
# deny all;
|
||||
#}
|
||||
}
|
||||
|
|
@ -1,10 +1,4 @@
|
|||
{% if MASTER == 'BACKUP' %}
|
||||
{% set ID = '101' %}
|
||||
{% else %}
|
||||
{% set ID = '100' %}
|
||||
{% endif %}
|
||||
|
||||
vrrp_instance VI_{{ID}} {
|
||||
vrrp_instance VI_{{IP}} {
|
||||
state {{MASTER}}
|
||||
interface {{ETH}}
|
||||
virtual_router_id 101
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
- hosts: "{{ variable_host }}"
|
||||
become: yes
|
||||
become_method: sudo
|
||||
tasks:
|
||||
- name: check if Nginx is installed
|
||||
package_facts:
|
||||
manager: "auto"
|
||||
|
||||
- name: populate service facts
|
||||
service_facts:
|
||||
|
||||
- name: Creates directory
|
||||
file:
|
||||
path: /etc/nginx
|
||||
state: directory
|
||||
when: "'nginx' not in ansible_facts.packages"
|
||||
|
||||
- name: Creates directory
|
||||
file:
|
||||
path: /etc/nginx/conf.d
|
||||
state: directory
|
||||
when: "'nginx' not in ansible_facts.packages"
|
||||
|
||||
- name: Install passlib
|
||||
package:
|
||||
name: python-passlib
|
||||
state: present
|
||||
when: "'nginx' not in ansible_facts.packages"
|
||||
environment:
|
||||
http_proxy: "{{PROXY}}"
|
||||
https_proxy: "{{PROXY}}"
|
||||
|
||||
- name: Copy Nginx configuration in place.
|
||||
template:
|
||||
src: ./default.conf.j2
|
||||
dest: "{{CONFIG_PATH}}"
|
||||
mode: 0644
|
||||
when: "'nginx' not in ansible_facts.packages"
|
||||
|
||||
- htpasswd:
|
||||
path: /etc/nginx/status_page_passwdfile
|
||||
name: "{{STATS_USER}}"
|
||||
password: "{{STATS_PASS}}"
|
||||
when: "'nginx' not in ansible_facts.packages"
|
||||
|
||||
- hosts: "{{ variable_host }}"
|
||||
become: yes
|
||||
become_method: sudo
|
||||
tasks:
|
||||
- name: Add syn_flood tasks
|
||||
include: haproxy/tasks/syn_flood.yml
|
||||
when: (SYN_FLOOD is defined) and (SYN_FLOOD|length > 0)
|
||||
roles:
|
||||
- role: nginxinc.nginx
|
||||
environment:
|
||||
http_proxy: "{{PROXY}}"
|
||||
https_proxy: "{{PROXY}}"
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
#!/bin/bash
|
||||
for ARGUMENT in "$@"
|
||||
do
|
||||
KEY=$(echo $ARGUMENT | cut -f1 -d=)
|
||||
VALUE=$(echo $ARGUMENT | cut -f2 -d=)
|
||||
|
||||
case "$KEY" in
|
||||
PROXY) PROXY=${VALUE} ;;
|
||||
HOST) HOST=${VALUE} ;;
|
||||
USER) USER=${VALUE} ;;
|
||||
PASS) PASS=${VALUE} ;;
|
||||
KEY) KEY=${VALUE} ;;
|
||||
SYN_FLOOD) SYN_FLOOD=${VALUE} ;;
|
||||
STAT_PORT) STAT_PORT=${VALUE} ;;
|
||||
STAT_PAGE) STAT_PAGE=${VALUE} ;;
|
||||
STATS_USER) STATS_USER=${VALUE} ;;
|
||||
STATS_PASS) STATS_PASS=${VALUE} ;;
|
||||
*)
|
||||
esac
|
||||
done
|
||||
|
||||
if [ ! -d "/var/www/haproxy-wi/app/scripts/ansible/roles/nginxinc.nginx" ]; then
|
||||
if [ ! -z $PROXY ];then
|
||||
export https_proxy="$PROXY"
|
||||
export http_proxy="$PROXY"
|
||||
fi
|
||||
ansible-galaxy install nginxinc.nginx --roles-path /var/www/haproxy-wi/app/scripts/ansible/roles/
|
||||
fi
|
||||
|
||||
export ANSIBLE_HOST_KEY_CHECKING=False
|
||||
export ANSIBLE_DISPLAY_SKIPPED_HOSTS=False
|
||||
export ACTION_WARNINGS=False
|
||||
PWD=`pwd`
|
||||
PWD=$PWD/scripts/ansible/
|
||||
echo $HOST > $PWD/$HOST
|
||||
|
||||
if [[ $KEY == "" ]]; then
|
||||
ansible-playbook $PWD/roles/nginx.yml -e "ansible_user=$USER ansible_ssh_pass=$PASS variable_host=$HOST PROXY=$PROXY SYN_FLOOD=$SYN_FLOOD STAT_PAGE=$STAT_PAGE STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS=$STATS_PASS" -i $PWD/$HOST
|
||||
else
|
||||
ansible-playbook $PWD/roles/nginx.yml --key-file $KEY -e "ansible_user=$USER variable_host=$HOST PROXY=$PROXY SYN_FLOOD=$SYN_FLOOD STAT_PAGE=$STAT_PAGE STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS=$STATS_PASS" -i $PWD/$HOST
|
||||
fi
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
echo "error: Can't install Nginx service <br /><br />"
|
||||
exit 1
|
||||
fi
|
||||
rm -f $PWD/$HOST
|
116
app/sql.py
|
@ -124,6 +124,7 @@ def add_group(name, description):
|
|||
return True
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def delete_group(id):
|
||||
con, cur = get_cur()
|
||||
|
@ -139,6 +140,7 @@ def delete_group(id):
|
|||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def update_group(name, descript, id):
|
||||
con, cur = get_cur()
|
||||
sql = """ update groups set
|
||||
|
@ -157,12 +159,13 @@ def update_group(name, descript, id):
|
|||
return True
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def add_server(hostname, ip, group, typeip, enable, master, cred, alert, metrics, port, desc, active):
|
||||
def add_server(hostname, ip, group, typeip, enable, master, cred, port, desc, haproxy, nginx):
|
||||
con, cur = get_cur()
|
||||
sql = """ INSERT INTO servers (hostname, ip, groups, type_ip, enable, master, cred, alert, metrics, port, `desc`, active)
|
||||
VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')
|
||||
""" % (hostname, ip, group, typeip, enable, master, cred, alert, metrics, port, desc, active)
|
||||
sql = """ INSERT INTO servers (hostname, ip, groups, type_ip, enable, master, cred, port, `desc`, haproxy, nginx)
|
||||
VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')
|
||||
""" % (hostname, ip, group, typeip, enable, master, cred, port, desc, haproxy, nginx)
|
||||
try:
|
||||
cur.execute(sql)
|
||||
con.commit()
|
||||
|
@ -173,6 +176,7 @@ def add_server(hostname, ip, group, typeip, enable, master, cred, alert, metrics
|
|||
return False
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def delete_server(id):
|
||||
con, cur = get_cur()
|
||||
|
@ -187,22 +191,15 @@ def delete_server(id):
|
|||
return True
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
def update_server(hostname, group, typeip, enable, master, id, cred, alert, metrics, port, desc, active):
|
||||
|
||||
|
||||
def update_hapwi_server(id, alert, metrics, active):
|
||||
con, cur = get_cur()
|
||||
sql = """ update servers set
|
||||
hostname = '%s',
|
||||
groups = '%s',
|
||||
type_ip = '%s',
|
||||
enable = '%s',
|
||||
master = '%s',
|
||||
cred = '%s',
|
||||
alert = '%s',
|
||||
metrics = '%s',
|
||||
port = '%s',
|
||||
`desc` = '%s',
|
||||
active = '%s'
|
||||
where id = '%s'""" % (hostname, group, typeip, enable, master, cred, alert, metrics, port, desc, active, id)
|
||||
where id = '%s'""" % (alert, metrics, active, id)
|
||||
try:
|
||||
cur.execute(sql)
|
||||
con.commit()
|
||||
|
@ -211,6 +208,31 @@ def update_server(hostname, group, typeip, enable, master, id, cred, alert, metr
|
|||
con.rollback()
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def update_server(hostname, group, typeip, enable, master, id, cred, port, desc, haproxy, nginx):
|
||||
con, cur = get_cur()
|
||||
sql = """ update servers set
|
||||
hostname = '%s',
|
||||
groups = '%s',
|
||||
type_ip = '%s',
|
||||
enable = '%s',
|
||||
master = '%s',
|
||||
cred = '%s',
|
||||
port = '%s',
|
||||
`desc` = '%s',
|
||||
haproxy = '%s',
|
||||
nginx = '%s'
|
||||
where id = '%s'""" % (hostname, group, typeip, enable, master, cred, port, desc, haproxy, nginx, id)
|
||||
try:
|
||||
cur.execute(sql)
|
||||
con.commit()
|
||||
except sqltool.Error as e:
|
||||
out_error(e)
|
||||
con.rollback()
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def update_server_master(master, slave):
|
||||
con, cur = get_cur()
|
||||
|
@ -514,6 +536,9 @@ def get_dick_permit(**kwargs):
|
|||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
user_id = cookie.get('uuid')
|
||||
disable = ''
|
||||
haproxy = ''
|
||||
nginx = ''
|
||||
keepalived = ''
|
||||
ip = ''
|
||||
|
||||
con, cur = get_cur()
|
||||
|
@ -529,6 +554,12 @@ def get_dick_permit(**kwargs):
|
|||
disable = 'or enable = 0'
|
||||
if kwargs.get('ip'):
|
||||
ip = "and ip = '%s'" % kwargs.get('ip')
|
||||
if kwargs.get('haproxy'):
|
||||
haproxy = "and haproxy = 1"
|
||||
if kwargs.get('nginx'):
|
||||
nginx = "and nginx = 1"
|
||||
if kwargs.get('keepalived'):
|
||||
nginx = "and keepalived = 1"
|
||||
|
||||
try:
|
||||
cur.execute(sql)
|
||||
|
@ -537,18 +568,21 @@ def get_dick_permit(**kwargs):
|
|||
else:
|
||||
for group in cur:
|
||||
if group[5] == '1':
|
||||
sql = """ select * from servers where enable = 1 %s %s """ % (disable, type_ip)
|
||||
sql = """ select * from servers where enable = 1 %s %s %s """ % (disable, type_ip, nginx)
|
||||
else:
|
||||
sql = """ select * from servers where groups like '%{group}%' and (enable = 1 {disable}) {type_ip} {ip} """.format(group=group[5], disable=disable, type_ip=type_ip, ip=ip)
|
||||
sql = """ select * from servers where groups like '%{group}%' and (enable = 1 {disable}) {type_ip} {ip} {haproxy} {nginx} {keepalived}
|
||||
""".format(group=group[5], disable=disable, type_ip=type_ip, ip=ip, haproxy=haproxy, nginx=nginx, keepalived=keepalived)
|
||||
try:
|
||||
cur.execute(sql)
|
||||
except sqltool.Error as e:
|
||||
out_error(e)
|
||||
else:
|
||||
return cur.fetchall()
|
||||
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def is_master(ip, **kwargs):
|
||||
con, cur = get_cur()
|
||||
sql = """ select slave.ip, slave.hostname from servers as master left join servers as slave on master.id = slave.master where master.ip = '%s' """ % ip
|
||||
|
@ -563,6 +597,7 @@ def is_master(ip, **kwargs):
|
|||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def select_ssh(**kwargs):
|
||||
con, cur = get_cur()
|
||||
sql = """select * from cred """
|
||||
|
@ -581,6 +616,7 @@ def select_ssh(**kwargs):
|
|||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def insert_new_ssh(name, enable, group, username, password):
|
||||
con, cur = get_cur()
|
||||
sql = """insert into cred(name, enable, groups, username, password) values ('%s', '%s', '%s', '%s', '%s') """ % (name, enable, group, username, password)
|
||||
|
@ -595,6 +631,7 @@ def insert_new_ssh(name, enable, group, username, password):
|
|||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def delete_ssh(id):
|
||||
con, cur = get_cur()
|
||||
sql = """ delete from cred where id = %s """ % (id)
|
||||
|
@ -609,6 +646,7 @@ def delete_ssh(id):
|
|||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def update_ssh(id, name, enable, group, username, password):
|
||||
con, cur = get_cur()
|
||||
sql = """ update cred set
|
||||
|
@ -1491,6 +1529,50 @@ def update_keepalived(serv):
|
|||
return False
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def select_nginx(serv, **kwargs):
|
||||
con, cur = get_cur()
|
||||
sql = """select nginx from `servers` where ip='%s' """ % serv
|
||||
try:
|
||||
cur.execute(sql)
|
||||
except sqltool.Error as e:
|
||||
out_error(e)
|
||||
else:
|
||||
for value in cur.fetchone():
|
||||
return value
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def update_nginx(serv):
|
||||
con, cur = get_cur()
|
||||
sql = """update `servers` set `nginx` = '1' where ip = '%s' """ % serv
|
||||
try:
|
||||
cur.execute(sql)
|
||||
con.commit()
|
||||
return True
|
||||
except sqltool.Error as e:
|
||||
out_error(e)
|
||||
con.rollback()
|
||||
return False
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def update_haproxy(serv):
|
||||
con, cur = get_cur()
|
||||
sql = """update `servers` set `haproxy` = '1' where ip = '%s' """ % serv
|
||||
try:
|
||||
cur.execute(sql)
|
||||
con.commit()
|
||||
return True
|
||||
except sqltool.Error as e:
|
||||
out_error(e)
|
||||
con.rollback()
|
||||
return False
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
||||
def check_token_exists(token):
|
||||
|
|
|
@ -145,9 +145,8 @@
|
|||
<th class="group-field">Group</th>
|
||||
<th class="checkbox-head">Enable</th>
|
||||
<th class="checkbox-head"><span title="Vitrual IP, something like VRRP">Virt</span></th>
|
||||
<th class="checkbox-head"><span title="Alert if backend change status. Before enable add Telgram chanel at Checker tab">Alert</span></th>
|
||||
<th class="checkbox-head"><span title="Enable save and show metrics">Metrics</span></th>
|
||||
<th class="checkbox-head"><span title="Keep start HAProxy service if down">Start</span></th>
|
||||
<th class="checkbox-head">HAProxy</th>
|
||||
<th class="checkbox-head">Nginx</th>
|
||||
<th class="slave-field"><span title="Actions with master config will automatically apply on slave">Slave for</span></th>
|
||||
<th class="cred-field">Credentials</th>
|
||||
<th>Description</th>
|
||||
|
|
|
@ -2,15 +2,25 @@
|
|||
<h4>Config from {{serv}}</h4>
|
||||
<p class="accordion-expand-holder">
|
||||
{% if role %}
|
||||
{% if service != 'keepalived' %}
|
||||
<a class="ui-button ui-widget ui-corner-all" title="Edit this run config" href="config.py?serv={{serv}}&open=open">Edit</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<a class="accordion-expand-all ui-button ui-widget ui-corner-all" href="#">Expand all</a>
|
||||
<button id="raw">Raw</button>
|
||||
<button id="according" style="display: none;">According</button>
|
||||
{% if service != 'keepalived' and service != 'nginx' %}
|
||||
<a class="accordion-expand-all ui-button ui-widget ui-corner-all" href="#">Expand all</a>
|
||||
<button id="raw">Raw</button>
|
||||
<button id="according" style="display: none;">According</button>
|
||||
{% endif %}
|
||||
</p>
|
||||
</center>
|
||||
|
||||
{% if service == 'nginx' %}
|
||||
<div style="margin-left: 20%; border: 1px solid #ddd; padding-left: 50px; width: 60%;">
|
||||
<pre>
|
||||
{%- for line in conf -%}
|
||||
{{ line }}
|
||||
{% endfor %}
|
||||
</pre>
|
||||
</div>
|
||||
{% else %}
|
||||
<div style="margin-left: 16%" class="configShow">
|
||||
{% set i = 0 -%}
|
||||
{% set section_name = {} %}
|
||||
|
@ -172,6 +182,7 @@
|
|||
{%- endfor -%}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if configver %}
|
||||
<br>
|
||||
<center>
|
||||
|
|
|
@ -13,13 +13,13 @@
|
|||
<td>
|
||||
{% if role <= 1 %}
|
||||
<a id="{{ service.1 }}" class="start-waf" title="Start WAF service">
|
||||
<img src=/inc/images/start.png alt="start" class="icon" style="margin-bottom: -4px;">
|
||||
<span class="service-start" onclick="confirmAjaxAction('start', 'waf', '{{service.1}}')"></span>
|
||||
</a>
|
||||
<a id="{{ service.1 }}" class="stop-waf" title="Stop WAF service">
|
||||
<img src=/inc/images/stop.png alt="start" class="icon" width="17px">
|
||||
<span class="service-stop" onclick="confirmAjaxAction('stop', 'waf', '{{service.1}}')"></span>
|
||||
</a>
|
||||
<a id="{{ service.1 }}" class="restart-waf" title="Restart WAF service">
|
||||
<img src=/inc/images/update.png alt="restart" class="icon">
|
||||
<span class="service-reload" onclick="confirmAjaxAction('restart', 'restart', '{{service.1}}')"></span>
|
||||
</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
@ -76,4 +76,5 @@
|
|||
</script>
|
||||
<style>
|
||||
.ui-selectmenu-button.ui-button {width: 10em;}
|
||||
.fa-play, .fa-stop, .fa-sync-alt { margin-bottom: -1px; }
|
||||
</style>
|
|
@ -11,6 +11,17 @@
|
|||
<span class="serverDown server-status" style="margin-left: 25px !important;"></span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="padding10 first-collumn">
|
||||
{% if service.8|int() == 0 %}
|
||||
<span class="serverNone server-status" title="Nginx is not installed" style="margin-left: 4px !important;"></span>
|
||||
{% else %}
|
||||
{% if service.9|int() >= 1 %}
|
||||
<span class="serverUp server-status" title="running {{service.9 }} processes" style="margin-left: 4px !important;"></span>
|
||||
{% else %}
|
||||
<span class="serverDown server-status" title="Nginx is down" style="margin-left: 4px !important;"></span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="padding10 first-collumn">
|
||||
{% if service.6|int() == 0 %}
|
||||
<span class="serverNone server-status" title="Keepalived is not installed" style="margin-left: 4px !important;"></span>
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
{% for service in service_status %}
|
||||
{%- for service in service_status -%}
|
||||
<div class="server-info">
|
||||
<div class="server-name">
|
||||
Server status
|
||||
<span class="update-icon">
|
||||
<a onclick="showOverviewServer('{{ service.0 }}', '{{ service.1 }}', '{{id}}')" title="Refresh">
|
||||
<span class="service-reload"></span>
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="haproxy-info">
|
||||
{{ service.2 }}
|
||||
</div>
|
||||
|
@ -7,11 +15,6 @@
|
|||
<pre>
|
||||
{{ service.3 }}
|
||||
</pre>
|
||||
</div>
|
||||
<div class="update-icon">
|
||||
<a onclick="showOverviewServer('{{ service.0 }}', '{{ service.1 }}', '{{id}}')" title="Refresh">
|
||||
<img src="/inc/images/update.png" alt="restart" class="icon">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
|
@ -53,37 +53,37 @@
|
|||
<ul class="menu">
|
||||
{% if user %}
|
||||
<li><a href="/app/overview.py" title="Server and service status" class="overview-link">Overview</a></li>
|
||||
<li class="p_menu"><a title="Statistics, monitoring and logs" class="stats">Monitoring</a>
|
||||
<ul class="v_menu">
|
||||
<li><a href="/app/viewsttats.py" title="Show stats" class="stats head-submenu">Stats</a></li>
|
||||
<li><a href="/app/logs.py" title="View logs" class="logs head-submenu"> Logs</a></li>
|
||||
<li><a href="/app/edit.py" title="Runtime API" class="runtime head-submenu">Runtime API</a></li>
|
||||
<li><a href="/app/metrics.py" title="Metrics" class="metrics head-submenu">Metrics</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="p_menu"><a title="Actions with Haproxy configs" class="config-show">Haproxy</a>
|
||||
<ul class="v_menu">
|
||||
<li><a href="/app/hapservers.py" title="Working with Haproxy Configs" class="overview-link head-submenu">Overview</a> </li>
|
||||
<li><a href="/app/hapservers.py" title="Overview HAProxy servers" class="overview-link head-submenu">Overview</a> </li>
|
||||
<li><a href="/app/config.py" title="Working with HAProxy configs" class="edit head-submenu">Configs</a></li>
|
||||
<li><a href="/app/viewsttats.py" title="Show stats" class="stats head-submenu">Stats</a></li>
|
||||
<li><a href="/app/edit.py" title="Runtime API" class="runtime head-submenu">Runtime API</a></li>
|
||||
<li><a href="/app/metrics.py" title="Metrics" class="metrics head-submenu">Metrics</a></li>
|
||||
{% if role <= 2 %}
|
||||
<li><a href="/app/add.py#proxy" title="Add proxy" class="add head-submenu" id="add1">Add proxy</a></li>
|
||||
<li><a href="/app/versions.py" title="Actions with configs versions" class="version head-submenu">Versions</a></li>
|
||||
<li><a href="/app/add.py#ssl" title="Upload SSL cert" class="cert head-submenu" id="add4">SSL</a></li>
|
||||
<li><a href="/app/add.py#option" title="Save custom options" class="option head-submenu" id="add5">Options</a></li>
|
||||
<li><a href="/app/add.py#add-servers" title="Save servers" class="runtime head-submenu" id="add6">Servers</a></li>
|
||||
<li><a href="/app/add.py#userlist" title="Add userlist" class="add-userlist head-submenu" id="add7">User lists</a></li>
|
||||
<li><a href="/app/add.py#lists" title="Manage black and white lists" class="lists head-submenu" id="add8">Lists</a></li>
|
||||
<li><a href="/app/add.py#ssl" title="Upload SSL cert" class="cert head-submenu" id="add3">SSL</a></li>
|
||||
<li><a href="/app/add.py#lists" title="Manage black and white lists" class="lists head-submenu" id="add7">Lists</a></li>
|
||||
<li><a href="/app/waf.py" title="Web application firewall" class="waf head-submenu">WAF</a> </li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
{% if role <= 2 %}
|
||||
<li class="p_menu">
|
||||
<a title="Nginx" class="nginx">Nginx</a>
|
||||
<ul class="v_menu">
|
||||
<li><a href="/app/hapservers.py?service=nginx" title="Overview Nginx servers" class="overview-link head-submenu">Overview</a> </li>
|
||||
<li><a href="/app/config.py?service=nginx" title="Edit Nginx config" class="edit head-submenu">Configs</a></li>
|
||||
<li><a href="/app/versions.py?service=nginx" title="Actions with Nginx configs versions" class="version head-submenu">Versions</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="p_menu">
|
||||
<a title="Keepalived" class="ha">Keepalived</a>
|
||||
<ul class="v_menu">
|
||||
<li><a href="/app/ha.py" title="Create HA cluster" class="keepalived head-submenu">HA</a></li>
|
||||
<li><a href="/app/config.py?service=keepalived" title="Edit keepalived config" class="edit head-submenu">Edit config</a></li>
|
||||
<li><a href="/app/config.py?service=keepalived" title="Edit Keepalived config" class="edit head-submenu">Configs</a></li>
|
||||
<li><a href="/app/versions.py?service=keepalived" title="Actions with Keepalived configs versions" class="version head-submenu keepalived_versions">Versions</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
@ -130,8 +130,8 @@
|
|||
<span class="auto-refresh">
|
||||
<a onclick="pauseAutoRefresh()" class="auto-refresh-pause" style="display: none; margin-top: 4px;"></a>
|
||||
<a onclick="pauseAutoResume()" class="auto-refresh-resume" style="display: none; margin-top: 4px;"></a>
|
||||
<a id="0"><img src="/inc/images/update.png" alt="restart" class="icon"> Auto-refresh</a>
|
||||
<a id="1" style="display: none;"><img src="/inc/images/update.png" alt="restart" class="icon"> Auto-refresh</a>
|
||||
<a id="0"><span class="service-reload"></span> Auto-refresh</a>
|
||||
<a id="1" style="display: none;"><span class="service-reload"></span> Auto-refresh</a>
|
||||
</span>
|
||||
{% endif %}
|
||||
</h2>
|
||||
|
@ -241,7 +241,7 @@
|
|||
{% endif %}
|
||||
{% if new_ver_without_dots is defined and current_ver_without_dots is defined and new_ver is defined and new_ver_without_dots is defined %}
|
||||
<a style="color: #000; cursor: pointer;">
|
||||
{% if new_ver_without_dots > current_ver_without_dots and new_ver != "Sorry cannot get current version" %}
|
||||
{% if new_ver > current_ver and new_ver != "Sorry cannot get current version" %}
|
||||
<span id="show-updates-button" class="new-version-exists">v{{current_ver}} </span>
|
||||
{% else %}
|
||||
v{{current_ver}}
|
||||
|
|
|
@ -6,34 +6,27 @@
|
|||
<p>
|
||||
<form action="{{ action }}" method="post">
|
||||
<a class="ui-button ui-widget ui-corner-all" title="Return back" id="back" onclick="history.go(-2)">Back</a>
|
||||
<input type="hidden" id="service" value="{{service}}" />
|
||||
<select autofocus required name="serv" id="{{ select_id }}">
|
||||
<option disabled>Choose server</option>
|
||||
{% for select in selects %}
|
||||
{% if keepalived %}
|
||||
{% if select.1 == serv %}
|
||||
<option value="{{ select.1 }}" selected>{{ select.0 }}</option>
|
||||
{% else %}
|
||||
<option value="{{ select.1 }}">{{ select.0 }}</option>
|
||||
{% endif %}
|
||||
{% if select.3 == serv %}
|
||||
<option value="{{ select.3 }}" selected>{{ select.2 }}</option>
|
||||
{% else %}
|
||||
<option value="{{ select.3 }}">{{ select.2 }}</option>
|
||||
{% endif %}
|
||||
{% if select.2 == serv %}
|
||||
<option value="{{ select.2 }}" selected>{{ select.1 }}</option>
|
||||
{% else %}
|
||||
{% if select.2 == serv %}
|
||||
<option value="{{ select.2 }}" selected>{{ select.1 }}</option>
|
||||
{% else %}
|
||||
<option value="{{ select.2 }}">{{ select.1 }}</option>
|
||||
{% endif %}
|
||||
<option value="{{ select.2 }}">{{ select.1 }}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% if not keepalived %}
|
||||
<a class="ui-button ui-widget ui-corner-all" title="Show running config" onclick="showConfig()">Open</a>
|
||||
<a class="ui-button ui-widget ui-corner-all" title="Compare configs" onclick="showCompareConfigs()">Compare</a>
|
||||
{% if service != 'keepalived' and service != 'nginx'%}
|
||||
<a class="ui-button ui-widget ui-corner-all" title="Show running config" onclick="showConfig()">Open</a>
|
||||
<a class="ui-button ui-widget ui-corner-all" title="Show map" onclick="showMap()">Map</a>
|
||||
<a class="ui-button ui-widget ui-corner-all" title="View stat" onclick="openStats()">Stat</a>
|
||||
<a class="ui-button ui-widget ui-corner-all" title="View stat" onclick="openStats()">Stat</a>
|
||||
{% endif %}
|
||||
{% if role <= 2 and service == 'nginx'%}
|
||||
<button type="submit" value="open" name="open" class="btn btn-default" title="Edit running config">Edit</button>
|
||||
{% endif %}
|
||||
{% if service != 'keepalived' %}
|
||||
<a class="ui-button ui-widget ui-corner-all" title="Compare configs" onclick="showCompareConfigs()">Compare</a>
|
||||
{% if role <= 2 %}
|
||||
<a class="ui-button ui-widget ui-corner-all" title="Show versions" onclick="openVersions()">Versions</a>
|
||||
{% endif %}
|
||||
|
@ -59,12 +52,12 @@
|
|||
<input type="hidden" value="{{ cfg }}.old" name="oldconfig">
|
||||
<textarea name="config" class="config" rows="35" cols="100">{{ config }}</textarea>
|
||||
<p>
|
||||
{% if not keepalived %}
|
||||
{% if service == 'haproxy' %}
|
||||
<button type="submit" value="test" name="save" class="btn btn-default">Just test</button>
|
||||
{% endif %}
|
||||
<button type="submit" value="save" name="save" class="btn btn-default">Just save</button>
|
||||
<button type="submit" value="" name="" class="btn btn-default">Save and restart</button>
|
||||
{% if not keepalived %}
|
||||
{% if service != 'keepalived' %}
|
||||
<button type="submit" value="reload" name="save" class="btn btn-default">Save and reload</button>
|
||||
{% endif %}
|
||||
</p>
|
||||
|
@ -89,7 +82,7 @@
|
|||
if (cur_url[1].split('&')[1] == 'showMap') {
|
||||
showMap();
|
||||
}
|
||||
if (cur_url[1].split('&')[1] == 'showCompare') {
|
||||
if (cur_url[1].split('&')[1] == 'showCompare' || cur_url[1].split('&')[2] == 'showCompare') {
|
||||
showCompareConfigs();
|
||||
}
|
||||
if (cur_url[1].split('&')[1] == 'showConfig') {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<h3>Choose server</h3>
|
||||
<p>
|
||||
<form action="{{ action }}" method="post">
|
||||
<input type="hidden" id="service" value="{{service}}">
|
||||
<a class="ui-button ui-widget ui-corner-all" title="Return back" onclick="history.back()">Back</a>
|
||||
{% include 'include/select.html' %}
|
||||
<button type="submit" value="open" name="open" class="btn btn-default">Open</button>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<input type="checkbox" id="select_all"><br />
|
||||
{% for file in return_files %}
|
||||
<label for="{{file}}"> {{file.split('-', maxsplit=1)[1]}} </label><input type="checkbox" value="{{file}}" name="{{file}}" id="{{file}}">
|
||||
<a href="/app/versions.py?serv={{serv}}&open=open&configver={{file}}&service={{service}}" class="ui-button ui-widget ui-corner-all" title="View and upload this version of the config" style="margin-top: -6px;">
|
||||
<a href="/app/versions.py?service={{service}}&serv={{serv}}&open=open&configver={{file}}" class="ui-button ui-widget ui-corner-all" title="View and upload this version of the config" style="margin-top: -6px;">
|
||||
Upload
|
||||
</a><br />
|
||||
{% endfor %}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<td><span title="Interface for VRRP addreess">Interface(?)</span></td>
|
||||
<td>VRRP IP</td>
|
||||
<td><span title="HAProxy-WI will try install HAProxy">HAProxy(?)</span></td>
|
||||
<td><span title="HAProxy-WI will try install Nginx">Nginx(?)</span></td>
|
||||
<td>SYN flood protect</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
@ -33,6 +34,7 @@
|
|||
<td>{{ input('interface', size='7') }}</td>
|
||||
<td>{{ input('vrrp-ip', size='14') }}</td>
|
||||
<td>{{ checkbox('hap') }}</td>
|
||||
<td>{{ checkbox('nginx') }}</td>
|
||||
<td>{{ checkbox('syn_flood') }}</td>
|
||||
<td>
|
||||
<a class="ui-button ui-widget ui-corner-all" id="create" title="Create HA configuration">Create</a>
|
||||
|
@ -48,7 +50,8 @@
|
|||
<td><span title="Interface for VRRP addreess">Interface(?)</span></td>
|
||||
<td>VRRP IP</td>
|
||||
<td><span title="If checked HAProxy-WI will restart Keepalived">Restart(?)</span></td>
|
||||
<td style="width: 20%;"></td>
|
||||
<td style="width: 23%;"></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -72,6 +75,7 @@
|
|||
<td>{{ input('vrrp-ip-add', size='14') }}</td>
|
||||
<td>{{ checkbox('kp') }}</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>
|
||||
<a class="ui-button ui-widget ui-corner-all" id="add-vrrp" title="Add HA configuration">Add</a>
|
||||
</td>
|
||||
|
|
|
@ -47,37 +47,55 @@
|
|||
</script>
|
||||
{% endif %}
|
||||
<div class="div-pannel" id="div-pannel-{{s.0}}">
|
||||
<div id="div-server-{{s.0}}" class="div-server-hapwi">
|
||||
<div class="server-name">
|
||||
{% if s.5 != False %}
|
||||
<span class="serverUp server-status" title="{{s.5.0.2}}"></span>
|
||||
{% else %}
|
||||
<span class="serverDown server-status" title="HAProxy is down"></span>
|
||||
{% endif %}
|
||||
{% if not serv %}
|
||||
<a href="/app/hapservers.py?serv={{s.2}}" title="More about {{s.1}}" style="color: #5d9ceb">{{s.1}}</a>
|
||||
{% else %}
|
||||
<div id="div-server-{{s.0}}" class="div-server-hapwi" {% if service == 'nginx' %}style="height:138px;"{%endif%}>
|
||||
<div class="server-name">
|
||||
{% if service == 'nginx' %}
|
||||
<input type="hidden" id="service" value="nginx" />
|
||||
{% if s.5.0.3 == 'active' %}
|
||||
<span class="serverUp server-status" title="Uptime: {{s.5.0.4}}"></span>
|
||||
{% else %}
|
||||
<span class="serverDown server-status" title="Downtime: : {{s.5.0.4}}"></span>
|
||||
{% endif %}
|
||||
{{s.1}}
|
||||
{% else %}
|
||||
<input type="hidden" id="service" value="haproxy" />
|
||||
{% if s.5 != False %}
|
||||
<span class="serverUp server-status" title="{{s.5.0.2}}"></span>
|
||||
{% else %}
|
||||
<span class="serverDown server-status" title="HAProxy is down"></span>
|
||||
{% endif %}
|
||||
{% if not serv %}
|
||||
<a href="/app/hapservers.py?serv={{s.2}}" title="More about {{s.1}}" style="color: #5d9ceb">{{s.1}}</a>
|
||||
{% else %}
|
||||
{{s.1}}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if s.6|int() >= 1 %}
|
||||
<img
|
||||
{% if keep_alive|int() >= 1 %}
|
||||
src="/inc/images/shield.png" title="Auto start enabled"
|
||||
{% else %}
|
||||
src="/inc/images/shield-red.png" title="Auto start enabled, but keep alive service does not work"
|
||||
{% endif %}
|
||||
width=18 style="padding-left: 5px; margin-bottom: -3px;">
|
||||
{% if service == 'haproxy' %}
|
||||
{% if s.6|int() >= 1 %}
|
||||
<img
|
||||
{% if keep_alive|int() >= 1 %}
|
||||
src="/inc/images/shield.png" title="Auto start enabled"
|
||||
{% else %}
|
||||
src="/inc/images/shield-red.png" title="Auto start enabled, but keep alive service does not work"
|
||||
{% endif %}
|
||||
width=18 style="padding-left: 5px; margin-bottom: -3px;">
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if role <= 1 %}
|
||||
<span class="server-action">
|
||||
{% if service == 'nginx' %}
|
||||
{% set action_service = 'nginx' %}
|
||||
{% else %}
|
||||
{% set action_service = 'hap' %}
|
||||
{% endif %}
|
||||
<a id="start-{{ s.2 }}" class="start" title="Start HAProxy service">
|
||||
<img src=/inc/images/start.png alt="start" class="icon-hapservs" style="margin-bottom: -2px;" onclick="confirmAjaxAction('start', 'hap', '{{s.2}}')">
|
||||
<span class="service-start" onclick="confirmAjaxAction('start', '{{action_service}}', '{{s.2}}')"></span>
|
||||
</a>
|
||||
<a id="stop-{{ s.2 }}" class="stop" title="Stop HAProxy service">
|
||||
<img src=/inc/images/stop.png alt="stop" class="icon-hapservs" width="17px" onclick="confirmAjaxAction('stop', 'hap', '{{s.2}}')">
|
||||
<span class="service-stop" onclick="confirmAjaxAction('stop', '{{action_service}}', '{{s.2}}')"></span>
|
||||
</a>
|
||||
<a id="restart-{{ s.2 }}" class="restart" title="Restart HAProxy service" onclick="confirmAjaxAction('restart', 'hap', '{{s.2}}')">
|
||||
<img src=/inc/images/update.png alt="restart" class="icon-hapservs">
|
||||
<a id="restart-{{ s.2 }}" class="restart" title="Restart HAProxy service">
|
||||
<span class="service-reload" onclick="confirmAjaxAction('restart', '{{action_service}}', '{{s.2}}')"></span>
|
||||
</a>
|
||||
</span>
|
||||
{% endif %}
|
||||
|
@ -85,10 +103,14 @@
|
|||
<div class="server-desc">
|
||||
{{s.3}}
|
||||
<br />
|
||||
{% if s.5.0 is defined %}
|
||||
{{s.5.0.0}} {{s.5.0.1}} {{s.5.0.2}}
|
||||
{% if service == 'nginx' %}
|
||||
Version: {{s.5.0.2}} Process_num: {{s.5.0.5}} {% if s.5.0.3 == 'active' %} Uptime: {% else %} Downtime: {% endif %} {{s.5.0.4}}
|
||||
{% else %}
|
||||
Cannot get information about HAProxy
|
||||
{% if s.5.0 is defined %}
|
||||
{{s.5.0.0}} {{s.5.0.1}} {{s.5.0.2}}
|
||||
{% else %}
|
||||
Cannot get information about HAProxy
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<br />
|
||||
<span title="Date of last edit config" >
|
||||
|
@ -101,21 +123,51 @@
|
|||
Master for: {{ s.7.0.1 }}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if service == 'haproxy' %}
|
||||
<div class="server-act-links" id="server-{{s.8.0.0|string()}}">
|
||||
{% if role <= 1 %}
|
||||
{% set id = 'alert-' + s.8.0.0|string() %}
|
||||
{% if s.8.0.8 == 1 %}
|
||||
{{ checkbox(id, title='Enable alerting', value='1', desc='Alert', checked='checked') }}
|
||||
{% else %}
|
||||
{{ checkbox(id, title='Enable alerting', value='1', desc='Alert') }}
|
||||
{% endif %}
|
||||
{% set id = 'metrics-' + s.8.0.0|string() %}
|
||||
{% if s.8.0.9 == 1 %}
|
||||
{{ checkbox(id, title='Enable collect metrics', value='1', desc='Metrics', checked='checked') }}
|
||||
{% else %}
|
||||
{{ checkbox(id, title='Enable collect metrics', value='1', desc='Metrics') }}
|
||||
{% endif %}
|
||||
{% set id = 'active-' + s.8.0.0|string() %}
|
||||
{% if s.8.0.12 == 1 %}
|
||||
{{ checkbox(id, title='Enable Compression', value='1', desc='Auto Start', checked='checked') }}
|
||||
{% else %}
|
||||
{{ checkbox(id, title='Enable Auto Start', value='1', desc='Auto Start') }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="server-act-links">
|
||||
{% if service != 'nginx' %}
|
||||
<a href="/app/config.py?serv={{s.2}}&showConfig" class="ui-button ui-widget ui-corner-all" title="Open running config">Open</a>
|
||||
<a href="/app/config.py?serv={{s.2}}&showCompare" class="ui-button ui-widget ui-corner-all" title="Compare configs">Compare</a>
|
||||
{% else %}
|
||||
<a class="ui-button ui-widget ui-corner-all" title="Edit this run config" href="config.py?service={{service}}&serv={{s.2}}&open=open">Edit</a>
|
||||
{% 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>
|
||||
{% if service != 'nginx' %}
|
||||
<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/viewsttats.py?serv={{s.2}}" class="ui-button ui-widget ui-corner-all" title="View stat">Stat</a>
|
||||
<a href="/app/logs.py?serv={{s.2}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" class="ui-button ui-widget ui-corner-all" title="View log">Log</a>
|
||||
{% 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 log">Log</a>
|
||||
{% if role <= 2 %}
|
||||
<a href="/app/versions.py?serv={{s.2}}&open=open" class="ui-button ui-widget ui-corner-all">Versions</a>
|
||||
<a href="/app/versions.py?service={{service}}&serv={{s.2}}&open=open" class="ui-button ui-widget ui-corner-all">Versions</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% if serv %}
|
||||
<div id="ajax-server-{{s.0}}" class="ajax-server"></div>
|
||||
<div class="div-server div-backends">
|
||||
<div class="server-name">
|
||||
<div class="server-name backends">
|
||||
Backends:
|
||||
</div>
|
||||
<div style="margin-top: 10px;" id="top-{{s.1}}"></div>
|
||||
|
@ -126,7 +178,7 @@
|
|||
</div>
|
||||
{% if serv %}
|
||||
<div id="refresh" style="text-align: right;margin-right: 105px;clear: both;display: block;padding-top: 20px;margin-bottom: -25px;" title="Refresh metrics" onclick="showMetrics()">
|
||||
<img src="/inc/images/update.png" alt="Refresh" class="icon">
|
||||
<span class="service-reload"></span>
|
||||
</div>
|
||||
{% for s in servers %}
|
||||
<div class="chart-container" style="display: block; width: 90%; height: 300px;">
|
||||
|
@ -144,6 +196,6 @@
|
|||
{% if serv %}
|
||||
overviewHapserverBackends(ip, hostnamea);
|
||||
{% endif %}
|
||||
showHapservers(ip, hostnamea);
|
||||
showHapservers(ip, hostnamea, '{{service}}');
|
||||
</script>
|
||||
{% endblock %}
|
|
@ -50,6 +50,16 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="div-pannel">
|
||||
<div class="div-server">
|
||||
<div class="server-name">
|
||||
<span title="Create presaved options" class="span-link" id="add4">Create presaved options</span>
|
||||
</div>
|
||||
<div class="server-desc">
|
||||
Create, edit and delete options with given parameters. And after use them as autocomplete in the "Add" sections
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="middle-collumn">
|
||||
<div class="div-pannel">
|
||||
|
@ -92,6 +102,16 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="div-pannel">
|
||||
<div class="div-server">
|
||||
<div class="server-name">
|
||||
<span title="Create presaved servers" class="span-link" id="add5">Create presaved servers</span>
|
||||
</div>
|
||||
<div class="server-desc">
|
||||
Create, edit and delete servers. And after use them as autocomplete in the "Add" sections
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="right-collumn">
|
||||
<div class="div-pannel">
|
||||
|
@ -134,5 +154,15 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="div-pannel">
|
||||
<div class="div-server">
|
||||
<div class="server-name">
|
||||
<span title="Create userlists" class="span-link" id="add6">Create userlists</span>
|
||||
</div>
|
||||
<div class="server-desc">
|
||||
Create userlists. And use it in the "Add" sections
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -34,16 +34,12 @@
|
|||
<td>{{ checkbox('typeip') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding20" title="Alert if backend change status">Alert</td>
|
||||
<td>{{ checkbox('alert') }} </td>
|
||||
<td class="padding20" title="Is there HAProxy?">HAProxy</td>
|
||||
<td>{{ checkbox('haproxy') }} </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding20" title="Enable save and show metrics">Metrics</td>
|
||||
<td>{{ checkbox('metrics') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding20" title="Keep start HAProxy service if down">Start</td>
|
||||
<td>{{ checkbox('active') }}</td>
|
||||
<td class="padding20" title="Is there Nginx?">Nginx</td>
|
||||
<td>{{ checkbox('nginx') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding20" title="Actions with master config will automatically apply on slave">Slave for</td>
|
||||
|
|
|
@ -16,24 +16,16 @@
|
|||
{% endif %}
|
||||
</td>
|
||||
<td class="checkbox">
|
||||
{% set id = 'alert-' + server.0|string() %}
|
||||
{% if server.8 == 1 %}
|
||||
{% set id = 'haproxy-' + server.0|string() %}
|
||||
{% if server.15 == 1 %}
|
||||
{{ checkbox(id, checked='checked') }}
|
||||
{% else %}
|
||||
{{ checkbox(id) }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="checkbox">
|
||||
{% set id = 'metrics-' + server.0|string() %}
|
||||
{% if server.9 == 1 %}
|
||||
{{ checkbox(id, checked='checked') }}
|
||||
{% else %}
|
||||
{{ checkbox(id) }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="checkbox">
|
||||
{% set id = 'active-' + server.0|string() %}
|
||||
{% if server.12 == 1 %}
|
||||
{% set id = 'nginx-' + server.0|string() %}
|
||||
{% if server.14 == 1 %}
|
||||
{{ checkbox(id, checked='checked') }}
|
||||
{% else %}
|
||||
{{ checkbox(id) }}
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
<td class="padding10 first-collumn">
|
||||
{% if user.6 == 1%}
|
||||
<input type="text" id="login-{{user.0}}" value="{{user.1}}" class="form-control" readonly>
|
||||
{% else %}
|
||||
<input type="text" id="login-{{user.0}}" value="{{user.1}}" class="form-control">
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if user.6 != 1%}
|
||||
<span title="Change password" style="cursor: pointer">
|
||||
<img src="/inc/images/edit.png" alt="Edit" width="15" style="margin-bottom: -3px; padding-left: 15px;" onclick="openChangeUserPasswordDialog('{{user.0}}')" />
|
||||
</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="checkbox">
|
||||
{% if user.7 == 1 %}
|
||||
<label for="activeuser-{{user.0}}"></label><input type="checkbox" id="activeuser-{{user.0}}" checked>
|
||||
{% else %}
|
||||
<label for="activeuser-{{user.0}}"></label><input type="checkbox" id="activeuser-{{user.0}}">
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if user.6 == 1%}
|
||||
<input type="text" id="email-{{user.0}}" value="{{user.2}}" class="form-control" readonly>
|
||||
{% else %}
|
||||
<input type="text" id="email-{{user.0}}" value="{{user.2}}" class="form-control">
|
||||
{% endif %}
|
||||
</td>
|
|
@ -9,8 +9,7 @@
|
|||
</td>
|
||||
<td>
|
||||
{% if user.6 != 1%}
|
||||
<span title="Change password" style="cursor: pointer">
|
||||
<img src="/inc/images/edit.png" alt="Edit" width="15" style="margin-bottom: -3px; padding-left: 15px;" onclick="openChangeUserPasswordDialog('{{user.0}}')" />
|
||||
<span title="Change password" style="cursor: pointer; margin-left: 15px;" class="div-pic" onclick="openChangeUserPasswordDialog('{{user.0}}')">
|
||||
</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
{% block content %}
|
||||
{% from 'include/input_macros.html' import input, checkbox %}
|
||||
<script src="/inc/users.js"></script>
|
||||
<input type="hidden" id="service" value="{{service}}" />
|
||||
<table class="overview">
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn" style="width: 10%;">
|
||||
|
@ -11,7 +12,7 @@
|
|||
Server
|
||||
{% endif %}
|
||||
</td>
|
||||
{% if onclick != 'viewLogs()' %}
|
||||
{% if onclick != 'viewLogs()' and service != 'nginx' %}
|
||||
<td style="width: 5%;">WAF logs</td>
|
||||
{% endif %}
|
||||
<td style="width: 10%;">Number rows</td>
|
||||
|
@ -41,7 +42,7 @@
|
|||
{% include 'include/select.html' %}
|
||||
{% endif %}
|
||||
</td>
|
||||
{% if onclick != 'viewLogs()' %}
|
||||
{% if onclick != 'viewLogs()' and service != 'nginx' %}
|
||||
<td>
|
||||
{{ checkbox('waf') }}
|
||||
</td>
|
||||
|
|
|
@ -17,7 +17,7 @@ th, tr, td {
|
|||
<script src="/inc/chart.min.js"></script>
|
||||
<div id="table_metrics"></div>
|
||||
<div id="refresh" style="text-align: right;margin-top: 20px;margin-right: 10px;" title="Refresh metrics" onclick="showMetrics()">
|
||||
<img src="/inc/images/update.png" alt="Refresh" class="icon">
|
||||
<span class="service-reload"></span>
|
||||
</div>
|
||||
{% for s in servers %}
|
||||
<div class="chart-container">
|
||||
|
|
|
@ -10,16 +10,24 @@
|
|||
hostnamea.push("{{s[1]}}")
|
||||
{% endfor %}
|
||||
</script>
|
||||
<style>
|
||||
.fa-sync-alt { margin-bottom: -1px; }
|
||||
</style>
|
||||
<table class="overview-wi">
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn-wi">
|
||||
Server
|
||||
</td>
|
||||
<td class="padding10 third-collumn-wi" style="width: 27%;">
|
||||
<td class="padding10 third-collumn-wi" style="width: 20%;">
|
||||
<a href="/app/hapservers.py" title="HAProxy servers overview" class="logs_link">
|
||||
HAProxy
|
||||
</a>
|
||||
</td>
|
||||
<td class="padding10">
|
||||
<a href="/app/hapservers.py?service=nginx" title="Nginx servers overview" class="logs_link">
|
||||
Nginx
|
||||
</a>
|
||||
</td>
|
||||
<td class="padding10">
|
||||
Keealived
|
||||
</td>
|
||||
|
@ -29,7 +37,9 @@
|
|||
</a>
|
||||
</td class="padding10">
|
||||
<td>
|
||||
<a onclick="showOverview(ip, hostnamea)" title="Refresh" style="float: right; margin-right: 25px;"><img src="/inc/images/update.png" alt="hostname" class="icon"></a>
|
||||
<a onclick="showOverview(ip, hostnamea)" title="Refresh" style="float: right; margin-right: 25px;">
|
||||
<span class="service-reload"></span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% for s in servers %}
|
||||
|
@ -48,7 +58,9 @@
|
|||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<a onclick="showOverviewHapWI()" title="Refresh" style="float: right; margin-right: 25px;"><img src="/inc/images/update.png" alt="restart" class="icon"></a>
|
||||
<a onclick="showOverviewHapWI()" title="Refresh" style="float: right; margin-right: 25px;">
|
||||
<span class="service-reload"></span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -169,9 +181,9 @@
|
|||
{% if counter <= 2 %}
|
||||
<tr class="{{ loop.cycle('odd', 'even') }}">
|
||||
<td class="padding10 first-collumn-wi">
|
||||
<a href="users.py#users" title="Edit user" class="logs_link">
|
||||
<a href="users.py#users" title="Edit user" class="logs_link div-pic">
|
||||
{{ USER.1 }}
|
||||
<img src="/inc/images/edit.png" alt="Edit" width="15" style="margin-bottom: -3px;" />
|
||||
|
||||
</a>
|
||||
</td>
|
||||
{% for group in groups %}
|
||||
|
@ -184,9 +196,8 @@
|
|||
{% else %}
|
||||
<tr style="display: none;" class="show-users {{ loop.cycle('odd', 'even') }}">
|
||||
<td class="padding10 first-collumn-wi">
|
||||
<a href="users.py#users" title="Edit user" class="logs_link">
|
||||
<a href="users.py#users" title="Edit user" class="logs_link div-pic">
|
||||
{{ USER.1 }}
|
||||
<img src="/inc/images/edit.png" alt="Edit" width="15" style="margin-bottom: -3px;" />
|
||||
</a>
|
||||
</td>
|
||||
{% for group in groups %}
|
||||
|
@ -218,9 +229,8 @@
|
|||
{% if counter <= 2 %}
|
||||
<tr class="{{ loop.cycle('odd', 'even') }}">
|
||||
<td class="padding10 first-collumn-wi">
|
||||
<a href="users.py#groups" title="Edit groups" class="logs_link">
|
||||
<a href="users.py#groups" title="Edit groups" class="logs_link div-pic">
|
||||
{{ group.1 }}
|
||||
<img src="/inc/images/edit.png" alt="Edit" width="15" style="margin-bottom: -3px;" />
|
||||
</a>
|
||||
</td>
|
||||
<td class="third-collumn-wi" colspan="2">{{ group.2 }}</td>
|
||||
|
@ -228,9 +238,8 @@
|
|||
{% else %}
|
||||
<tr style="display: none;" class="show-groups {{ loop.cycle('odd', 'even') }}">
|
||||
<td class="padding10 first-collumn-wi">
|
||||
<a href="users.py#groups" title="Edit groups" class="logs_link">
|
||||
<a href="users.py#groups" title="Edit groups" class="logs_link div-pic">
|
||||
{{ group.1 }}
|
||||
<img src="/inc/images/edit.png" alt="Edit" width="15" style="margin-bottom: -3px;" />
|
||||
</a>
|
||||
</td>
|
||||
<td class="third-collumn-wi" colspan="2">{{ group.2 }}</td>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<li><a href="#servers">Servers</a></li>
|
||||
<li><a href="#ssh">SSH credentials</a></li>
|
||||
<li><a href="#checker">Checker</a></li>
|
||||
<li><a href="#installhaproxy">Install HAProxy</a></li>
|
||||
<li><a href="#installhaproxy">Installation</a></li>
|
||||
<li><a href="#backup">Backup</a></li>
|
||||
{% include 'include/login.html' %}
|
||||
</ul>
|
||||
|
@ -74,9 +74,8 @@
|
|||
<td class="checkbox-head"><span title="SSH port">Port</span></td></td>
|
||||
<td class="checkbox-head">Enable</td>
|
||||
<td class="checkbox-head"><span title="Vitrual IP, something like VRRP">Virt</span></td>
|
||||
<td class="checkbox-head"><span title="Alert if backend change status. Before enable add Telgram chanel at Checker tab">Alert</span></td>
|
||||
<td class="checkbox-head"><span title="Enable save and show metrics">Metrics</span></td>
|
||||
<td class="checkbox-head"><span title="Keep start HAProxy service if down">Start</span></td>
|
||||
<th class="checkbox-head">HAProxy</th>
|
||||
<th class="checkbox-head">Nginx</th>
|
||||
<td class="slave-field"><span title="Actions with master config will automatically apply on slave">Slave for</span></td>
|
||||
<td class="cred-field">Credentials</td>
|
||||
<td>Description</td>
|
||||
|
@ -274,6 +273,7 @@
|
|||
</div>
|
||||
<div id="installhaproxy">
|
||||
<table class="overview">
|
||||
<caption><h3>Install HAProxy</h3></caption>
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">Current version</td>
|
||||
<td class="padding10 first-collumn" style="width: 25%;">Available Versions</td>
|
||||
|
@ -305,6 +305,37 @@
|
|||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<caption><h3>Install Nginx</h3></caption>
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">Current version</td>
|
||||
<td class="padding10 first-collumn" style="width: 25%;">Available Versions</td>
|
||||
<td class="padding10 first-collumn" style="width: 35%;">Server</td>
|
||||
<td>SYN flood protect</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td id="cur_nginx_ver" class="padding10 first-collumn">
|
||||
</td>
|
||||
<td class="padding10 first-collumn" style="width: 20%;">
|
||||
HAProxy-WI will try to install the latest Nginx version from official Nginx repository
|
||||
</td>
|
||||
<td class="padding10 first-collumn">
|
||||
<select autofocus required name="nginxaddserv" id="nginxaddserv">
|
||||
<option disabled selected>Choose server</option>
|
||||
{% for select in servers %}
|
||||
<option value="{{ select.2 }}">{{ select.1 }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
{{ checkbox('nginx_syn_flood', title="Enable SYN flood protect", checked='checked') }}
|
||||
</td>
|
||||
<td>
|
||||
<a class="ui-button ui-widget ui-corner-all" id="nginx_install" title="Install Nginx">Install</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="ajax"></div>
|
||||
</div>
|
||||
|
||||
|
@ -436,7 +467,9 @@
|
|||
$('.delete').remove()
|
||||
$('#hapver').selectmenu('enable');
|
||||
$('#haproxyaddserv').selectmenu('enable');
|
||||
$('#nginxaddserv').selectmenu('enable');
|
||||
$('#syn_flood').checkboxradio('enable');
|
||||
$('#nginx_syn_flood').checkboxradio('enable');
|
||||
}, 500 );
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,9 @@
|
|||
Metrics
|
||||
</td>
|
||||
<td>
|
||||
<a onclick="showOverviewWaf(ip, hostnamea)" title="Refresh" style="float: right; margin-right: 25px;"><img src="/inc/images/update.png" alt="Refresh" class="icon"></a>
|
||||
<a onclick="showOverviewWaf(ip, hostnamea)" title="Refresh" style="float: right; margin-right: 25px;">
|
||||
<span class="service-reload"></span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% for s in servers_all %}
|
||||
|
@ -46,7 +48,7 @@
|
|||
<script src="/inc/chart.min.js"></script>
|
||||
<script src="/inc/waf.js"></script>
|
||||
<div id="refresh" style="text-align: right;margin-top: 20px;margin-right: 20px;" title="Refresh metrics" onclick="showWafMetrics()">
|
||||
<img src="/inc/images/update.png" alt="Refresh" class="icon">
|
||||
<span class="service-reload"></span>
|
||||
</div>
|
||||
{% for s in servers %}
|
||||
<div class="chart-container">
|
||||
|
|
|
@ -35,11 +35,18 @@ except:
|
|||
|
||||
|
||||
if service == 'keepalived':
|
||||
title = "Working with versions Keepalived configs"
|
||||
files = funct.get_files(dir=funct.get_config_var('configs', 'kp_save_configs_dir'), format='conf')
|
||||
action = 'versions.py?service=keepalived'
|
||||
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
||||
title = "Working with versions Keepalived configs"
|
||||
files = funct.get_files(dir=configs_dir, format='conf')
|
||||
action = 'versions.py?service=keepalived'
|
||||
format = 'conf'
|
||||
elif service == 'nginx':
|
||||
configs_dir = funct.get_config_var('configs', 'nginx_save_configs_dir')
|
||||
title = "Working with versions Nginx configs"
|
||||
files = funct.get_files(dir=configs_dir, format='conf')
|
||||
action = 'versions.py?service=nginx'
|
||||
format = 'conf'
|
||||
servers = sql.get_dick_permit(nginx=1)
|
||||
else:
|
||||
title = "Working with versions HAProxy configs"
|
||||
files = funct.get_files()
|
||||
|
@ -59,7 +66,7 @@ if serv is not None and form.getvalue('del') is not None:
|
|||
funct.logging(serv, "versions.py were deleted configs: %s" % form.getvalue(get))
|
||||
except OSError as e:
|
||||
stderr = "Error: %s - %s." % (e.filename,e.strerror)
|
||||
print('<meta http-equiv="refresh" content="10; url=versions.py?serv=%s&open=open&service=%s">' % (form.getvalue('serv'), service))
|
||||
print('<meta http-equiv="refresh" content="10; url=versions.py?service=%s&serv=%s&open=open">' % (service, form.getvalue('serv')))
|
||||
|
||||
|
||||
if serv is not None and form.getvalue('config') is not None:
|
||||
|
@ -71,7 +78,9 @@ if serv is not None and form.getvalue('config') is not None:
|
|||
except:
|
||||
pass
|
||||
if service == 'keepalived':
|
||||
stderr = funct.master_slave_upload_and_restart(serv, configver, just_save=save, keepalived=1)
|
||||
stderr = funct.upload_and_restart(serv, configver, just_save=save, keepalived=1)
|
||||
elif service == 'nginx':
|
||||
stderr = funct.master_slave_upload_and_restart(serv, configver, just_save=save, nginx=1)
|
||||
else:
|
||||
stderr = funct.master_slave_upload_and_restart(serv, configver, just_save=save)
|
||||
|
||||
|
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 109 KiB |
34
inc/add.js
|
@ -680,33 +680,24 @@ $( function() {
|
|||
});
|
||||
$( "#tabs" ).tabs( "option", "active", 0 );
|
||||
} );
|
||||
$( "#add4" ).on( "click", function() {
|
||||
$( "#add3" ).on( "click", function() {
|
||||
$('.menu li ul li').each(function () {
|
||||
$(this).find('a').css('padding-left', '20px')
|
||||
$(this).find('a').css('border-left', '0px solid #5D9CEB');
|
||||
$(this).children("#add4").css('padding-left', '30px');;
|
||||
$(this).children("#add4").css('border-left', '4px solid #5D9CEB');
|
||||
$(this).children("#add3").css('padding-left', '30px');
|
||||
$(this).children("#add3").css('border-left', '4px solid #5D9CEB');
|
||||
});
|
||||
$( "#tabs" ).tabs( "option", "active", 4 );
|
||||
} );
|
||||
$( "#add5" ).on( "click", function() {
|
||||
$('.menu li ul li').each(function () {
|
||||
$(this).find('a').css('padding-left', '20px')
|
||||
$(this).find('a').css('border-left', '0px solid #5D9CEB');
|
||||
$(this).children("#add5").css('padding-left', '30px');;
|
||||
$(this).children("#add5").css('border-left', '4px solid #5D9CEB');
|
||||
});
|
||||
$( "#add4" ).on( "click", function() {
|
||||
$( "#tabs" ).tabs( "option", "active", 5 );
|
||||
} );
|
||||
$( "#add6" ).on( "click", function() {
|
||||
$('.menu li ul li').each(function () {
|
||||
$(this).find('a').css('padding-left', '20px')
|
||||
$(this).find('a').css('border-left', '0px solid #5D9CEB');
|
||||
$(this).children("#add6").css('padding-left', '30px');
|
||||
$(this).children("#add6").css('border-left', '4px solid #5D9CEB');
|
||||
});
|
||||
$( "#add5" ).on( "click", function() {
|
||||
$( "#tabs" ).tabs( "option", "active", 6 );
|
||||
} );
|
||||
$( "#add6" ).on( "click", function() {
|
||||
$( "#tabs" ).tabs( "option", "active", 7 );
|
||||
} );
|
||||
$( "#add7" ).on( "click", function() {
|
||||
$('.menu li ul li').each(function () {
|
||||
$(this).find('a').css('padding-left', '20px')
|
||||
|
@ -714,15 +705,6 @@ $( function() {
|
|||
$(this).children("#add7").css('padding-left', '30px');
|
||||
$(this).children("#add7").css('border-left', '4px solid #5D9CEB');
|
||||
});
|
||||
$( "#tabs" ).tabs( "option", "active", 7 );
|
||||
} );
|
||||
$( "#add8" ).on( "click", function() {
|
||||
$('.menu li ul li').each(function () {
|
||||
$(this).find('a').css('padding-left', '20px')
|
||||
$(this).find('a').css('border-left', '0px solid #5D9CEB');
|
||||
$(this).children("#add8").css('padding-left', '30px');
|
||||
$(this).children("#add8").css('border-left', '4px solid #5D9CEB');
|
||||
});
|
||||
$( "#tabs" ).tabs( "option", "active", 8 );
|
||||
} );
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
.config-show::before {
|
||||
display: none;
|
||||
font-family: "Font Awesome 5 Solid";
|
||||
content: "\f10a";
|
||||
content: "\f6ff";
|
||||
}
|
||||
.compare::before {
|
||||
display: none;
|
||||
|
@ -107,6 +107,11 @@
|
|||
font-family: "Font Awesome 5 Solid";
|
||||
content: "\f126";
|
||||
}
|
||||
.nginx::before {
|
||||
display: none;
|
||||
font-family: "Font Awesome 5 Solid";
|
||||
content: "\f0e8";
|
||||
}
|
||||
.version::before {
|
||||
display: none;
|
||||
font-family: "Font Awesome 5 Solid";
|
||||
|
@ -185,4 +190,43 @@
|
|||
font-family: "Font Awesome 5 Solid";
|
||||
content: "\f093";
|
||||
padding-left: 5px;
|
||||
}
|
||||
.backends::before {
|
||||
display: none;
|
||||
font-family: "Font Awesome 5 Solid";
|
||||
content: "\f233";
|
||||
padding-left: 5px;
|
||||
}
|
||||
.div-pic::after {
|
||||
display: none;
|
||||
font-family: "Font Awesome 5 Solid";
|
||||
content: "\f303";
|
||||
}
|
||||
.fa-pencil-alt{
|
||||
padding-left: 7px;
|
||||
color: #5cb85c !important;
|
||||
}
|
||||
.service-start::after {
|
||||
display: none;
|
||||
font-family: "Font Awesome 5 Solid";
|
||||
content: "\f04b";
|
||||
}
|
||||
.fa-play, .fa-stop, .fa-sync-alt {
|
||||
width: 3px;
|
||||
color: #a0d100 !important;
|
||||
cursor: pointer;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
.service-stop::after {
|
||||
display: none;
|
||||
font-family: "Font Awesome 5 Solid";
|
||||
content: "\f04d";
|
||||
}
|
||||
.fa-stop {
|
||||
color: red !important;
|
||||
}
|
||||
.service-reload::after {
|
||||
display: none;
|
||||
font-family: "Font Awesome 5 Solid";
|
||||
content: "\f2f1";
|
||||
}
|
Before Width: | Height: | Size: 832 B |
Before Width: | Height: | Size: 722 B |
Before Width: | Height: | Size: 932 B |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 847 B |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 674 B |
109
inc/overview.js
|
@ -16,18 +16,19 @@ function showOverviewHapWI() {
|
|||
}
|
||||
} );
|
||||
}
|
||||
function showHapservers(serv, hostnamea) {
|
||||
function showHapservers(serv, hostnamea, service) {
|
||||
var i;
|
||||
for (i = 0; i < serv.length; i++) {
|
||||
showHapserversCallBack(serv[i], hostnamea[i])
|
||||
showHapserversCallBack(serv[i], hostnamea[i], service)
|
||||
}
|
||||
}
|
||||
function showHapserversCallBack(serv, hostnamea) {
|
||||
function showHapserversCallBack(serv, hostnamea, service) {
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
act: "overviewHapservers",
|
||||
serv: serv,
|
||||
service: service,
|
||||
token: $('#token').val()
|
||||
},
|
||||
beforeSend: function() {
|
||||
|
@ -41,7 +42,6 @@ function showHapserversCallBack(serv, hostnamea) {
|
|||
} );
|
||||
}
|
||||
function overviewHapserverBackends(serv, hostnamea) {
|
||||
console.log("#top-"+hostnamea)
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
|
@ -110,6 +110,7 @@ function showOverviewServer(name,ip,id) {
|
|||
$(".div-pannel").css('height', '70px');
|
||||
$("#div-pannel-"+id).insertBefore('#up-pannel')
|
||||
$("#ajax-server-"+id).html(data);
|
||||
$.getScript("/inc/fontawesome.min.js")
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
@ -139,6 +140,32 @@ function ajaxActionServers(action, id) {
|
|||
}
|
||||
} );
|
||||
}
|
||||
function ajaxActionNginxServers(action, id) {
|
||||
var bad_ans = 'Bad config, check please';
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
action_nginx: action,
|
||||
serv: id,
|
||||
token: $('#token').val()
|
||||
},
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if( data == 'Bad config, check please ' ) {
|
||||
alert(data);
|
||||
} else {
|
||||
if (cur_url[0] == "hapservers.py") {
|
||||
location.reload()
|
||||
} else {
|
||||
setTimeout(showOverview(ip, hostnamea), 2000)
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function(){
|
||||
alert(w.data_error);
|
||||
}
|
||||
} );
|
||||
}
|
||||
function ajaxActionWafServers(action, id) {
|
||||
var bad_ans = 'Bad config, check please';
|
||||
$.ajax( {
|
||||
|
@ -162,33 +189,6 @@ function ajaxActionWafServers(action, id) {
|
|||
} );
|
||||
}
|
||||
$( function() {
|
||||
$('.start').click(function() {
|
||||
var id = $(this).attr('id');
|
||||
id = id.split('-')[1]
|
||||
confirmAjaxAction("start", "hap", id);
|
||||
});
|
||||
$('.stop').click(function() {
|
||||
var id = $(this).attr('id');
|
||||
id = id.split('-')[1]
|
||||
confirmAjaxAction("stop", "hap", id);
|
||||
});
|
||||
$('.restart').click(function() {
|
||||
var id = $(this).attr('id');
|
||||
id = id.split('-')[1]
|
||||
confirmAjaxAction("restart", "hap", id);
|
||||
});
|
||||
$('.start-waf').click(function() {
|
||||
var id = $(this).attr('id');
|
||||
confirmAjaxAction("start", "waf", id);
|
||||
});
|
||||
$('.stop-waf').click(function() {
|
||||
var id = $(this).attr('id');
|
||||
confirmAjaxAction("stop", "waf", id);
|
||||
});
|
||||
$('.restart-waf').click(function() {
|
||||
var id = $(this).attr('id');
|
||||
confirmAjaxAction("restart", "waf", id);
|
||||
});
|
||||
$( "#show-all-users" ).click( function() {
|
||||
$( ".show-users" ).show("fast");
|
||||
$( "#show-all-users" ).text("Hide");
|
||||
|
@ -235,6 +235,10 @@ $( function() {
|
|||
$("#apply").css('display', 'none');
|
||||
Cookies.remove('restart', { path: '' });
|
||||
});
|
||||
$( ".server-act-links" ).change(function() {
|
||||
var id = $(this).attr('id').split('-');
|
||||
updateHapWIServer(id[1])
|
||||
});
|
||||
});
|
||||
function confirmAjaxAction(action, service, id) {
|
||||
$( "#dialog-confirm" ).dialog({
|
||||
|
@ -256,6 +260,8 @@ function confirmAjaxAction(action, service, id) {
|
|||
}
|
||||
} else if (service == "waf") {
|
||||
ajaxActionWafServers(action, id)
|
||||
} else if (service == "nginx") {
|
||||
ajaxActionNginxServers(action, id)
|
||||
}
|
||||
},
|
||||
Cancel: function() {
|
||||
|
@ -263,4 +269,45 @@ function confirmAjaxAction(action, service, id) {
|
|||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function updateHapWIServer(id) {
|
||||
var alert_en = 0;
|
||||
var metrics = 0;
|
||||
var active = 0;
|
||||
if ($('#alert-'+id).is(':checked')) {
|
||||
alert_en = '1';
|
||||
}
|
||||
if ($('#metrics-'+id).is(':checked')) {
|
||||
metrics = '1';
|
||||
}
|
||||
if ($('#active-'+id).is(':checked')) {
|
||||
active = '1';
|
||||
}
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
updatehapwiserver: id,
|
||||
metrics: metrics,
|
||||
alert_en: alert_en,
|
||||
active: active,
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data.indexOf('error') != '-1') {
|
||||
$("#ajax-servers").append(data);
|
||||
$('#errorMess').click(function() {
|
||||
$('#error').remove();
|
||||
$('.alert-danger').remove();
|
||||
});
|
||||
} else {
|
||||
$('.alert-danger').remove();
|
||||
$("#server-"+id).addClass( "update", 1000 );
|
||||
setTimeout(function() {
|
||||
$( "#server-"+id ).removeClass( "update" );
|
||||
}, 2500 );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
|
@ -7,7 +7,10 @@ $( function() {
|
|||
$('.menu li ul li').each(function () {
|
||||
var link = $(this).find('a').attr('href');
|
||||
var link2 = link.split('/')[2]
|
||||
if (cur_url[0] == link2 && cur_url[1] != 'service=keepalived') {
|
||||
if (cur_url[1] == null) {
|
||||
cur_url[1] = 'haproxy';
|
||||
}
|
||||
if (cur_url[0] == link2 && cur_url[1].split('&')[0] != 'service=keepalived' && cur_url[1].split('&')[0] != 'service=nginx') {
|
||||
$(this).parent().css('display', 'contents');
|
||||
$(this).parent().css('font-size', '13px');
|
||||
$(this).parent().css('top', '0');
|
||||
|
@ -16,7 +19,7 @@ $( function() {
|
|||
$(this).parent().find('a').css('padding-left', '20px');
|
||||
$(this).find('a').css('padding-left', '30px');
|
||||
$(this).find('a').css('border-left', '4px solid #5D9CEB');
|
||||
} else if(cur_url[0] == 'versions.py' && cur_url[1] == 'service=keepalived' && link2 == 'versions.py?service=keepalived'){
|
||||
} else if(cur_url[0] == 'versions.py' && cur_url[1].split('&')[0] == 'service=keepalived' && link2 == 'versions.py?service=keepalived'){
|
||||
$(this).parent().css('display', 'contents');
|
||||
$(this).parent().css('font-size', '13px');
|
||||
$(this).parent().css('top', '0');
|
||||
|
@ -25,7 +28,34 @@ $( function() {
|
|||
$(this).parent().find('a').css('padding-left', '20px');
|
||||
$(this).find('a').css('padding-left', '30px');
|
||||
$(this).find('a').css('border-left', '4px solid #5D9CEB');
|
||||
} else if(cur_url[0] == 'config.py' && cur_url[1] == 'service=keepalived' && link2 == 'config.py?service=keepalived'){
|
||||
} else if(cur_url[0] == 'config.py' && cur_url[1].split('&')[0] == 'service=keepalived' && link2 == 'config.py?service=keepalived'){
|
||||
$(this).parent().css('display', 'contents');
|
||||
$(this).parent().css('font-size', '13px');
|
||||
$(this).parent().css('top', '0');
|
||||
$(this).parent().css('left', '0');
|
||||
$(this).parent().children().css('margin-left', '-20px');
|
||||
$(this).parent().find('a').css('padding-left', '20px');
|
||||
$(this).find('a').css('padding-left', '30px');
|
||||
$(this).find('a').css('border-left', '4px solid #5D9CEB');
|
||||
} else if(cur_url[0] == 'versions.py' && cur_url[1].split('&')[0] == 'service=nginx' && link2 == 'versions.py?service=nginx'){
|
||||
$(this).parent().css('display', 'contents');
|
||||
$(this).parent().css('font-size', '13px');
|
||||
$(this).parent().css('top', '0');
|
||||
$(this).parent().css('left', '0');
|
||||
$(this).parent().children().css('margin-left', '-20px');
|
||||
$(this).parent().find('a').css('padding-left', '20px');
|
||||
$(this).find('a').css('padding-left', '30px');
|
||||
$(this).find('a').css('border-left', '4px solid #5D9CEB');
|
||||
} else if(cur_url[0] == 'config.py' && cur_url[1].split('&')[0] == 'service=nginx' && link2 == 'config.py?service=nginx'){
|
||||
$(this).parent().css('display', 'contents');
|
||||
$(this).parent().css('font-size', '13px');
|
||||
$(this).parent().css('top', '0');
|
||||
$(this).parent().css('left', '0');
|
||||
$(this).parent().children().css('margin-left', '-20px');
|
||||
$(this).parent().find('a').css('padding-left', '20px');
|
||||
$(this).find('a').css('padding-left', '30px');
|
||||
$(this).find('a').css('border-left', '4px solid #5D9CEB');
|
||||
} else if(cur_url[0] == 'hapservers.py' && cur_url[1].split('&')[0] == 'service=nginx' && link2 == 'hapservers.py?service=nginx'){
|
||||
$(this).parent().css('display', 'contents');
|
||||
$(this).parent().css('font-size', '13px');
|
||||
$(this).parent().css('top', '0');
|
||||
|
@ -124,13 +154,14 @@ function setRefreshInterval(interval) {
|
|||
if (interval == "0") {
|
||||
Cookies.remove('auto-refresh');
|
||||
pauseAutoRefresh();
|
||||
$('.auto-refresh').prepend('<img src=/inc/images/update.png alt="restart" class="icon">');
|
||||
$('.auto-refresh').prepend('<span class="service-reload"></span>');
|
||||
$('.auto-refresh').css('margin-top', '-3px');
|
||||
$('#1').text('Auto-refresh');
|
||||
$('#0').text('Auto-refresh');
|
||||
$('.auto-refresh-pause').css('display', 'none');
|
||||
$('.auto-refresh-resume').css('display', 'none');
|
||||
hideAutoRefreshDiv();
|
||||
$.getScript("/inc/fontawesome.min.js")
|
||||
} else {
|
||||
clearInterval(intervalId);
|
||||
Cookies.set('auto-refresh', interval, { expires: 365 });
|
||||
|
@ -216,12 +247,13 @@ function showStats() {
|
|||
data: {
|
||||
act: "stats",
|
||||
serv: $("#serv").val(),
|
||||
service: $("#service").val(),
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
$("#ajax").html(data);
|
||||
window.history.pushState("Stats", "Stats", cur_url[0]+"?serv="+$("#serv").val());
|
||||
window.history.pushState("Stats", "Stats", cur_url[0]+"?service="+$("#service").val()+"&serv="+$("#serv").val());
|
||||
wait();
|
||||
}
|
||||
} );
|
||||
|
@ -236,6 +268,8 @@ function openVersions() {
|
|||
var serv = $("#serv").val();
|
||||
if (cur_url[1] == "service=keepalived") {
|
||||
var url = "versions.py?service=keepalived&serv="+serv+"&open=open"
|
||||
} else if (cur_url[1] == "service=nginx") {
|
||||
var url = "versions.py?service=nginx&serv="+serv+"&open=open"
|
||||
} else {
|
||||
var url = "versions.py?serv="+serv+"&open=open"
|
||||
}
|
||||
|
@ -253,6 +287,7 @@ function showLog() {
|
|||
var minut = $('#time_range_out_minut').val()
|
||||
var hour1 = $('#time_range_out_hour1').val()
|
||||
var minut1 = $('#time_range_out_minut1').val()
|
||||
var service = $('#service').val()
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
|
@ -264,12 +299,13 @@ function showLog() {
|
|||
minut: minut,
|
||||
hour1: hour1,
|
||||
minut1: minut1,
|
||||
service: service,
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
$("#ajax").html(data);
|
||||
window.history.pushState("Logs", "Logs", cur_url[0]+"?serv="+$("#serv").val()+
|
||||
window.history.pushState("Logs", "Logs", cur_url[0]+"?service="+service+"&serv="+$("#serv").val()+
|
||||
'&rows='+rows+
|
||||
'&grep='+grep+
|
||||
'&hour='+hour+
|
||||
|
@ -328,6 +364,7 @@ function showCompare() {
|
|||
serv: $("#serv").val(),
|
||||
left: $('#left').val(),
|
||||
right: $("#right").val(),
|
||||
service: $("#service").val(),
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
|
@ -346,6 +383,7 @@ function showCompareConfigs() {
|
|||
serv: $("#serv").val(),
|
||||
act: "showCompareConfigs",
|
||||
open: "open",
|
||||
service: $("#service").val(),
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
|
@ -353,7 +391,7 @@ function showCompareConfigs() {
|
|||
$("#ajax-compare").html(data);
|
||||
$( "input[type=submit], button" ).button();
|
||||
$( "select" ).selectmenu();
|
||||
window.history.pushState("Show compare config", "Show compare config", cur_url[0]+'?serv='+$("#serv").val()+'&showCompare');
|
||||
window.history.pushState("Show compare config", "Show compare config", cur_url[0]+'?service='+$("#service").val()+'&serv='+$("#serv").val()+'&showCompare');
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
@ -393,7 +431,7 @@ function showUploadConfig() {
|
|||
type: "POST",
|
||||
success: function( data ) {
|
||||
$("#ajax").html(data);
|
||||
window.history.pushState("Show config", "Show config", cur_url[0]+"?serv="+serv+"&open=open&configver="+configver+"&service="+service);
|
||||
window.history.pushState("Show config", "Show config", cur_url[0]+"?service="+service+"&serv="+serv+"&open=open&configver="+configver);
|
||||
$.getScript('/inc/configshow.js');
|
||||
}
|
||||
} );
|
||||
|
@ -769,16 +807,33 @@ $( function() {
|
|||
$('#cur_hap_ver').text(data);
|
||||
$('#install').text('Update');
|
||||
$('#install').attr('title', 'Update HAProxy');
|
||||
$('#syn_flood').checkboxradio('disable');
|
||||
$('#syn_flood').prop( "checked", false );
|
||||
$('#syn_flood').checkboxradio('refresh');
|
||||
} else {
|
||||
$('#cur_hap_ver').text('HAProxy has not installed');
|
||||
$('#install').text('Install');
|
||||
$('#install').attr('title', 'Install HAProxy');
|
||||
$('#syn_flood').checkboxradio('enable');
|
||||
$('#syn_flood').prop( "checked", true );
|
||||
$('#syn_flood').checkboxradio('refresh');
|
||||
}
|
||||
}
|
||||
} );
|
||||
});
|
||||
$( "#nginxaddserv" ).on('selectmenuchange',function() {
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
get_nginx_v: 1,
|
||||
serv: $('#nginxaddserv option:selected').val(),
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/^\s+|\s+$/g,'');
|
||||
if(data.indexOf('bash') != '-1') {
|
||||
$('#cur_nginx_ver').text('Nginx has not installed');
|
||||
$('#nginx_install').text('Install');
|
||||
$('#nginx_install').attr('title', 'Install Nginx');
|
||||
} else {
|
||||
$('#cur_nginx_ver').text(data);
|
||||
$('#nginx_install').text('Update');
|
||||
$('#nginx_install').attr('title', 'Update Nginx');
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
|
|
@ -87,6 +87,7 @@ pre {
|
|||
z-index: 1000;
|
||||
display: block;
|
||||
background-color: #222a31;
|
||||
font-size: 12px;
|
||||
}
|
||||
.logoText {
|
||||
color: #EBF1F1;
|
||||
|
@ -289,10 +290,10 @@ pre {
|
|||
margin-left: 30px;
|
||||
position: fixed;
|
||||
margin-left: 65px;
|
||||
margin-top: 25px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
.line {
|
||||
background-color: #f5faf4;
|
||||
background-color: #f3f8fb;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
.line, .line3 {
|
||||
|
@ -747,7 +748,7 @@ label {
|
|||
.div-server, .div-server-hapwi {
|
||||
background-color: #fbfbfb;
|
||||
border: 1px solid #A4C7F5;
|
||||
height: 153px;
|
||||
height: 165px;
|
||||
width: 365px;
|
||||
padding: 20px;
|
||||
padding-top: 10px;
|
||||
|
@ -755,7 +756,7 @@ label {
|
|||
padding-right: 15px;
|
||||
margin: 20px;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 30px ;
|
||||
margin-bottom: 20px ;
|
||||
margin-top: 0px;
|
||||
display: block;
|
||||
float: left;
|
||||
|
@ -785,9 +786,8 @@ label {
|
|||
margin-top: 6px;
|
||||
}
|
||||
.server-desc {
|
||||
padding-bottom: 10px;
|
||||
color: #999;
|
||||
padding-top: 10px;
|
||||
padding-top: 5px;
|
||||
height: 80px;
|
||||
}
|
||||
.server-act-links {
|
||||
|
@ -806,30 +806,33 @@ label {
|
|||
margin: 25px;
|
||||
margin-left: 440px;
|
||||
margin-bottom: 0;
|
||||
width: 60em;
|
||||
width: 750px;
|
||||
display: none;
|
||||
margin-top: px;
|
||||
margin-bottom: 0px;
|
||||
margin-top: 0px;
|
||||
height: 183px;
|
||||
height: 185px;
|
||||
padding-bottom: 0px;
|
||||
padding-top: 10px;
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
}
|
||||
.haproxy-info {
|
||||
display: inline-block;
|
||||
width: 160px;
|
||||
padding-left: 30px;
|
||||
padding-top: 35px;
|
||||
padding-top: 15px;
|
||||
font-size: 12px;
|
||||
float: left;
|
||||
}
|
||||
.top-info {
|
||||
display: inline-block;
|
||||
width: 350px;
|
||||
margin-top: 30px;
|
||||
margin-top: 10px;
|
||||
font-size: 10px;
|
||||
}
|
||||
.update-icon {
|
||||
float: right;
|
||||
margin-top: 35px;
|
||||
margin-right: 15px;
|
||||
}
|
||||
.span-link {
|
||||
|
|
114
inc/users.js
|
@ -53,9 +53,13 @@ $( function() {
|
|||
var ipformat = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
|
||||
$('#create').click(function() {
|
||||
var hap = 0;
|
||||
var nginx = 0;
|
||||
var syn_flood = 0;
|
||||
if ($('#hap').is(':checked')) {
|
||||
hap = '1';
|
||||
}
|
||||
if ($('#nginx').is(':checked')) {
|
||||
nginx = '1';
|
||||
}
|
||||
if ($('#syn_flood').is(':checked')) {
|
||||
syn_flood = '1';
|
||||
|
@ -78,6 +82,7 @@ $( function() {
|
|||
interface: $("#interface").val(),
|
||||
vrrpip: $('#vrrp-ip').val(),
|
||||
hap: hap,
|
||||
nginx: nginx,
|
||||
syn_flood: syn_flood,
|
||||
token: $('#token').val()
|
||||
},
|
||||
|
@ -178,6 +183,41 @@ $( function() {
|
|||
}
|
||||
} );
|
||||
});
|
||||
$('#nginx_install').click(function() {
|
||||
$("#ajax").html('')
|
||||
var syn_flood = 0;
|
||||
if ($('#nginx_syn_flood').is(':checked')) {
|
||||
syn_flood = '1';
|
||||
}
|
||||
$("#ajax").html('<div class="alert alert-warning">Please don\'t close and don\'t represh page. Wait until the work is completed. This may take some time </div>');
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
install_nginx: $('#nginxaddserv').val(),
|
||||
syn_flood: syn_flood,
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data.indexOf('error') != '-1' || data.indexOf('FAILED') != '-1') {
|
||||
$("#ajax").html('<div class="alert alert-danger">'+data+'</div>');
|
||||
} else if (data.indexOf('success') != '-1' ){
|
||||
$('.alert-danger').remove();
|
||||
$('.alert-warning').remove();
|
||||
$("#ajax").html('<div class="alert alert-success">'+data+'</div>');
|
||||
} else if (data.indexOf('Info') != '-1' ){
|
||||
$('.alert-danger').remove();
|
||||
$('.alert-warning').remove();
|
||||
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
|
||||
} else {
|
||||
$('.alert-danger').remove();
|
||||
$('.alert-warning').remove();
|
||||
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
|
||||
}
|
||||
}
|
||||
} );
|
||||
});
|
||||
$('#update_haproxy_wi').click(function() {
|
||||
$("#ajax-update").html('')
|
||||
$("#ajax-update").html('<div class="alert alert-warning">Please don\'t close and don\'t represh page. Wait until the work is completed. This may take some time </div>');
|
||||
|
@ -623,23 +663,19 @@ function addServer() {
|
|||
var cred = $('#credentials').val();
|
||||
var typeip = 0;
|
||||
var enable = 0;
|
||||
var alert_en = 0;
|
||||
var metrics = 0;
|
||||
var active = 0;
|
||||
var haproxy = 0;
|
||||
var nginx = 0;
|
||||
if ($('#typeip').is(':checked')) {
|
||||
typeip = '1';
|
||||
}
|
||||
if ($('#enable').is(':checked')) {
|
||||
enable = '1';
|
||||
}
|
||||
if ($('#alert').is(':checked')) {
|
||||
var alert_en = '1';
|
||||
if ($('#haproxy').is(':checked')) {
|
||||
haproxy = '1';
|
||||
}
|
||||
if ($('#metrics').is(':checked')) {
|
||||
var metrics = '1';
|
||||
}
|
||||
if ($('#active').is(':checked')) {
|
||||
var active = '1';
|
||||
if ($('#nginx').is(':checked')) {
|
||||
nginx = '1';
|
||||
}
|
||||
allFields = $( [] ).add( $('#new-server-add') ).add( $('#new-ip') ).add( $('#new-port') )
|
||||
allFields.removeClass( "ui-state-error" );
|
||||
|
@ -656,14 +692,13 @@ function addServer() {
|
|||
newport: $('#new-port').val(),
|
||||
newservergroup: newservergroup,
|
||||
typeip: typeip,
|
||||
haproxy: haproxy,
|
||||
nginx: nginx,
|
||||
enable: enable,
|
||||
slave: $('#slavefor' ).val(),
|
||||
cred: cred,
|
||||
alert_en: alert_en,
|
||||
metrics: metrics,
|
||||
page: cur_url[0],
|
||||
desc: $('#desc').val(),
|
||||
active: active,
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
|
@ -909,25 +944,20 @@ function cloneServer(id) {
|
|||
} else {
|
||||
$('#typeip').prop('checked', false)
|
||||
}
|
||||
if ($('#alert-'+id).is(':checked')) {
|
||||
$('#alert').prop('checked', true)
|
||||
if ($('#haproxy-'+id).is(':checked')) {
|
||||
$('#haproxy').prop('checked', true)
|
||||
} else {
|
||||
$('#alert').prop('checked', false)
|
||||
$('#haproxy').prop('checked', false)
|
||||
}
|
||||
if ($('#metrics-'+id).is(':checked')) {
|
||||
$('#metrics').prop('checked', true)
|
||||
if ($('#nginx-'+id).is(':checked')) {
|
||||
$('#nginx').prop('checked', true)
|
||||
} else {
|
||||
$('#metrics').prop('checked', false)
|
||||
}
|
||||
if ($('#active-'+id).is(':checked')) {
|
||||
$('#active').prop('checked', true)
|
||||
} else {
|
||||
$('#active').prop('checked', false)
|
||||
$('#nginx').prop('checked', false)
|
||||
}
|
||||
$('#enable').checkboxradio("refresh");
|
||||
$('#typeip').checkboxradio("refresh");
|
||||
$('#alert').checkboxradio("refresh");
|
||||
$('#active').checkboxradio("refresh");
|
||||
$('#haproxy').checkboxradio("refresh");
|
||||
$('#nginx').checkboxradio("refresh");
|
||||
$('#new-server-add').val($('#hostname-'+id).val())
|
||||
$('#new-ip').val($('#ip-'+id).val())
|
||||
$('#new-port').val($('#port-'+id).val())
|
||||
|
@ -1161,28 +1191,27 @@ function updateServer(id) {
|
|||
$('.alert-danger').remove();
|
||||
var typeip = 0;
|
||||
var enable = 0;
|
||||
var alert_en = 0;
|
||||
var metrics = 0;
|
||||
var active = 0;
|
||||
var haproxy = 0;
|
||||
var nginx = 0;
|
||||
if ($('#typeip-'+id).is(':checked')) {
|
||||
typeip = '1';
|
||||
}
|
||||
if ($('#haproxy-'+id).is(':checked')) {
|
||||
haproxy = '1';
|
||||
}
|
||||
if ($('#nginx-'+id).is(':checked')) {
|
||||
nginx = '1';
|
||||
}
|
||||
if ($('#enable-'+id).is(':checked')) {
|
||||
enable = '1';
|
||||
}
|
||||
if ($('#alert-'+id).is(':checked')) {
|
||||
alert_en = '1';
|
||||
}
|
||||
if ($('#metrics-'+id).is(':checked')) {
|
||||
metrics = '1';
|
||||
}
|
||||
if ($('#active-'+id).is(':checked')) {
|
||||
active = '1';
|
||||
}
|
||||
var servergroup = $('#servergroup-'+id+' option:selected' ).val();
|
||||
if (cur_url[0] == "servers.py") {
|
||||
servergroup = $('#servergroup-'+id).val();
|
||||
console.log(cur_url[0])
|
||||
if (cur_url[0].split('#')[0] == "servers.py") {
|
||||
servergroup = $('#new-server-group-add').val();
|
||||
console.log('1')
|
||||
}
|
||||
console.log(servergroup)
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
|
@ -1190,14 +1219,13 @@ function updateServer(id) {
|
|||
port: $('#port-'+id).val(),
|
||||
servergroup: servergroup,
|
||||
typeip: typeip,
|
||||
haproxy: haproxy,
|
||||
nginx: nginx,
|
||||
enable: enable,
|
||||
slave: $('#slavefor-'+id+' option:selected' ).val(),
|
||||
cred: $('#credentials-'+id+' option:selected').val(),
|
||||
id: id,
|
||||
metrics: metrics,
|
||||
alert_en: alert_en,
|
||||
desc: $('#desc-'+id).val(),
|
||||
active: active,
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
var awesome = "/inc/fontawesome.min.js"
|
||||
|
||||
$( function() {
|
||||
$( "#ajaxwafstatus input" ).change(function() {
|
||||
var id = $(this).attr('id');
|
||||
|
@ -32,6 +34,7 @@ function showOverviewWafCallBack(serv, hostnamea) {
|
|||
$( "input[type=submit], button" ).button();
|
||||
$( "input[type=checkbox]" ).checkboxradio();
|
||||
$.getScript('/inc/overview.js');
|
||||
$.getScript(awesome);
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
|