mirror of https://github.com/Aidaho12/haproxy-wi
parent
0ae15ae4c6
commit
64091f2a9f
60
README.md
60
README.md
|
@ -15,36 +15,36 @@ Web interface(user-friendly web GUI, alerting, monitoring and secure) for managi
|
||||||

|

|
||||||
|
|
||||||
# Features:
|
# Features:
|
||||||
1. Configure HAProxy and Keepalived In a jiffy with HAProxy-WI
|
1. Installation and updating HAProxy, Nginx and Keepalived with HAProxy-WI
|
||||||
2. View and analyse Status of all Frontend/backend server via HAProxy-WI from a single control panel.
|
2. Configure HAProxy, Nginx and Keepalived In a jiffy with HAProxy-WI
|
||||||
3. Enable/disable servers through stats page without rebooting HAProxy
|
3. View and analyse Status of all Frontend/backend server via HAProxy-WI from a single control panel.
|
||||||
4. View/Analyse HAproxy logs straight from the HAProxy-WI web interface
|
4. Enable/disable servers through stats page without rebooting HAProxy
|
||||||
5. Create and visualise the HAProxy workflow from Web Ui.
|
5. View/Analyse HAproxy, Nginx logs straight from the HAProxy-WI web interface
|
||||||
6. Push Your changes to your HAProxy and Keepalived servers with a single click through web interface
|
6. Create and visualise the HAProxy workflow from Web Ui.
|
||||||
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
|
7. Push Your changes to your HAProxy, Nginx and Keepalived servers with a single click through web interface
|
||||||
8. Add/Edit Frontend or backend servers via web interface with a click of a button.
|
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. Edit config of HAProxy, Keepalived and push changes to All Master/Slave server with a single click
|
9. Add/Edit Frontend or backend servers via web interface with a click of a button.
|
||||||
10. Add Multiple server to ensure Config Sync between servers.
|
10. Edit config of HAProxy, Nginx, Keepalived and push changes to All Master/Slave server with a single click
|
||||||
11. Auto management of ports assigned to Fronted.
|
11. Add Multiple server to ensure Config Sync between servers.
|
||||||
12. Evaluate the changes of recent configs pushed to HAProxy and Keepalived instances straight from web ui
|
12. Auto management of ports assigned to Fronted.
|
||||||
13. Multiple User Roles support for privileged based Viewing and editing of Config
|
13. Evaluate the changes of recent configs pushed to HAProxy, Nginx and Keepalived instances straight from web ui
|
||||||
14. Create Groups and add /remove servers to ensure proper identification for your HAProxy Clusters
|
14. Multiple User Roles support for privileged based Viewing and editing of Config
|
||||||
15. Send notifications to telegram directly from HAProxy-WI
|
15. Create Groups and add /remove servers to ensure proper identification for your HAProxy Clusters
|
||||||
16. HAProxy-WI supports high Availability to ensure uptime to all Master slave servers configured
|
16. Send notifications to telegram directly from HAProxy-WI
|
||||||
17. SSL certificate support.
|
17. HAProxy-WI supports high Availability to ensure uptime to all Master slave servers configured
|
||||||
18. SSH Key support for managing multiple HAProxy Servers straight from HAProxy-WI
|
18. SSL certificate support.
|
||||||
19. SYN flood protect
|
19. SSH Key support for managing multiple HAProxy Servers straight from HAProxy-WI
|
||||||
20. Alerting about changes backends state
|
20. SYN flood protect
|
||||||
21. Alerting about HAProxy service state
|
21. Alerting about changes backends state
|
||||||
22. Metrics incoming connections
|
22. Alerting about HAProxy service state
|
||||||
23. Web acceleration settings
|
23. Metrics incoming connections
|
||||||
24. Web application firewall
|
24. Web acceleration settings
|
||||||
25. LDAP support
|
25. Web application firewall
|
||||||
26. Keep active HAProxy service
|
26. LDAP support
|
||||||
27. Ability to hide parts of the config with tags for users with "guest" role: "HideBlockStart" and "HideBlockEnd"
|
27. Keep active HAProxy service
|
||||||
28. Mobile-ready desing
|
28. Ability to hide parts of the config with tags for users with "guest" role: "HideBlockStart" and "HideBlockEnd"
|
||||||
29. REST API
|
29. Mobile-ready desing
|
||||||
30. Installation and Upgrading HAProxy service via HAProxy-WI
|
30. REST API
|
||||||
31. Backup HAProxy's and Keepalived's config files through HAProxy-WI
|
31. Backup HAProxy's and Keepalived's config files through HAProxy-WI
|
||||||
|
|
||||||

|

|
||||||
|
|
|
@ -35,15 +35,19 @@ if service == 'keepalived':
|
||||||
action = "config.py?service=keepalived"
|
action = "config.py?service=keepalived"
|
||||||
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
||||||
format = 'conf'
|
format = 'conf'
|
||||||
servers = sql.get_dick_permit()
|
servers = sql.is_master('123', master_slave=1)
|
||||||
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:
|
else:
|
||||||
title = "Working with HAProxy configs"
|
title = "Working with HAProxy configs"
|
||||||
action = "config.py"
|
action = "config.py"
|
||||||
configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||||
format = 'cfg'
|
format = 'cfg'
|
||||||
servers = sql.get_dick_permit()
|
servers = sql.get_dick_permit()
|
||||||
keepalived = 0
|
|
||||||
|
|
||||||
if serv is not None:
|
if serv is not None:
|
||||||
cfg = configs_dir + serv + "-" + funct.get_data('config') + "."+format
|
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':
|
if service == 'keepalived':
|
||||||
error = funct.get_config(serv, cfg, keepalived=1)
|
error = funct.get_config(serv, cfg, keepalived=1)
|
||||||
try:
|
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:
|
except:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
error = funct.get_config(serv, cfg)
|
error = funct.get_config(serv, cfg)
|
||||||
try:
|
try:
|
||||||
funct.logging(serv, "config.py open config")
|
funct.logging(serv, " HAProxy config has opened ")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -90,6 +100,8 @@ if serv is not None and form.getvalue('config') is not None:
|
||||||
|
|
||||||
if service == 'keepalived':
|
if service == 'keepalived':
|
||||||
stderr = funct.upload_and_restart(serv, cfg, just_save=save, keepalived=1)
|
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:
|
else:
|
||||||
stderr = funct.master_slave_upload_and_restart(serv, cfg, just_save=save)
|
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,
|
error = error,
|
||||||
note = 1,
|
note = 1,
|
||||||
versions = funct.versions(),
|
versions = funct.versions(),
|
||||||
keepalived = keepalived,
|
service = service,
|
||||||
token = token)
|
token = token)
|
||||||
print(template)
|
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('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('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('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_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('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');")
|
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('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', '/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('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('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('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_enable', '0', 'ldap', 'If 1 ldap enabled');")
|
||||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('ldap_server', '', 'ldap', 'IP address ldap server');")
|
sql.append("INSERT INTO settings (param, value, section, `desc`) values('ldap_server', '', 'ldap', 'IP address ldap server');")
|
||||||
|
@ -371,12 +371,80 @@ def update_db_v_3_13(**kwargs):
|
||||||
except sqltool.Error as e:
|
except sqltool.Error as e:
|
||||||
if kwargs.get('silent') != 1:
|
if kwargs.get('silent') != 1:
|
||||||
if e.args[0] == 'duplicate column name: keepalived' or e == " 1060 (42S21): Duplicate column name 'keepalived' ":
|
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:
|
else:
|
||||||
print("An error occurred:", e)
|
print("An error occurred:", e)
|
||||||
return False
|
return False
|
||||||
else:
|
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("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 = 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';")
|
||||||
|
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_42(**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('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
|
return True
|
||||||
cur.close()
|
cur.close()
|
||||||
con.close()
|
con.close()
|
||||||
|
@ -384,7 +452,7 @@ def update_db_v_3_13(**kwargs):
|
||||||
|
|
||||||
def update_ver(**kwargs):
|
def update_ver(**kwargs):
|
||||||
con, cur = get_cur()
|
con, cur = get_cur()
|
||||||
sql = """update version set version = '3.13.0.0'; """
|
sql = """update version set version = '4.0.0.0'; """
|
||||||
try:
|
try:
|
||||||
cur.execute(sql)
|
cur.execute(sql)
|
||||||
con.commit()
|
con.commit()
|
||||||
|
@ -406,6 +474,9 @@ def update_all():
|
||||||
update_db_v_3_12()
|
update_db_v_3_12()
|
||||||
update_db_v_3_12_1()
|
update_db_v_3_12_1()
|
||||||
update_db_v_3_13()
|
update_db_v_3_13()
|
||||||
|
update_db_v_4()
|
||||||
|
update_db_v_41()
|
||||||
|
update_db_v_42()
|
||||||
update_ver()
|
update_ver()
|
||||||
|
|
||||||
|
|
||||||
|
@ -421,6 +492,9 @@ def update_all_silent():
|
||||||
update_db_v_3_12(silent=1)
|
update_db_v_3_12(silent=1)
|
||||||
update_db_v_3_12_1(silent=1)
|
update_db_v_3_12_1(silent=1)
|
||||||
update_db_v_3_13(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()
|
update_ver()
|
||||||
|
|
||||||
|
|
||||||
|
|
51
app/funct.py
51
app/funct.py
|
@ -231,16 +231,22 @@ def ssh_connect(serv, **kwargs):
|
||||||
def get_config(serv, cfg, **kwargs):
|
def get_config(serv, cfg, **kwargs):
|
||||||
import sql
|
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)
|
ssh = ssh_connect(serv)
|
||||||
try:
|
try:
|
||||||
sftp = ssh.open_sftp()
|
sftp = ssh.open_sftp()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging('localhost', ssh, haproxywi=1)
|
logging('localhost', str(e), haproxywi=1)
|
||||||
try:
|
try:
|
||||||
sftp.get(config_path, cfg)
|
sftp.get(config_path, cfg)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging('localhost', ssh, haproxywi=1)
|
logging('localhost', str(e), haproxywi=1)
|
||||||
try:
|
try:
|
||||||
sftp.close()
|
sftp.close()
|
||||||
ssh.close()
|
ssh.close()
|
||||||
|
@ -495,7 +501,13 @@ def upload(serv, path, file, **kwargs):
|
||||||
|
|
||||||
def upload_and_restart(serv, cfg, **kwargs):
|
def upload_and_restart(serv, cfg, **kwargs):
|
||||||
import sql
|
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 = ""
|
error = ""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -509,15 +521,22 @@ def upload_and_restart(serv, cfg, **kwargs):
|
||||||
commands = [ "sudo mv -f " + tmp_file + " /etc/keepalived/keepalived.conf" ]
|
commands = [ "sudo mv -f " + tmp_file + " /etc/keepalived/keepalived.conf" ]
|
||||||
else:
|
else:
|
||||||
commands = [ "sudo mv -f " + tmp_file + " /etc/keepalived/keepalived.conf && sudo systemctl restart keepalived" ]
|
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:
|
else:
|
||||||
if kwargs.get("just_save") == "test":
|
if kwargs.get("just_save") == "test":
|
||||||
commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo rm -f " + tmp_file ]
|
commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo rm -f " + tmp_file ]
|
||||||
elif kwargs.get("just_save") == "save":
|
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":
|
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:
|
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":
|
if sql.get_setting('firewall_enable') == "1":
|
||||||
commands.extend(open_port_firewalld(cfg))
|
commands.extend(open_port_firewalld(cfg))
|
||||||
error += str(upload(serv, tmp_file, cfg, dir='fullpath'))
|
error += str(upload(serv, tmp_file, cfg, dir='fullpath'))
|
||||||
|
@ -538,9 +557,9 @@ def master_slave_upload_and_restart(serv, cfg, just_save, **kwargs):
|
||||||
error = ""
|
error = ""
|
||||||
for master in MASTERS:
|
for master in MASTERS:
|
||||||
if master[0] != None:
|
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
|
return error
|
||||||
|
|
||||||
|
@ -592,7 +611,7 @@ def show_log(stdout, **kwargs):
|
||||||
return out
|
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
|
import sql
|
||||||
date = hour+':'+minut
|
date = hour+':'+minut
|
||||||
date1 = hour1+':'+minut1
|
date1 = hour1+':'+minut1
|
||||||
|
@ -604,9 +623,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')
|
syslog_server_enable = sql.get_setting('syslog_server_enable')
|
||||||
if syslog_server_enable is None or syslog_server_enable == "0":
|
if syslog_server_enable is None or syslog_server_enable == "0":
|
||||||
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
|
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:
|
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) ]
|
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')
|
syslog_server = sql.get_setting('syslog_server')
|
||||||
|
@ -614,7 +639,7 @@ def show_haproxy_log(serv, rows=10, waf='0', grep=None, hour='00', minut='00', h
|
||||||
if waf == "1":
|
if waf == "1":
|
||||||
local_path_logs = '/var/log/modsec_audit.log'
|
local_path_logs = '/var/log/modsec_audit.log'
|
||||||
commands = [ "sudo cat %s |tail -%s %s %s" % (local_path_logs, rows, grep_act, grep) ]
|
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:
|
if kwargs.get('html') == 0:
|
||||||
a = ssh_command(syslog_server, commands)
|
a = ssh_command(syslog_server, commands)
|
||||||
|
|
|
@ -7,6 +7,7 @@ log_path = ${fullpath}/log/
|
||||||
#Dir where configs will be save
|
#Dir where configs will be save
|
||||||
haproxy_save_configs_dir = ${main:fullpath}/configs/hap_config/
|
haproxy_save_configs_dir = ${main:fullpath}/configs/hap_config/
|
||||||
kp_save_configs_dir = ${main:fullpath}/configs/kp_config/
|
kp_save_configs_dir = ${main:fullpath}/configs/kp_config/
|
||||||
|
nginx_save_configs_dir = ${main:fullpath}/configs/nginx_config/
|
||||||
|
|
||||||
[mysql]
|
[mysql]
|
||||||
#Enable MySQL DB. Default will be used Sqlite DB. Default disable
|
#Enable MySQL DB. Default will be used Sqlite DB. Default disable
|
||||||
|
|
|
@ -16,38 +16,60 @@ try:
|
||||||
users = sql.select_users()
|
users = sql.select_users()
|
||||||
groups = sql.select_groups()
|
groups = sql.select_groups()
|
||||||
token = sql.get_token(user_id.value)
|
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:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
form = funct.form
|
form = funct.form
|
||||||
serv = form.getvalue('serv')
|
serv = form.getvalue('serv')
|
||||||
|
service = form.getvalue('service')
|
||||||
|
autorefresh = 0
|
||||||
|
|
||||||
if serv:
|
if service == 'nginx':
|
||||||
servers = sql.select_servers(server=serv)
|
title = "Nginx servers overview"
|
||||||
autorefresh = 1
|
keep_alive = ''
|
||||||
|
stderr = ''
|
||||||
|
servers = sql.get_dick_permit(nginx=1)
|
||||||
|
service = 'nginx'
|
||||||
else:
|
else:
|
||||||
servers = sql.get_dick_permit()
|
title = "HAProxy servers overview"
|
||||||
autorefresh = 0
|
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()
|
||||||
|
|
||||||
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
|
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
|
||||||
servers_with_status1 = []
|
servers_with_status1 = []
|
||||||
out1 = ""
|
out1 = ''
|
||||||
for s in servers:
|
for s in servers:
|
||||||
servers_with_status = list()
|
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[0])
|
||||||
servers_with_status.append(s[1])
|
servers_with_status.append(s[1])
|
||||||
servers_with_status.append(s[2])
|
servers_with_status.append(s[2])
|
||||||
servers_with_status.append(s[11])
|
servers_with_status.append(s[11])
|
||||||
for k in out:
|
if service == 'nginx':
|
||||||
if "Ncat:" not in k:
|
cmd = [ "/usr/sbin/nginx -v && systemctl status nginx |grep -e 'Active\|Tasks' |awk '{print $2, $9}'" ]
|
||||||
out1 = out
|
out = funct.ssh_command(s[2], cmd)
|
||||||
else:
|
h = ()
|
||||||
out1 = False
|
out1 = []
|
||||||
servers_with_status.append(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(s[12])
|
||||||
servers_with_status.append(sql.is_master(s[2]))
|
servers_with_status.append(sql.is_master(s[2]))
|
||||||
servers_with_status.append(sql.select_servers(server=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,
|
template = template.render(h2 = 1,
|
||||||
autorefresh = autorefresh,
|
autorefresh = autorefresh,
|
||||||
title = "HAProxy servers overview",
|
title = title,
|
||||||
role = sql.get_user_role_by_uuid(user_id.value),
|
role = sql.get_user_role_by_uuid(user_id.value),
|
||||||
user = user,
|
user = user,
|
||||||
users = users,
|
users = users,
|
||||||
|
@ -66,5 +88,6 @@ template = template.render(h2 = 1,
|
||||||
versions = funct.versions(),
|
versions = funct.versions(),
|
||||||
keep_alive = ''.join(keep_alive),
|
keep_alive = ''.join(keep_alive),
|
||||||
serv = serv,
|
serv = serv,
|
||||||
|
service = service,
|
||||||
token = token)
|
token = token)
|
||||||
print(template)
|
print(template)
|
||||||
|
|
44
app/logs.py
44
app/logs.py
|
@ -24,6 +24,7 @@ hour1 = form.getvalue('hour1')
|
||||||
minut = form.getvalue('minut')
|
minut = form.getvalue('minut')
|
||||||
minut1 = form.getvalue('minut1')
|
minut1 = form.getvalue('minut1')
|
||||||
waf = form.getvalue('waf')
|
waf = form.getvalue('waf')
|
||||||
|
service = form.getvalue('service')
|
||||||
|
|
||||||
print('Content-type: text/html\n')
|
print('Content-type: text/html\n')
|
||||||
funct.check_login()
|
funct.check_login()
|
||||||
|
@ -37,26 +38,31 @@ try:
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if service == 'nginx':
|
||||||
|
title = "Nginx`s logs"
|
||||||
|
else:
|
||||||
|
title = "HAProxy`s logs"
|
||||||
|
|
||||||
output_from_parsed_template = template.render(h2 = 1,
|
template = template.render(h2 = 1,
|
||||||
autorefresh = 1,
|
autorefresh = 1,
|
||||||
title = "HAProxy`s logs",
|
title = title,
|
||||||
role = sql.get_user_role_by_uuid(user_id.value),
|
role = sql.get_user_role_by_uuid(user_id.value),
|
||||||
user = user,
|
user = user,
|
||||||
onclick = "showLog()",
|
onclick = "showLog()",
|
||||||
select_id = "serv",
|
select_id = "serv",
|
||||||
selects = servers,
|
selects = servers,
|
||||||
serv = form.getvalue('serv'),
|
serv = form.getvalue('serv'),
|
||||||
rows = rows,
|
rows = rows,
|
||||||
grep = grep,
|
grep = grep,
|
||||||
hour = hour,
|
hour = hour,
|
||||||
hour1 = hour1,
|
hour1 = hour1,
|
||||||
minut = minut,
|
minut = minut,
|
||||||
minut1 = minut1,
|
minut1 = minut1,
|
||||||
waf = waf,
|
waf = waf,
|
||||||
versions = funct.versions(),
|
versions = funct.versions(),
|
||||||
token = token)
|
service = service,
|
||||||
print(output_from_parsed_template)
|
token = token)
|
||||||
|
print(template)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
128
app/options.py
128
app/options.py
|
@ -112,6 +112,18 @@ if form.getvalue('action_hap') is not None and serv is not None:
|
||||||
print("Bad config, check please")
|
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:
|
if form.getvalue('action_waf') is not None and serv is not None:
|
||||||
serv = form.getvalue('serv')
|
serv = form.getvalue('serv')
|
||||||
action = form.getvalue('action_waf')
|
action = form.getvalue('action_waf')
|
||||||
|
@ -148,8 +160,11 @@ if act == "overviewHapserverBackends":
|
||||||
|
|
||||||
|
|
||||||
if act == "overviewHapservers":
|
if act == "overviewHapservers":
|
||||||
haproxy_config_path = sql.get_setting('haproxy_config_path')
|
if form.getvalue('service') == 'nginx':
|
||||||
commands = [ "ls -l %s |awk '{ print $6\" \"$7\" \"$8}'" % haproxy_config_path ]
|
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:
|
try:
|
||||||
print(funct.ssh_command(serv, commands))
|
print(funct.ssh_command(serv, commands))
|
||||||
except:
|
except:
|
||||||
|
@ -168,14 +183,22 @@ if act == "overview":
|
||||||
keepalived_process = funct.ssh_command(serv2, command)
|
keepalived_process = funct.ssh_command(serv2, command)
|
||||||
else:
|
else:
|
||||||
keepalived_process = ''
|
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,
|
server_status = (serv1,
|
||||||
serv2,
|
serv2,
|
||||||
funct.server_status(funct.subprocess_execute(cmd)),
|
funct.server_status(funct.subprocess_execute(cmd)),
|
||||||
sql.select_servers(server=serv2, keep_alive=1),
|
sql.select_servers(server=serv2, keep_alive=1),
|
||||||
funct.ssh_command(serv2, commands2),
|
funct.ssh_command(serv2, commands2),
|
||||||
sql.select_waf_servers(serv2),
|
sql.select_waf_servers(serv2),
|
||||||
sql.select_keealived(serv2),
|
keepalived,
|
||||||
keepalived_process)
|
keepalived_process,
|
||||||
|
nginx,
|
||||||
|
nginx_process)
|
||||||
return server_status
|
return server_status
|
||||||
|
|
||||||
|
|
||||||
|
@ -355,7 +378,8 @@ if serv is not None and form.getvalue('rows') is not None:
|
||||||
minut = form.getvalue('minut')
|
minut = form.getvalue('minut')
|
||||||
hour1 = form.getvalue('hour1')
|
hour1 = form.getvalue('hour1')
|
||||||
minut1 = form.getvalue('minut1')
|
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)
|
print(out)
|
||||||
|
|
||||||
|
|
||||||
|
@ -550,7 +574,12 @@ if act == "showCompareConfigs":
|
||||||
left = form.getvalue('left')
|
left = form.getvalue('left')
|
||||||
right = form.getvalue('right')
|
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)
|
print(template)
|
||||||
|
|
||||||
|
|
||||||
|
@ -558,8 +587,11 @@ if serv is not None and form.getvalue('right') is not None:
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
left = form.getvalue('left')
|
left = form.getvalue('left')
|
||||||
right = form.getvalue('right')
|
right = form.getvalue('right')
|
||||||
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
if form.getvalue('service') == 'nginx':
|
||||||
cmd='diff -ub %s%s %s%s' % (hap_configs_dir, left, hap_configs_dir, right)
|
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"])
|
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True, extensions=["jinja2.ext.loopcontrols", "jinja2.ext.do"])
|
||||||
template = env.get_template('ajax/compare.html')
|
template = env.get_template('ajax/compare.html')
|
||||||
|
|
||||||
|
@ -573,6 +605,8 @@ if serv is not None and form.getvalue('right') is not None:
|
||||||
if serv is not None and act == "configShow":
|
if serv is not None and act == "configShow":
|
||||||
if form.getvalue('service') == 'keepalived':
|
if form.getvalue('service') == 'keepalived':
|
||||||
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
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:
|
else:
|
||||||
configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||||
|
|
||||||
|
@ -581,11 +615,10 @@ if serv is not None and act == "configShow":
|
||||||
funct.get_config(serv, cfg)
|
funct.get_config(serv, cfg)
|
||||||
else:
|
else:
|
||||||
cfg = configs_dir + form.getvalue('configver')
|
cfg = configs_dir + form.getvalue('configver')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
conf = open(cfg, "r")
|
conf = open(cfg, "r")
|
||||||
except IOError:
|
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
|
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"])
|
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True, trim_blocks=True, lstrip_blocks=True, extensions=["jinja2.ext.loopcontrols", "jinja2.ext.do"])
|
||||||
|
@ -828,6 +861,56 @@ if form.getvalue('backup') or form.getvalue('deljob') or form.getvalue('backupup
|
||||||
funct.logging('backup ', ' has updated a backup job for server '+server, haproxywi=1, login=1)
|
funct.logging('backup ', ' has updated a backup job for server '+server, haproxywi=1, login=1)
|
||||||
|
|
||||||
|
|
||||||
|
if form.getvalue('install_nginx'):
|
||||||
|
script = "install_nginx.sh"
|
||||||
|
serv = form.getvalue('install_nginx')
|
||||||
|
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 = funct.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 = funct.subprocess_execute(commands[0])
|
||||||
|
|
||||||
|
if error:
|
||||||
|
funct.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)
|
||||||
|
|
||||||
|
|
||||||
if form.getvalue('haproxyaddserv'):
|
if form.getvalue('haproxyaddserv'):
|
||||||
funct.install_haproxy(form.getvalue('haproxyaddserv'), syn_flood=form.getvalue('syn_flood'), hapver=form.getvalue('hapver'))
|
funct.install_haproxy(form.getvalue('haproxyaddserv'), syn_flood=form.getvalue('syn_flood'), hapver=form.getvalue('hapver'))
|
||||||
|
|
||||||
|
@ -916,6 +999,11 @@ if form.getvalue('get_hap_v'):
|
||||||
print(output)
|
print(output)
|
||||||
|
|
||||||
|
|
||||||
|
if form.getvalue('get_nginx_v'):
|
||||||
|
cmd = [ "/usr/sbin/nginx -v" ]
|
||||||
|
print(funct.ssh_command(serv, cmd))
|
||||||
|
|
||||||
|
|
||||||
if form.getvalue('bwlists'):
|
if form.getvalue('bwlists'):
|
||||||
list = os.path.dirname(os.getcwd())+"/"+sql.get_setting('lists_path')+"/"+form.getvalue('group')+"/"+form.getvalue('color')+"/"+form.getvalue('bwlists')
|
list = os.path.dirname(os.getcwd())+"/"+sql.get_setting('lists_path')+"/"+form.getvalue('group')+"/"+form.getvalue('color')+"/"+form.getvalue('bwlists')
|
||||||
try:
|
try:
|
||||||
|
@ -1093,15 +1181,12 @@ if form.getvalue('newserver') is not None:
|
||||||
enable = form.getvalue('enable')
|
enable = form.getvalue('enable')
|
||||||
master = form.getvalue('slave')
|
master = form.getvalue('slave')
|
||||||
cred = form.getvalue('cred')
|
cred = form.getvalue('cred')
|
||||||
alert = form.getvalue('alert_en')
|
|
||||||
metrics = form.getvalue('metrics')
|
|
||||||
page = form.getvalue('page')
|
page = form.getvalue('page')
|
||||||
page = page.split("#")[0]
|
page = page.split("#")[0]
|
||||||
port = form.getvalue('newport')
|
port = form.getvalue('newport')
|
||||||
desc = form.getvalue('desc')
|
desc = form.getvalue('desc')
|
||||||
active = form.getvalue('active')
|
|
||||||
|
|
||||||
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):
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
env = Environment(loader=FileSystemLoader('templates/'))
|
env = Environment(loader=FileSystemLoader('templates/'))
|
||||||
template = env.get_template('ajax/new_server.html')
|
template = env.get_template('ajax/new_server.html')
|
||||||
|
@ -1116,6 +1201,15 @@ if form.getvalue('newserver') is not None:
|
||||||
funct.logging('a new server '+hostname, ' has created ', haproxywi=1, login=1)
|
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:
|
if form.getvalue('updateserver') is not None:
|
||||||
name = form.getvalue('updateserver')
|
name = form.getvalue('updateserver')
|
||||||
group = form.getvalue('servergroup')
|
group = form.getvalue('servergroup')
|
||||||
|
@ -1124,15 +1218,13 @@ if form.getvalue('updateserver') is not None:
|
||||||
master = form.getvalue('slave')
|
master = form.getvalue('slave')
|
||||||
id = form.getvalue('id')
|
id = form.getvalue('id')
|
||||||
cred = form.getvalue('cred')
|
cred = form.getvalue('cred')
|
||||||
alert = form.getvalue('alert_en')
|
|
||||||
metrics = form.getvalue('metrics')
|
|
||||||
port = form.getvalue('port')
|
port = form.getvalue('port')
|
||||||
desc = form.getvalue('desc')
|
desc = form.getvalue('desc')
|
||||||
active = form.getvalue('active')
|
|
||||||
if name is None or port is None:
|
if name is None or port is None:
|
||||||
print(error_mess)
|
print(error_mess)
|
||||||
else:
|
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)
|
||||||
funct.logging('the server '+name, ' has updated ', haproxywi=1, login=1)
|
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;
|
||||||
|
#}
|
||||||
|
}
|
||||||
|
|
|
@ -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
|
89
app/sql.py
89
app/sql.py
|
@ -125,6 +125,7 @@ def add_group(name, description):
|
||||||
cur.close()
|
cur.close()
|
||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
|
|
||||||
def delete_group(id):
|
def delete_group(id):
|
||||||
con, cur = get_cur()
|
con, cur = get_cur()
|
||||||
sql = """ delete from groups where id = '%s'""" % (id)
|
sql = """ delete from groups where id = '%s'""" % (id)
|
||||||
|
@ -139,6 +140,7 @@ def delete_group(id):
|
||||||
cur.close()
|
cur.close()
|
||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
|
|
||||||
def update_group(name, descript, id):
|
def update_group(name, descript, id):
|
||||||
con, cur = get_cur()
|
con, cur = get_cur()
|
||||||
sql = """ update groups set
|
sql = """ update groups set
|
||||||
|
@ -158,11 +160,12 @@ def update_group(name, descript, id):
|
||||||
cur.close()
|
cur.close()
|
||||||
con.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):
|
||||||
con, cur = get_cur()
|
con, cur = get_cur()
|
||||||
sql = """ INSERT INTO servers (hostname, ip, groups, type_ip, enable, master, cred, alert, metrics, port, `desc`, active)
|
sql = """ INSERT INTO servers (hostname, ip, groups, type_ip, enable, master, cred, port, `desc`)
|
||||||
VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')
|
VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')
|
||||||
""" % (hostname, ip, group, typeip, enable, master, cred, alert, metrics, port, desc, active)
|
""" % (hostname, ip, group, typeip, enable, master, cred, port, desc)
|
||||||
try:
|
try:
|
||||||
cur.execute(sql)
|
cur.execute(sql)
|
||||||
con.commit()
|
con.commit()
|
||||||
|
@ -174,6 +177,7 @@ def add_server(hostname, ip, group, typeip, enable, master, cred, alert, metrics
|
||||||
cur.close()
|
cur.close()
|
||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
|
|
||||||
def delete_server(id):
|
def delete_server(id):
|
||||||
con, cur = get_cur()
|
con, cur = get_cur()
|
||||||
sql = """ delete from servers where id = '%s'""" % (id)
|
sql = """ delete from servers where id = '%s'""" % (id)
|
||||||
|
@ -188,21 +192,14 @@ def delete_server(id):
|
||||||
cur.close()
|
cur.close()
|
||||||
con.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()
|
con, cur = get_cur()
|
||||||
sql = """ update servers set
|
sql = """ update servers set
|
||||||
hostname = '%s',
|
|
||||||
groups = '%s',
|
|
||||||
type_ip = '%s',
|
|
||||||
enable = '%s',
|
|
||||||
master = '%s',
|
|
||||||
cred = '%s',
|
|
||||||
alert = '%s',
|
alert = '%s',
|
||||||
metrics = '%s',
|
metrics = '%s',
|
||||||
port = '%s',
|
|
||||||
`desc` = '%s',
|
|
||||||
active = '%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:
|
try:
|
||||||
cur.execute(sql)
|
cur.execute(sql)
|
||||||
con.commit()
|
con.commit()
|
||||||
|
@ -212,6 +209,29 @@ def update_server(hostname, group, typeip, enable, master, id, cred, alert, metr
|
||||||
cur.close()
|
cur.close()
|
||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
|
|
||||||
|
def update_server(hostname, group, typeip, enable, master, id, cred, port, desc):
|
||||||
|
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'
|
||||||
|
where id = '%s'""" % (hostname, group, typeip, enable, master, cred, port, desc, 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):
|
def update_server_master(master, slave):
|
||||||
con, cur = get_cur()
|
con, cur = get_cur()
|
||||||
sql = """ select id from servers where ip = '%s' """ % master
|
sql = """ select id from servers where ip = '%s' """ % master
|
||||||
|
@ -514,6 +534,7 @@ def get_dick_permit(**kwargs):
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
user_id = cookie.get('uuid')
|
user_id = cookie.get('uuid')
|
||||||
disable = ''
|
disable = ''
|
||||||
|
nginx = ''
|
||||||
ip = ''
|
ip = ''
|
||||||
|
|
||||||
con, cur = get_cur()
|
con, cur = get_cur()
|
||||||
|
@ -529,6 +550,8 @@ def get_dick_permit(**kwargs):
|
||||||
disable = 'or enable = 0'
|
disable = 'or enable = 0'
|
||||||
if kwargs.get('ip'):
|
if kwargs.get('ip'):
|
||||||
ip = "and ip = '%s'" % kwargs.get('ip')
|
ip = "and ip = '%s'" % kwargs.get('ip')
|
||||||
|
if kwargs.get('nginx'):
|
||||||
|
nginx = "and nginx = 1"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cur.execute(sql)
|
cur.execute(sql)
|
||||||
|
@ -537,9 +560,9 @@ def get_dick_permit(**kwargs):
|
||||||
else:
|
else:
|
||||||
for group in cur:
|
for group in cur:
|
||||||
if group[5] == '1':
|
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:
|
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} {nginx} """.format(group=group[5], disable=disable, type_ip=type_ip, ip=ip, nginx=nginx)
|
||||||
try:
|
try:
|
||||||
cur.execute(sql)
|
cur.execute(sql)
|
||||||
except sqltool.Error as e:
|
except sqltool.Error as e:
|
||||||
|
@ -549,6 +572,7 @@ def get_dick_permit(**kwargs):
|
||||||
cur.close()
|
cur.close()
|
||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
|
|
||||||
def is_master(ip, **kwargs):
|
def is_master(ip, **kwargs):
|
||||||
con, cur = get_cur()
|
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
|
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 +587,7 @@ def is_master(ip, **kwargs):
|
||||||
cur.close()
|
cur.close()
|
||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
|
|
||||||
def select_ssh(**kwargs):
|
def select_ssh(**kwargs):
|
||||||
con, cur = get_cur()
|
con, cur = get_cur()
|
||||||
sql = """select * from cred """
|
sql = """select * from cred """
|
||||||
|
@ -581,6 +606,7 @@ def select_ssh(**kwargs):
|
||||||
cur.close()
|
cur.close()
|
||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
|
|
||||||
def insert_new_ssh(name, enable, group, username, password):
|
def insert_new_ssh(name, enable, group, username, password):
|
||||||
con, cur = get_cur()
|
con, cur = get_cur()
|
||||||
sql = """insert into cred(name, enable, groups, username, password) values ('%s', '%s', '%s', '%s', '%s') """ % (name, enable, group, username, password)
|
sql = """insert into cred(name, enable, groups, username, password) values ('%s', '%s', '%s', '%s', '%s') """ % (name, enable, group, username, password)
|
||||||
|
@ -595,6 +621,7 @@ def insert_new_ssh(name, enable, group, username, password):
|
||||||
cur.close()
|
cur.close()
|
||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
|
|
||||||
def delete_ssh(id):
|
def delete_ssh(id):
|
||||||
con, cur = get_cur()
|
con, cur = get_cur()
|
||||||
sql = """ delete from cred where id = %s """ % (id)
|
sql = """ delete from cred where id = %s """ % (id)
|
||||||
|
@ -609,6 +636,7 @@ def delete_ssh(id):
|
||||||
cur.close()
|
cur.close()
|
||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
|
|
||||||
def update_ssh(id, name, enable, group, username, password):
|
def update_ssh(id, name, enable, group, username, password):
|
||||||
con, cur = get_cur()
|
con, cur = get_cur()
|
||||||
sql = """ update cred set
|
sql = """ update cred set
|
||||||
|
@ -1493,6 +1521,35 @@ def update_keepalived(serv):
|
||||||
con.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 check_token_exists(token):
|
def check_token_exists(token):
|
||||||
try:
|
try:
|
||||||
import http.cookies
|
import http.cookies
|
||||||
|
|
|
@ -145,9 +145,6 @@
|
||||||
<th class="group-field">Group</th>
|
<th class="group-field">Group</th>
|
||||||
<th class="checkbox-head">Enable</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="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="slave-field"><span title="Actions with master config will automatically apply on slave">Slave for</span></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 class="cred-field">Credentials</th>
|
||||||
<th>Description</th>
|
<th>Description</th>
|
||||||
|
|
|
@ -2,15 +2,25 @@
|
||||||
<h4>Config from {{serv}}</h4>
|
<h4>Config from {{serv}}</h4>
|
||||||
<p class="accordion-expand-holder">
|
<p class="accordion-expand-holder">
|
||||||
{% if role %}
|
{% 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>
|
<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 %}
|
{% endif %}
|
||||||
<a class="accordion-expand-all ui-button ui-widget ui-corner-all" href="#">Expand all</a>
|
{% if service != 'keepalived' and service != 'nginx' %}
|
||||||
<button id="raw">Raw</button>
|
<a class="accordion-expand-all ui-button ui-widget ui-corner-all" href="#">Expand all</a>
|
||||||
<button id="according" style="display: none;">According</button>
|
<button id="raw">Raw</button>
|
||||||
|
<button id="according" style="display: none;">According</button>
|
||||||
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
</center>
|
</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">
|
<div style="margin-left: 16%" class="configShow">
|
||||||
{% set i = 0 -%}
|
{% set i = 0 -%}
|
||||||
{% set section_name = {} %}
|
{% set section_name = {} %}
|
||||||
|
@ -172,6 +182,7 @@
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% if configver %}
|
{% if configver %}
|
||||||
<br>
|
<br>
|
||||||
<center>
|
<center>
|
||||||
|
|
|
@ -11,6 +11,17 @@
|
||||||
<span class="serverDown server-status" style="margin-left: 25px !important;"></span>
|
<span class="serverDown server-status" style="margin-left: 25px !important;"></span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</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">
|
<td class="padding10 first-collumn">
|
||||||
{% if service.6|int() == 0 %}
|
{% if service.6|int() == 0 %}
|
||||||
<span class="serverNone server-status" title="Keepalived is not installed" style="margin-left: 4px !important;"></span>
|
<span class="serverNone server-status" title="Keepalived is not installed" style="margin-left: 4px !important;"></span>
|
||||||
|
|
|
@ -53,18 +53,12 @@
|
||||||
<ul class="menu">
|
<ul class="menu">
|
||||||
{% if user %}
|
{% if user %}
|
||||||
<li><a href="/app/overview.py" title="Server and service status" class="overview-link">Overview</a></li>
|
<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>
|
<li class="p_menu"><a title="Actions with Haproxy configs" class="config-show">Haproxy</a>
|
||||||
<ul class="v_menu">
|
<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/config.py" title="Working with HAProxy configs" class="edit head-submenu">Configs</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 %}
|
{% 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/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/versions.py" title="Actions with configs versions" class="version head-submenu">Versions</a></li>
|
||||||
|
@ -79,11 +73,19 @@
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
{% if role <= 2 %}
|
{% 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">
|
<li class="p_menu">
|
||||||
<a title="Keepalived" class="ha">Keepalived</a>
|
<a title="Keepalived" class="ha">Keepalived</a>
|
||||||
<ul class="v_menu">
|
<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/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>
|
<li><a href="/app/versions.py?service=keepalived" title="Actions with Keepalived configs versions" class="version head-submenu keepalived_versions">Versions</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
@ -241,7 +243,7 @@
|
||||||
{% endif %}
|
{% 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 %}
|
{% 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;">
|
<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>
|
<span id="show-updates-button" class="new-version-exists">v{{current_ver}} </span>
|
||||||
{% else %}
|
{% else %}
|
||||||
v{{current_ver}}
|
v{{current_ver}}
|
||||||
|
|
|
@ -6,10 +6,11 @@
|
||||||
<p>
|
<p>
|
||||||
<form action="{{ action }}" method="post">
|
<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>
|
<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 }}">
|
<select autofocus required name="serv" id="{{ select_id }}">
|
||||||
<option disabled>Choose server</option>
|
<option disabled>Choose server</option>
|
||||||
{% for select in selects %}
|
{% for select in selects %}
|
||||||
{% if keepalived %}
|
{% if service == 'keepalived' %}
|
||||||
{% if select.1 == serv %}
|
{% if select.1 == serv %}
|
||||||
<option value="{{ select.1 }}" selected>{{ select.0 }}</option>
|
<option value="{{ select.1 }}" selected>{{ select.0 }}</option>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -29,11 +30,16 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
{% if not keepalived %}
|
{% 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 running config" onclick="showConfig()">Open</a>
|
||||||
<a class="ui-button ui-widget ui-corner-all" title="Compare configs" onclick="showCompareConfigs()">Compare</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="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 %}
|
{% if role <= 2 %}
|
||||||
<a class="ui-button ui-widget ui-corner-all" title="Show versions" onclick="openVersions()">Versions</a>
|
<a class="ui-button ui-widget ui-corner-all" title="Show versions" onclick="openVersions()">Versions</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -59,12 +65,12 @@
|
||||||
<input type="hidden" value="{{ cfg }}.old" name="oldconfig">
|
<input type="hidden" value="{{ cfg }}.old" name="oldconfig">
|
||||||
<textarea name="config" class="config" rows="35" cols="100">{{ config }}</textarea>
|
<textarea name="config" class="config" rows="35" cols="100">{{ config }}</textarea>
|
||||||
<p>
|
<p>
|
||||||
{% if not keepalived %}
|
{% if service == 'haproxy' %}
|
||||||
<button type="submit" value="test" name="save" class="btn btn-default">Just test</button>
|
<button type="submit" value="test" name="save" class="btn btn-default">Just test</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<button type="submit" value="save" name="save" class="btn btn-default">Just save</button>
|
<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>
|
<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>
|
<button type="submit" value="reload" name="save" class="btn btn-default">Save and reload</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
|
@ -89,7 +95,7 @@
|
||||||
if (cur_url[1].split('&')[1] == 'showMap') {
|
if (cur_url[1].split('&')[1] == 'showMap') {
|
||||||
showMap();
|
showMap();
|
||||||
}
|
}
|
||||||
if (cur_url[1].split('&')[1] == 'showCompare') {
|
if (cur_url[1].split('&')[1] == 'showCompare' || cur_url[1].split('&')[2] == 'showCompare') {
|
||||||
showCompareConfigs();
|
showCompareConfigs();
|
||||||
}
|
}
|
||||||
if (cur_url[1].split('&')[1] == 'showConfig') {
|
if (cur_url[1].split('&')[1] == 'showConfig') {
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
<h3>Choose server</h3>
|
<h3>Choose server</h3>
|
||||||
<p>
|
<p>
|
||||||
<form action="{{ action }}" method="post">
|
<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>
|
<a class="ui-button ui-widget ui-corner-all" title="Return back" onclick="history.back()">Back</a>
|
||||||
{% include 'include/select.html' %}
|
{% include 'include/select.html' %}
|
||||||
<button type="submit" value="open" name="open" class="btn btn-default">Open</button>
|
<button type="submit" value="open" name="open" class="btn btn-default">Open</button>
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<input type="checkbox" id="select_all"><br />
|
<input type="checkbox" id="select_all"><br />
|
||||||
{% for file in return_files %}
|
{% for file in return_files %}
|
||||||
<label for="{{file}}"> {{file.split('-', maxsplit=1)[1]}} </label><input type="checkbox" value="{{file}}" name="{{file}}" id="{{file}}">
|
<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
|
Upload
|
||||||
</a><br />
|
</a><br />
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -47,36 +47,54 @@
|
||||||
</script>
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="div-pannel" id="div-pannel-{{s.0}}">
|
<div class="div-pannel" id="div-pannel-{{s.0}}">
|
||||||
<div id="div-server-{{s.0}}" class="div-server-hapwi">
|
<div id="div-server-{{s.0}}" class="div-server-hapwi" {% if service == 'nginx' %}style="height:138px;"{%endif%}>
|
||||||
<div class="server-name">
|
<div class="server-name">
|
||||||
{% if s.5 != False %}
|
{% if service == 'nginx' %}
|
||||||
<span class="serverUp server-status" title="{{s.5.0.2}}"></span>
|
<input type="hidden" id="service" value="nginx" />
|
||||||
{% else %}
|
{% if s.5.0.3 == 'active' %}
|
||||||
<span class="serverDown server-status" title="HAProxy is down"></span>
|
<span class="serverUp server-status" title="Uptime: {{s.5.0.4}}"></span>
|
||||||
{% endif %}
|
{% else %}
|
||||||
{% if not serv %}
|
<span class="serverDown server-status" title="Downtime: : {{s.5.0.4}}"></span>
|
||||||
<a href="/app/hapservers.py?serv={{s.2}}" title="More about {{s.1}}" style="color: #5d9ceb">{{s.1}}</a>
|
{% endif %}
|
||||||
{% else %}
|
|
||||||
{{s.1}}
|
{{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 %}
|
{% endif %}
|
||||||
{% if s.6|int() >= 1 %}
|
{% if service == 'haproxy' %}
|
||||||
<img
|
{% if s.6|int() >= 1 %}
|
||||||
{% if keep_alive|int() >= 1 %}
|
<img
|
||||||
src="/inc/images/shield.png" title="Auto start enabled"
|
{% if keep_alive|int() >= 1 %}
|
||||||
{% else %}
|
src="/inc/images/shield.png" title="Auto start enabled"
|
||||||
src="/inc/images/shield-red.png" title="Auto start enabled, but keep alive service does not work"
|
{% else %}
|
||||||
{% endif %}
|
src="/inc/images/shield-red.png" title="Auto start enabled, but keep alive service does not work"
|
||||||
width=18 style="padding-left: 5px; margin-bottom: -3px;">
|
{% endif %}
|
||||||
|
width=18 style="padding-left: 5px; margin-bottom: -3px;">
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if role <= 1 %}
|
{% if role <= 1 %}
|
||||||
<span class="server-action">
|
<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">
|
<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}}')">
|
<img src=/inc/images/start.png alt="start" class="icon-hapservs" style="margin-bottom: -2px;" onclick="confirmAjaxAction('start', '{{action_service}}', '{{s.2}}')">
|
||||||
</a>
|
</a>
|
||||||
<a id="stop-{{ s.2 }}" class="stop" title="Stop HAProxy service">
|
<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}}')">
|
<img src=/inc/images/stop.png alt="stop" class="icon-hapservs" width="17px" onclick="confirmAjaxAction('stop', '{{action_service}}', '{{s.2}}')">
|
||||||
</a>
|
</a>
|
||||||
<a id="restart-{{ s.2 }}" class="restart" title="Restart HAProxy service" onclick="confirmAjaxAction('restart', 'hap', '{{s.2}}')">
|
<a id="restart-{{ s.2 }}" class="restart" title="Restart HAProxy service" onclick="confirmAjaxAction('restart', '{{action_service}}', '{{s.2}}')">
|
||||||
<img src=/inc/images/update.png alt="restart" class="icon-hapservs">
|
<img src=/inc/images/update.png alt="restart" class="icon-hapservs">
|
||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
|
@ -85,10 +103,14 @@
|
||||||
<div class="server-desc">
|
<div class="server-desc">
|
||||||
{{s.3}}
|
{{s.3}}
|
||||||
<br />
|
<br />
|
||||||
{% if s.5.0 is defined %}
|
{% if service == 'nginx' %}
|
||||||
{{s.5.0.0}} {{s.5.0.1}} {{s.5.0.2}}
|
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 %}
|
{% 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 %}
|
{% endif %}
|
||||||
<br />
|
<br />
|
||||||
<span title="Date of last edit config" >
|
<span title="Date of last edit config" >
|
||||||
|
@ -101,14 +123,44 @@
|
||||||
Master for: {{ s.7.0.1 }}
|
Master for: {{ s.7.0.1 }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</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">
|
<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}}&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/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/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 %}
|
{% 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 %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -144,6 +196,6 @@
|
||||||
{% if serv %}
|
{% if serv %}
|
||||||
overviewHapserverBackends(ip, hostnamea);
|
overviewHapserverBackends(ip, hostnamea);
|
||||||
{% endif %}
|
{% endif %}
|
||||||
showHapservers(ip, hostnamea);
|
showHapservers(ip, hostnamea, '{{service}}');
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -33,18 +33,6 @@
|
||||||
<td class="padding20" title="Vitrual IP, something like VRRP">Virt</td>
|
<td class="padding20" title="Vitrual IP, something like VRRP">Virt</td>
|
||||||
<td>{{ checkbox('typeip') }}</td>
|
<td>{{ checkbox('typeip') }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td class="padding20" title="Alert if backend change status">Alert</td>
|
|
||||||
<td>{{ checkbox('alert') }} </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>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="padding20" title="Actions with master config will automatically apply on slave">Slave for</td>
|
<td class="padding20" title="Actions with master config will automatically apply on slave">Slave for</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
|
@ -15,30 +15,6 @@
|
||||||
{{ checkbox(id) }}
|
{{ checkbox(id) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td class="checkbox">
|
|
||||||
{% set id = 'alert-' + server.0|string() %}
|
|
||||||
{% if server.8 == 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 %}
|
|
||||||
{{ checkbox(id, checked='checked') }}
|
|
||||||
{% else %}
|
|
||||||
{{ checkbox(id) }}
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
<td>
|
<td>
|
||||||
<select id="slavefor-{{server.0}}">
|
<select id="slavefor-{{server.0}}">
|
||||||
<option value="0" selected>Not slave</option>
|
<option value="0" selected>Not slave</option>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% from 'include/input_macros.html' import input, checkbox %}
|
{% from 'include/input_macros.html' import input, checkbox %}
|
||||||
<script src="/inc/users.js"></script>
|
<script src="/inc/users.js"></script>
|
||||||
|
<input type="hidden" id="service" value="{{service}}" />
|
||||||
<table class="overview">
|
<table class="overview">
|
||||||
<tr class="overviewHead">
|
<tr class="overviewHead">
|
||||||
<td class="padding10 first-collumn" style="width: 10%;">
|
<td class="padding10 first-collumn" style="width: 10%;">
|
||||||
|
@ -11,7 +12,7 @@
|
||||||
Server
|
Server
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
{% if onclick != 'viewLogs()' %}
|
{% if onclick != 'viewLogs()' and service != 'nginx' %}
|
||||||
<td style="width: 5%;">WAF logs</td>
|
<td style="width: 5%;">WAF logs</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td style="width: 10%;">Number rows</td>
|
<td style="width: 10%;">Number rows</td>
|
||||||
|
@ -41,7 +42,7 @@
|
||||||
{% include 'include/select.html' %}
|
{% include 'include/select.html' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
{% if onclick != 'viewLogs()' %}
|
{% if onclick != 'viewLogs()' and service != 'nginx' %}
|
||||||
<td>
|
<td>
|
||||||
{{ checkbox('waf') }}
|
{{ checkbox('waf') }}
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -15,11 +15,14 @@
|
||||||
<td class="padding10 first-collumn-wi">
|
<td class="padding10 first-collumn-wi">
|
||||||
Server
|
Server
|
||||||
</td>
|
</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">
|
<a href="/app/hapservers.py" title="HAProxy servers overview" class="logs_link">
|
||||||
HAProxy
|
HAProxy
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
<td class="padding10">
|
||||||
|
Nginx
|
||||||
|
</td>
|
||||||
<td class="padding10">
|
<td class="padding10">
|
||||||
Keealived
|
Keealived
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<li><a href="#servers">Servers</a></li>
|
<li><a href="#servers">Servers</a></li>
|
||||||
<li><a href="#ssh">SSH credentials</a></li>
|
<li><a href="#ssh">SSH credentials</a></li>
|
||||||
<li><a href="#checker">Checker</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>
|
<li><a href="#backup">Backup</a></li>
|
||||||
{% include 'include/login.html' %}
|
{% include 'include/login.html' %}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -74,9 +74,6 @@
|
||||||
<td class="checkbox-head"><span title="SSH port">Port</span></td></td>
|
<td class="checkbox-head"><span title="SSH port">Port</span></td></td>
|
||||||
<td class="checkbox-head">Enable</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="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>
|
|
||||||
<td class="slave-field"><span title="Actions with master config will automatically apply on slave">Slave for</span></td>
|
<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 class="cred-field">Credentials</td>
|
||||||
<td>Description</td>
|
<td>Description</td>
|
||||||
|
@ -274,6 +271,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="installhaproxy">
|
<div id="installhaproxy">
|
||||||
<table class="overview">
|
<table class="overview">
|
||||||
|
<caption><h3>Install HAProxy</h3></caption>
|
||||||
<tr class="overviewHead">
|
<tr class="overviewHead">
|
||||||
<td class="padding10 first-collumn">Current version</td>
|
<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: 25%;">Available Versions</td>
|
||||||
|
@ -305,6 +303,37 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</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 id="ajax"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -436,7 +465,9 @@
|
||||||
$('.delete').remove()
|
$('.delete').remove()
|
||||||
$('#hapver').selectmenu('enable');
|
$('#hapver').selectmenu('enable');
|
||||||
$('#haproxyaddserv').selectmenu('enable');
|
$('#haproxyaddserv').selectmenu('enable');
|
||||||
|
$('#nginxaddserv').selectmenu('enable');
|
||||||
$('#syn_flood').checkboxradio('enable');
|
$('#syn_flood').checkboxradio('enable');
|
||||||
|
$('#nginx_syn_flood').checkboxradio('enable');
|
||||||
}, 500 );
|
}, 500 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,10 +35,16 @@ except:
|
||||||
|
|
||||||
|
|
||||||
if service == 'keepalived':
|
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')
|
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'
|
format = 'conf'
|
||||||
else:
|
else:
|
||||||
title = "Working with versions HAProxy configs"
|
title = "Working with versions HAProxy configs"
|
||||||
|
@ -71,7 +77,9 @@ if serv is not None and form.getvalue('config') is not None:
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if service == 'keepalived':
|
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:
|
else:
|
||||||
stderr = funct.master_slave_upload_and_restart(serv, configver, just_save=save)
|
stderr = funct.master_slave_upload_and_restart(serv, configver, just_save=save)
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,11 @@
|
||||||
font-family: "Font Awesome 5 Solid";
|
font-family: "Font Awesome 5 Solid";
|
||||||
content: "\f126";
|
content: "\f126";
|
||||||
}
|
}
|
||||||
|
.nginx::before {
|
||||||
|
display: none;
|
||||||
|
font-family: "Font Awesome 5 Solid";
|
||||||
|
content: "\f0e8";
|
||||||
|
}
|
||||||
.version::before {
|
.version::before {
|
||||||
display: none;
|
display: none;
|
||||||
font-family: "Font Awesome 5 Solid";
|
font-family: "Font Awesome 5 Solid";
|
||||||
|
|
|
@ -16,18 +16,19 @@ function showOverviewHapWI() {
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
function showHapservers(serv, hostnamea) {
|
function showHapservers(serv, hostnamea, service) {
|
||||||
var i;
|
var i;
|
||||||
for (i = 0; i < serv.length; 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( {
|
$.ajax( {
|
||||||
url: "options.py",
|
url: "options.py",
|
||||||
data: {
|
data: {
|
||||||
act: "overviewHapservers",
|
act: "overviewHapservers",
|
||||||
serv: serv,
|
serv: serv,
|
||||||
|
service: service,
|
||||||
token: $('#token').val()
|
token: $('#token').val()
|
||||||
},
|
},
|
||||||
beforeSend: function() {
|
beforeSend: function() {
|
||||||
|
@ -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) {
|
function ajaxActionWafServers(action, id) {
|
||||||
var bad_ans = 'Bad config, check please';
|
var bad_ans = 'Bad config, check please';
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
|
@ -162,21 +189,6 @@ function ajaxActionWafServers(action, id) {
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
$( function() {
|
$( 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() {
|
$('.start-waf').click(function() {
|
||||||
var id = $(this).attr('id');
|
var id = $(this).attr('id');
|
||||||
confirmAjaxAction("start", "waf", id);
|
confirmAjaxAction("start", "waf", id);
|
||||||
|
@ -235,6 +247,10 @@ $( function() {
|
||||||
$("#apply").css('display', 'none');
|
$("#apply").css('display', 'none');
|
||||||
Cookies.remove('restart', { path: '' });
|
Cookies.remove('restart', { path: '' });
|
||||||
});
|
});
|
||||||
|
$( ".server-act-links" ).change(function() {
|
||||||
|
var id = $(this).attr('id').split('-');
|
||||||
|
updateHapWIServer(id[1])
|
||||||
|
});
|
||||||
});
|
});
|
||||||
function confirmAjaxAction(action, service, id) {
|
function confirmAjaxAction(action, service, id) {
|
||||||
$( "#dialog-confirm" ).dialog({
|
$( "#dialog-confirm" ).dialog({
|
||||||
|
@ -256,6 +272,8 @@ function confirmAjaxAction(action, service, id) {
|
||||||
}
|
}
|
||||||
} else if (service == "waf") {
|
} else if (service == "waf") {
|
||||||
ajaxActionWafServers(action, id)
|
ajaxActionWafServers(action, id)
|
||||||
|
} else if (service == "nginx") {
|
||||||
|
ajaxActionNginxServers(action, id)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Cancel: function() {
|
Cancel: function() {
|
||||||
|
@ -264,3 +282,44 @@ 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 () {
|
$('.menu li ul li').each(function () {
|
||||||
var link = $(this).find('a').attr('href');
|
var link = $(this).find('a').attr('href');
|
||||||
var link2 = link.split('/')[2]
|
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('display', 'contents');
|
||||||
$(this).parent().css('font-size', '13px');
|
$(this).parent().css('font-size', '13px');
|
||||||
$(this).parent().css('top', '0');
|
$(this).parent().css('top', '0');
|
||||||
|
@ -16,7 +19,7 @@ $( function() {
|
||||||
$(this).parent().find('a').css('padding-left', '20px');
|
$(this).parent().find('a').css('padding-left', '20px');
|
||||||
$(this).find('a').css('padding-left', '30px');
|
$(this).find('a').css('padding-left', '30px');
|
||||||
$(this).find('a').css('border-left', '4px solid #5D9CEB');
|
$(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('display', 'contents');
|
||||||
$(this).parent().css('font-size', '13px');
|
$(this).parent().css('font-size', '13px');
|
||||||
$(this).parent().css('top', '0');
|
$(this).parent().css('top', '0');
|
||||||
|
@ -25,7 +28,34 @@ $( function() {
|
||||||
$(this).parent().find('a').css('padding-left', '20px');
|
$(this).parent().find('a').css('padding-left', '20px');
|
||||||
$(this).find('a').css('padding-left', '30px');
|
$(this).find('a').css('padding-left', '30px');
|
||||||
$(this).find('a').css('border-left', '4px solid #5D9CEB');
|
$(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('display', 'contents');
|
||||||
$(this).parent().css('font-size', '13px');
|
$(this).parent().css('font-size', '13px');
|
||||||
$(this).parent().css('top', '0');
|
$(this).parent().css('top', '0');
|
||||||
|
@ -236,6 +266,8 @@ function openVersions() {
|
||||||
var serv = $("#serv").val();
|
var serv = $("#serv").val();
|
||||||
if (cur_url[1] == "service=keepalived") {
|
if (cur_url[1] == "service=keepalived") {
|
||||||
var url = "versions.py?service=keepalived&serv="+serv+"&open=open"
|
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 {
|
} else {
|
||||||
var url = "versions.py?serv="+serv+"&open=open"
|
var url = "versions.py?serv="+serv+"&open=open"
|
||||||
}
|
}
|
||||||
|
@ -253,6 +285,7 @@ function showLog() {
|
||||||
var minut = $('#time_range_out_minut').val()
|
var minut = $('#time_range_out_minut').val()
|
||||||
var hour1 = $('#time_range_out_hour1').val()
|
var hour1 = $('#time_range_out_hour1').val()
|
||||||
var minut1 = $('#time_range_out_minut1').val()
|
var minut1 = $('#time_range_out_minut1').val()
|
||||||
|
var service = $('#service').val()
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
url: "options.py",
|
url: "options.py",
|
||||||
data: {
|
data: {
|
||||||
|
@ -264,12 +297,13 @@ function showLog() {
|
||||||
minut: minut,
|
minut: minut,
|
||||||
hour1: hour1,
|
hour1: hour1,
|
||||||
minut1: minut1,
|
minut1: minut1,
|
||||||
|
service: service,
|
||||||
token: $('#token').val()
|
token: $('#token').val()
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
$("#ajax").html(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+
|
'&rows='+rows+
|
||||||
'&grep='+grep+
|
'&grep='+grep+
|
||||||
'&hour='+hour+
|
'&hour='+hour+
|
||||||
|
@ -328,6 +362,7 @@ function showCompare() {
|
||||||
serv: $("#serv").val(),
|
serv: $("#serv").val(),
|
||||||
left: $('#left').val(),
|
left: $('#left').val(),
|
||||||
right: $("#right").val(),
|
right: $("#right").val(),
|
||||||
|
service: $("#service").val(),
|
||||||
token: $('#token').val()
|
token: $('#token').val()
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
|
@ -346,6 +381,7 @@ function showCompareConfigs() {
|
||||||
serv: $("#serv").val(),
|
serv: $("#serv").val(),
|
||||||
act: "showCompareConfigs",
|
act: "showCompareConfigs",
|
||||||
open: "open",
|
open: "open",
|
||||||
|
service: $("#service").val(),
|
||||||
token: $('#token').val()
|
token: $('#token').val()
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
|
@ -353,7 +389,7 @@ function showCompareConfigs() {
|
||||||
$("#ajax-compare").html(data);
|
$("#ajax-compare").html(data);
|
||||||
$( "input[type=submit], button" ).button();
|
$( "input[type=submit], button" ).button();
|
||||||
$( "select" ).selectmenu();
|
$( "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 +429,7 @@ function showUploadConfig() {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
$("#ajax").html(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');
|
$.getScript('/inc/configshow.js');
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
@ -769,16 +805,33 @@ $( function() {
|
||||||
$('#cur_hap_ver').text(data);
|
$('#cur_hap_ver').text(data);
|
||||||
$('#install').text('Update');
|
$('#install').text('Update');
|
||||||
$('#install').attr('title', 'Update HAProxy');
|
$('#install').attr('title', 'Update HAProxy');
|
||||||
$('#syn_flood').checkboxradio('disable');
|
|
||||||
$('#syn_flood').prop( "checked", false );
|
|
||||||
$('#syn_flood').checkboxradio('refresh');
|
|
||||||
} else {
|
} else {
|
||||||
$('#cur_hap_ver').text('HAProxy has not installed');
|
$('#cur_hap_ver').text('HAProxy has not installed');
|
||||||
$('#install').text('Install');
|
$('#install').text('Install');
|
||||||
$('#install').attr('title', 'Install HAProxy');
|
$('#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;
|
z-index: 1000;
|
||||||
display: block;
|
display: block;
|
||||||
background-color: #222a31;
|
background-color: #222a31;
|
||||||
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
.logoText {
|
.logoText {
|
||||||
color: #EBF1F1;
|
color: #EBF1F1;
|
||||||
|
@ -289,7 +290,7 @@ pre {
|
||||||
margin-left: 30px;
|
margin-left: 30px;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
margin-left: 65px;
|
margin-left: 65px;
|
||||||
margin-top: 25px;
|
margin-top: 15px;
|
||||||
}
|
}
|
||||||
.line {
|
.line {
|
||||||
background-color: #f5faf4;
|
background-color: #f5faf4;
|
||||||
|
@ -747,7 +748,7 @@ label {
|
||||||
.div-server, .div-server-hapwi {
|
.div-server, .div-server-hapwi {
|
||||||
background-color: #fbfbfb;
|
background-color: #fbfbfb;
|
||||||
border: 1px solid #A4C7F5;
|
border: 1px solid #A4C7F5;
|
||||||
height: 153px;
|
height: 165px;
|
||||||
width: 365px;
|
width: 365px;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
|
@ -755,7 +756,7 @@ label {
|
||||||
padding-right: 15px;
|
padding-right: 15px;
|
||||||
margin: 20px;
|
margin: 20px;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
margin-bottom: 30px ;
|
margin-bottom: 20px ;
|
||||||
margin-top: 0px;
|
margin-top: 0px;
|
||||||
display: block;
|
display: block;
|
||||||
float: left;
|
float: left;
|
||||||
|
@ -785,9 +786,8 @@ label {
|
||||||
margin-top: 6px;
|
margin-top: 6px;
|
||||||
}
|
}
|
||||||
.server-desc {
|
.server-desc {
|
||||||
padding-bottom: 10px;
|
|
||||||
color: #999;
|
color: #999;
|
||||||
padding-top: 10px;
|
padding-top: 5px;
|
||||||
height: 80px;
|
height: 80px;
|
||||||
}
|
}
|
||||||
.server-act-links {
|
.server-act-links {
|
||||||
|
@ -811,7 +811,7 @@ label {
|
||||||
margin-top: px;
|
margin-top: px;
|
||||||
margin-bottom: 0px;
|
margin-bottom: 0px;
|
||||||
margin-top: 0px;
|
margin-top: 0px;
|
||||||
height: 183px;
|
height: 195px;
|
||||||
}
|
}
|
||||||
.haproxy-info {
|
.haproxy-info {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|
65
inc/users.js
65
inc/users.js
|
@ -178,6 +178,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() {
|
$('#update_haproxy_wi').click(function() {
|
||||||
$("#ajax-update").html('')
|
$("#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>');
|
$("#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,24 +658,12 @@ function addServer() {
|
||||||
var cred = $('#credentials').val();
|
var cred = $('#credentials').val();
|
||||||
var typeip = 0;
|
var typeip = 0;
|
||||||
var enable = 0;
|
var enable = 0;
|
||||||
var alert_en = 0;
|
|
||||||
var metrics = 0;
|
|
||||||
var active = 0;
|
|
||||||
if ($('#typeip').is(':checked')) {
|
if ($('#typeip').is(':checked')) {
|
||||||
typeip = '1';
|
typeip = '1';
|
||||||
}
|
}
|
||||||
if ($('#enable').is(':checked')) {
|
if ($('#enable').is(':checked')) {
|
||||||
enable = '1';
|
enable = '1';
|
||||||
}
|
}
|
||||||
if ($('#alert').is(':checked')) {
|
|
||||||
var alert_en = '1';
|
|
||||||
}
|
|
||||||
if ($('#metrics').is(':checked')) {
|
|
||||||
var metrics = '1';
|
|
||||||
}
|
|
||||||
if ($('#active').is(':checked')) {
|
|
||||||
var active = '1';
|
|
||||||
}
|
|
||||||
allFields = $( [] ).add( $('#new-server-add') ).add( $('#new-ip') ).add( $('#new-port') )
|
allFields = $( [] ).add( $('#new-server-add') ).add( $('#new-ip') ).add( $('#new-port') )
|
||||||
allFields.removeClass( "ui-state-error" );
|
allFields.removeClass( "ui-state-error" );
|
||||||
valid = valid && checkLength( $('#new-server-add'), "Hostname", 1 );
|
valid = valid && checkLength( $('#new-server-add'), "Hostname", 1 );
|
||||||
|
@ -659,11 +682,8 @@ function addServer() {
|
||||||
enable: enable,
|
enable: enable,
|
||||||
slave: $('#slavefor' ).val(),
|
slave: $('#slavefor' ).val(),
|
||||||
cred: cred,
|
cred: cred,
|
||||||
alert_en: alert_en,
|
|
||||||
metrics: metrics,
|
|
||||||
page: cur_url[0],
|
page: cur_url[0],
|
||||||
desc: $('#desc').val(),
|
desc: $('#desc').val(),
|
||||||
active: active,
|
|
||||||
token: $('#token').val()
|
token: $('#token').val()
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
|
@ -1161,24 +1181,12 @@ function updateServer(id) {
|
||||||
$('.alert-danger').remove();
|
$('.alert-danger').remove();
|
||||||
var typeip = 0;
|
var typeip = 0;
|
||||||
var enable = 0;
|
var enable = 0;
|
||||||
var alert_en = 0;
|
|
||||||
var metrics = 0;
|
|
||||||
var active = 0;
|
|
||||||
if ($('#typeip-'+id).is(':checked')) {
|
if ($('#typeip-'+id).is(':checked')) {
|
||||||
typeip = '1';
|
typeip = '1';
|
||||||
}
|
}
|
||||||
if ($('#enable-'+id).is(':checked')) {
|
if ($('#enable-'+id).is(':checked')) {
|
||||||
enable = '1';
|
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();
|
var servergroup = $('#servergroup-'+id+' option:selected' ).val();
|
||||||
if (cur_url[0] == "servers.py") {
|
if (cur_url[0] == "servers.py") {
|
||||||
servergroup = $('#servergroup-'+id).val();
|
servergroup = $('#servergroup-'+id).val();
|
||||||
|
@ -1194,10 +1202,7 @@ function updateServer(id) {
|
||||||
slave: $('#slavefor-'+id+' option:selected' ).val(),
|
slave: $('#slavefor-'+id+' option:selected' ).val(),
|
||||||
cred: $('#credentials-'+id+' option:selected').val(),
|
cred: $('#credentials-'+id+' option:selected').val(),
|
||||||
id: id,
|
id: id,
|
||||||
metrics: metrics,
|
|
||||||
alert_en: alert_en,
|
|
||||||
desc: $('#desc-'+id).val(),
|
desc: $('#desc-'+id).val(),
|
||||||
active: active,
|
|
||||||
token: $('#token').val()
|
token: $('#token').val()
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
|
|
Loading…
Reference in New Issue