Changelog: https://haproxy-wi.org/changelog.py#4
pull/217/head
Pavel Loginov 2020-02-09 19:19:44 +01:00 committed by GitHub
commit e184083b36
55 changed files with 1236 additions and 445 deletions

View File

@ -15,36 +15,36 @@ Web interface(user-friendly web GUI, alerting, monitoring and secure) for managi
![alt text](image/haproxy-wi-config-show.png "Show config page") ![alt text](image/haproxy-wi-config-show.png "Show config page")
# 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
![alt text](image/haproxy-wi-metrics.png "Merics") ![alt text](image/haproxy-wi-metrics.png "Merics")

View File

@ -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.get_dick_permit(keepalived=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)

View File

@ -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,85 @@ 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("update settings set section = 'main', `desc` = 'Temp store configs, for check' where param = 'tmp_config_path';")
sql.append("update settings set section = 'main' where param = 'cert_path';")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_path_error_logs', '/var/log/nginx/error.log', 'nginx', 'Nginx error log');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_stats_user', 'admin', 'nginx', 'Username for Stats web page Nginx');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_stats_password', 'password', 'nginx', 'Password for Stats web page Nginx');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_stats_port', '8086', 'nginx', 'Stats port for web page Nginx');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_stats_page', 'stats', 'nginx', 'URI Stats for web page Nginx');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_restart_command', 'systemctl restart nginx', 'nginx', 'Command for restart Nginx service');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_reload_command', 'systemctl reload nginx', 'nginx', 'Command for reload Nginx service');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_status_command', 'systemctl status nginx', 'nginx', 'Command for status check Nginx service');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_dir', '/etc/nginx/conf.d/', 'nginx', 'Path to Nginx dir');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_config_path', '/etc/nginx/conf.d/default.conf', 'nginx', 'Path to Nginx config');")
for i in sql:
try:
cur.execute(i)
con.commit()
except sqltool.Error as e:
pass
else:
if kwargs.get('silent') != 1:
print('Updating... one more for version 4.0.0')
return True
cur.close()
con.close()
def update_db_v_41(**kwargs):
con, cur = get_cur()
sql = """
ALTER TABLE `servers` ADD COLUMN nginx INTEGER NOT NULL DEFAULT 0;
"""
try:
cur.execute(sql)
con.commit()
except sqltool.Error as e:
if kwargs.get('silent') != 1:
if e.args[0] == 'duplicate column name: nginx' or e == " 1060 (42S21): Duplicate column name 'nginx' ":
print('Updating... one more for version 4.0.0')
else:
print("An error occurred:", e)
return False
else:
print("Updating... one more for version 4.0.0")
return True
cur.close()
con.close()
def update_db_v_42(**kwargs):
con, cur = get_cur()
sql = """
ALTER TABLE `servers` ADD COLUMN haproxy INTEGER NOT NULL DEFAULT 0;
"""
try:
cur.execute(sql)
con.commit()
except sqltool.Error as e:
if kwargs.get('silent') != 1:
if e.args[0] == 'duplicate column name: nginx' or e == " 1060 (42S21): Duplicate column name 'nginx' ":
print('DB was update to 4.0.0')
else:
print("An error occurred:", e)
return False
else:
print("DB was update to 4.0.0")
return True return True
cur.close() cur.close()
con.close() con.close()
@ -384,7 +457,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 +479,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 +497,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()

View File

@ -47,7 +47,6 @@ def logging(serv, action, **kwargs):
import sql import sql
import http.cookies import http.cookies
log_path = get_config_var('main', 'log_path') log_path = get_config_var('main', 'log_path')
login = ''
if not os.path.exists(log_path): if not os.path.exists(log_path):
os.makedirs(log_path) os.makedirs(log_path)
@ -76,7 +75,7 @@ def logging(serv, action, **kwargs):
if kwargs.get('login'): if kwargs.get('login'):
mess = get_data('date_in_log') + " from " + IP + " user: " + login + " " + action + " for: " + serv + "\n" mess = get_data('date_in_log') + " from " + IP + " user: " + login + " " + action + " for: " + serv + "\n"
else: else:
mess = get_data('date_in_log') + action + "\n" mess = get_data('date_in_log') + action + " from " + IP + "\n"
log = open(log_path + "/haproxy-wi-"+get_data('logs')+".log", "a") log = open(log_path + "/haproxy-wi-"+get_data('logs')+".log", "a")
else: else:
mess = get_data('date_in_log') + " from " + IP + " user: " + login + " " + action + " for: " + serv + "\n" mess = get_data('date_in_log') + " from " + IP + " user: " + login + " " + action + " for: " + serv + "\n"
@ -230,17 +229,23 @@ def ssh_connect(serv, **kwargs):
def get_config(serv, cfg, **kwargs): 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()
@ -409,6 +414,7 @@ def install_haproxy(serv, **kwargs):
print('success: HAProxy was installed<br>') print('success: HAProxy was installed<br>')
os.system("rm -f %s" % script) os.system("rm -f %s" % script)
sql.update_haproxy(serv)
def waf_install(serv, **kwargs): def waf_install(serv, **kwargs):
@ -439,6 +445,56 @@ def waf_install(serv, **kwargs):
if stderr is None: if stderr is None:
sql.insert_waf_metrics_enable(serv, "0") sql.insert_waf_metrics_enable(serv, "0")
def install_nginx(serv):
import sql
script = "install_nginx.sh"
stats_user = sql.get_setting('nginx_stats_user')
stats_password = sql.get_setting('nginx_stats_password')
stats_port = sql.get_setting('nginx_stats_port')
stats_page = sql.get_setting('nginx_stats_page')
config_path = sql.get_setting('nginx_config_path')
proxy = sql.get_setting('proxy')
ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name = return_ssh_keys_path(serv)
if ssh_enable == 0:
ssh_key_name = ''
os.system("cp scripts/%s ." % script)
if proxy is not None and proxy != '' and proxy != 'None':
proxy_serv = proxy
else:
proxy_serv = ''
syn_flood_protect = '1' if form.getvalue('syn_flood') == "1" else ''
commands = [ "chmod +x "+script +" && ./"+script +" PROXY=" + proxy_serv+" STATS_USER="+stats_user+" STATS_PASS="+stats_password+
" CONFIG_PATH="+config_path+" STAT_PORT="+stats_port+" STAT_PAGE="+stats_page+" SYN_FLOOD="+syn_flood_protect+" HOST="+serv+
" USER="+ssh_user_name+" PASS="+ssh_user_password+" KEY="+ssh_key_name ]
output, error = subprocess_execute(commands[0])
if error:
logging('localhost', error, haproxywi=1)
print('error: '+error)
else:
for l in output:
if "msg" in l or "FAILED" in l:
try:
l = l.split(':')[1]
l = l.split('"')[1]
print(l+"<br>")
break
except:
print(output)
break
else:
print('success: Nginx was installed<br>')
os.system("rm -f %s" % script)
sql.update_nginx(serv)
def update_haproxy_wi(): def update_haproxy_wi():
cmd = 'sudo -S yum -y update haproxy-wi' cmd = 'sudo -S yum -y update haproxy-wi'
@ -495,7 +551,13 @@ def upload(serv, path, file, **kwargs):
def upload_and_restart(serv, cfg, **kwargs): 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 +571,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 +607,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 +661,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 +673,15 @@ def show_haproxy_log(serv, rows=10, waf='0', grep=None, hour='00', minut='00', h
syslog_server_enable = sql.get_setting('syslog_server_enable') 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 +689,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)

View File

@ -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

View File

@ -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(virt=1, 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(virt=1, haproxy=1)
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$10$11$12$13}'" ]
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)

View File

@ -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)

View File

@ -50,7 +50,6 @@ if form.getvalue('getcert') is not None and serv is not None:
if serv and form.getvalue('ssl_cert'): if serv and form.getvalue('ssl_cert'):
#cert_local_dir = funct.get_config_var('main', 'cert_local_dir')
cert_local_dir = os.path.dirname(os.getcwd())+"/"+sql.get_setting('ssl_local_path') cert_local_dir = os.path.dirname(os.getcwd())+"/"+sql.get_setting('ssl_local_path')
cert_path = sql.get_setting('cert_path') cert_path = sql.get_setting('cert_path')
@ -111,6 +110,18 @@ if form.getvalue('action_hap') is not None and serv is not None:
else: else:
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')
@ -148,8 +159,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 +182,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
@ -290,7 +312,7 @@ if act == "overviewHapwi":
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True) env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
template = env.get_template('/overviewHapwi.html') template = env.get_template('/overviewHapwi.html')
cmd = "top -b -n 1 |head -9" cmd = "top -b -n 1 |head -12"
server_status, stderr = funct.subprocess_execute(cmd) server_status, stderr = funct.subprocess_execute(cmd)
template = template.render(server_status=server_status,stderr=stderr) template = template.render(server_status=server_status,stderr=stderr)
@ -324,10 +346,16 @@ if form.getvalue('action'):
if serv is not None and act == "stats": if serv is not None and act == "stats":
import requests import requests
haproxy_user = sql.get_setting('stats_user') if form.getvalue('service') == 'nginx':
haproxy_pass = sql.get_setting('stats_password') haproxy_user = sql.get_setting('nginx_stats_user')
stats_port = sql.get_setting('stats_port') haproxy_pass = sql.get_setting('nginx_stats_password')
stats_page = sql.get_setting('stats_page') stats_port = sql.get_setting('nginx_stats_port')
stats_page = sql.get_setting('nginx_stats_page')
else:
haproxy_user = sql.get_setting('stats_user')
haproxy_pass = sql.get_setting('stats_password')
stats_port = sql.get_setting('stats_port')
stats_page = sql.get_setting('stats_page')
try: try:
response = requests.get('http://%s:%s/%s' % (serv, stats_port, stats_page), auth=(haproxy_user, haproxy_pass)) response = requests.get('http://%s:%s/%s' % (serv, stats_port, stats_page), auth=(haproxy_user, haproxy_pass))
except requests.exceptions.ConnectTimeout: except requests.exceptions.ConnectTimeout:
@ -344,7 +372,25 @@ if serv is not None and act == "stats":
print ("OOps: Something Else",err) print ("OOps: Something Else",err)
data = response.content data = response.content
print(data.decode('utf-8')) if form.getvalue('service') == 'nginx':
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/'))
template = env.get_template('ajax/nginx_stats.html')
servers_with_status = list()
h = ()
out1 = []
for k in data.decode('utf-8').split():
out1.append(k)
h = (out1, )
servers_with_status.append(h)
template = template.render(out=servers_with_status)
print(template)
else:
print(data.decode('utf-8'))
if serv is not None and form.getvalue('rows') is not None: if serv is not None and form.getvalue('rows') is not None:
@ -355,7 +401,8 @@ if serv is not None and form.getvalue('rows') is not None:
minut = form.getvalue('minut') 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 +597,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 +610,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 +628,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 +638,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"])
@ -627,6 +683,10 @@ if form.getvalue('master'):
funct.install_haproxy(master) funct.install_haproxy(master)
funct.install_haproxy(slave) funct.install_haproxy(slave)
if form.getvalue('nginx') == "1":
funct.install_nginx(master)
funct.install_nginx(slave)
commands = [ "chmod +x "+script +" && ./"+script +" PROXY=" + proxy_serv+ commands = [ "chmod +x "+script +" && ./"+script +" PROXY=" + proxy_serv+
" ETH="+ETH+" IP="+str(IP)+" MASTER=MASTER"+" SYN_FLOOD="+syn_flood+" HOST="+str(master)+ " ETH="+ETH+" IP="+str(IP)+" MASTER=MASTER"+" SYN_FLOOD="+syn_flood+" HOST="+str(master)+
" USER="+str(ssh_user_name)+" PASS="+str(ssh_user_password)+" KEY="+str(ssh_key_name) ] " USER="+str(ssh_user_name)+" PASS="+str(ssh_user_password)+" KEY="+str(ssh_key_name) ]
@ -827,6 +887,10 @@ if form.getvalue('backup') or form.getvalue('deljob') or form.getvalue('backupup
print('Ok') print('Ok')
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'):
funct.install_nginx(form.getvalue('install_nginx'))
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 +980,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:
@ -1090,18 +1159,17 @@ if form.getvalue('newserver') is not None:
ip = form.getvalue('newip') ip = form.getvalue('newip')
group = form.getvalue('newservergroup') group = form.getvalue('newservergroup')
typeip = form.getvalue('typeip') typeip = form.getvalue('typeip')
haproxy = form.getvalue('haproxy')
nginx = form.getvalue('nginx')
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, haproxy, nginx):
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,23 +1184,32 @@ 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')
typeip = form.getvalue('typeip') typeip = form.getvalue('typeip')
haproxy = form.getvalue('haproxy')
nginx = form.getvalue('nginx')
enable = form.getvalue('enable') enable = form.getvalue('enable')
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, haproxy, nginx)
funct.logging('the server '+name, ' has updated ', haproxywi=1, login=1) funct.logging('the server '+name, ' has updated ', haproxywi=1, login=1)

View File

@ -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;
#}
}

View File

@ -1,10 +1,4 @@
{% if MASTER == 'BACKUP' %} vrrp_instance VI_{{IP}} {
{% set ID = '101' %}
{% else %}
{% set ID = '100' %}
{% endif %}
vrrp_instance VI_{{ID}} {
state {{MASTER}} state {{MASTER}}
interface {{ETH}} interface {{ETH}}
virtual_router_id 101 virtual_router_id 101

View File

@ -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}}"

View File

@ -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

View File

@ -124,6 +124,7 @@ def add_group(name, description):
return True return True
cur.close() cur.close()
con.close() con.close()
def delete_group(id): def delete_group(id):
con, cur = get_cur() con, cur = get_cur()
@ -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
@ -157,12 +159,13 @@ def update_group(name, descript, id):
return True return True
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, haproxy, nginx):
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`, haproxy, nginx)
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, haproxy, nginx)
try: try:
cur.execute(sql) cur.execute(sql)
con.commit() con.commit()
@ -173,6 +176,7 @@ def add_server(hostname, ip, group, typeip, enable, master, cred, alert, metrics
return False return False
cur.close() cur.close()
con.close() con.close()
def delete_server(id): def delete_server(id):
con, cur = get_cur() con, cur = get_cur()
@ -187,22 +191,15 @@ def delete_server(id):
return True return True
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()
@ -211,6 +208,31 @@ def update_server(hostname, group, typeip, enable, master, id, cred, alert, metr
con.rollback() con.rollback()
cur.close() cur.close()
con.close() con.close()
def update_server(hostname, group, typeip, enable, master, id, cred, port, desc, haproxy, nginx):
con, cur = get_cur()
sql = """ update servers set
hostname = '%s',
groups = '%s',
type_ip = '%s',
enable = '%s',
master = '%s',
cred = '%s',
port = '%s',
`desc` = '%s',
haproxy = '%s',
nginx = '%s'
where id = '%s'""" % (hostname, group, typeip, enable, master, cred, port, desc, haproxy, nginx, id)
try:
cur.execute(sql)
con.commit()
except sqltool.Error as e:
out_error(e)
con.rollback()
cur.close()
con.close()
def update_server_master(master, slave): def update_server_master(master, slave):
con, cur = get_cur() con, cur = get_cur()
@ -514,6 +536,9 @@ 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 = ''
haproxy = ''
nginx = ''
keepalived = ''
ip = '' ip = ''
con, cur = get_cur() con, cur = get_cur()
@ -529,6 +554,12 @@ 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('haproxy'):
haproxy = "and haproxy = 1"
if kwargs.get('nginx'):
nginx = "and nginx = 1"
if kwargs.get('keepalived'):
nginx = "and keepalived = 1"
try: try:
cur.execute(sql) cur.execute(sql)
@ -537,18 +568,21 @@ 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} {haproxy} {nginx} {keepalived}
""".format(group=group[5], disable=disable, type_ip=type_ip, ip=ip, haproxy=haproxy, nginx=nginx, keepalived=keepalived)
try: try:
cur.execute(sql) cur.execute(sql)
except sqltool.Error as e: except sqltool.Error as e:
out_error(e) out_error(e)
else: else:
return cur.fetchall() return cur.fetchall()
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 +597,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 +616,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 +631,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 +646,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
@ -1491,6 +1529,50 @@ def update_keepalived(serv):
return False return False
cur.close() cur.close()
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 update_haproxy(serv):
con, cur = get_cur()
sql = """update `servers` set `haproxy` = '1' where ip = '%s' """ % serv
try:
cur.execute(sql)
con.commit()
return True
except sqltool.Error as e:
out_error(e)
con.rollback()
return False
cur.close()
con.close()
def check_token_exists(token): def check_token_exists(token):

View File

@ -145,9 +145,8 @@
<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">HAProxy</th>
<th class="checkbox-head"><span title="Enable save and show metrics">Metrics</span></th> <th class="checkbox-head">Nginx</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>

View File

@ -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>

View File

@ -13,13 +13,13 @@
<td> <td>
{% if role <= 1 %} {% if role <= 1 %}
<a id="{{ service.1 }}" class="start-waf" title="Start WAF service"> <a id="{{ service.1 }}" class="start-waf" title="Start WAF service">
<img src=/inc/images/start.png alt="start" class="icon" style="margin-bottom: -4px;"> <span class="service-start" onclick="confirmAjaxAction('start', 'waf', '{{service.1}}')"></span>
</a> </a>
<a id="{{ service.1 }}" class="stop-waf" title="Stop WAF service"> <a id="{{ service.1 }}" class="stop-waf" title="Stop WAF service">
<img src=/inc/images/stop.png alt="start" class="icon" width="17px"> <span class="service-stop" onclick="confirmAjaxAction('stop', 'waf', '{{service.1}}')"></span>
</a> </a>
<a id="{{ service.1 }}" class="restart-waf" title="Restart WAF service"> <a id="{{ service.1 }}" class="restart-waf" title="Restart WAF service">
<img src=/inc/images/update.png alt="restart" class="icon"> <span class="service-reload" onclick="confirmAjaxAction('restart', 'restart', '{{service.1}}')"></span>
</a> </a>
{% endif %} {% endif %}
</td> </td>
@ -76,4 +76,5 @@
</script> </script>
<style> <style>
.ui-selectmenu-button.ui-button {width: 10em;} .ui-selectmenu-button.ui-button {width: 10em;}
.fa-play, .fa-stop, .fa-sync-alt { margin-bottom: -1px; }
</style> </style>

View File

@ -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>

View File

@ -1,5 +1,13 @@
{% for service in service_status %} {%- for service in service_status -%}
<div class="server-info"> <div class="server-info">
<div class="server-name">
Server status
<span class="update-icon">
<a onclick="showOverviewServer('{{ service.0 }}', '{{ service.1 }}', '{{id}}')" title="Refresh">
<span class="service-reload"></span>
</a>
</span>
</div>
<div class="haproxy-info"> <div class="haproxy-info">
{{ service.2 }} {{ service.2 }}
</div> </div>
@ -7,11 +15,6 @@
<pre> <pre>
{{ service.3 }} {{ service.3 }}
</pre> </pre>
</div> </div>
<div class="update-icon">
<a onclick="showOverviewServer('{{ service.0 }}', '{{ service.1 }}', '{{id}}')" title="Refresh">
<img src="/inc/images/update.png" alt="restart" class="icon">
</a>
</div>
</div> </div>
{% endfor %} {% endfor %}

View File

@ -53,37 +53,37 @@
<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/viewsttats.py" title="Show stats" class="stats head-submenu">Stats</a></li>
<li><a href="/app/edit.py" title="Runtime API" class="runtime head-submenu">Runtime API</a></li>
<li><a href="/app/metrics.py" title="Metrics" class="metrics head-submenu">Metrics</a></li>
{% if role <= 2 %} {% 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>
<li><a href="/app/add.py#ssl" title="Upload SSL cert" class="cert head-submenu" id="add4">SSL</a></li> <li><a href="/app/add.py#ssl" title="Upload SSL cert" class="cert head-submenu" id="add3">SSL</a></li>
<li><a href="/app/add.py#option" title="Save custom options" class="option head-submenu" id="add5">Options</a></li> <li><a href="/app/add.py#lists" title="Manage black and white lists" class="lists head-submenu" id="add7">Lists</a></li>
<li><a href="/app/add.py#add-servers" title="Save servers" class="runtime head-submenu" id="add6">Servers</a></li>
<li><a href="/app/add.py#userlist" title="Add userlist" class="add-userlist head-submenu" id="add7">User lists</a></li>
<li><a href="/app/add.py#lists" title="Manage black and white lists" class="lists head-submenu" id="add8">Lists</a></li>
<li><a href="/app/waf.py" title="Web application firewall" class="waf head-submenu">WAF</a> </li> <li><a href="/app/waf.py" title="Web application firewall" class="waf head-submenu">WAF</a> </li>
{% endif %} {% endif %}
</ul> </ul>
</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>
@ -130,8 +130,8 @@
<span class="auto-refresh"> <span class="auto-refresh">
<a onclick="pauseAutoRefresh()" class="auto-refresh-pause" style="display: none; margin-top: 4px;"></a> <a onclick="pauseAutoRefresh()" class="auto-refresh-pause" style="display: none; margin-top: 4px;"></a>
<a onclick="pauseAutoResume()" class="auto-refresh-resume" style="display: none; margin-top: 4px;"></a> <a onclick="pauseAutoResume()" class="auto-refresh-resume" style="display: none; margin-top: 4px;"></a>
<a id="0"><img src="/inc/images/update.png" alt="restart" class="icon"> Auto-refresh</a> <a id="0"><span class="service-reload"></span> Auto-refresh</a>
<a id="1" style="display: none;"><img src="/inc/images/update.png" alt="restart" class="icon"> Auto-refresh</a> <a id="1" style="display: none;"><span class="service-reload"></span> Auto-refresh</a>
</span> </span>
{% endif %} {% endif %}
</h2> </h2>
@ -241,7 +241,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}}

View File

@ -6,34 +6,27 @@
<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 select.2 == serv %}
{% if select.1 == serv %} <option value="{{ select.2 }}" selected>{{ select.1 }}</option>
<option value="{{ select.1 }}" selected>{{ select.0 }}</option>
{% else %}
<option value="{{ select.1 }}">{{ select.0 }}</option>
{% endif %}
{% if select.3 == serv %}
<option value="{{ select.3 }}" selected>{{ select.2 }}</option>
{% else %}
<option value="{{ select.3 }}">{{ select.2 }}</option>
{% endif %}
{% else %} {% else %}
{% if select.2 == serv %} <option value="{{ select.2 }}">{{ select.1 }}</option>
<option value="{{ select.2 }}" selected>{{ select.1 }}</option>
{% else %}
<option value="{{ select.2 }}">{{ select.1 }}</option>
{% endif %}
{% 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 +52,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 +82,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') {

View File

@ -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>

View File

@ -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 %}

View File

@ -10,6 +10,7 @@
<td><span title="Interface for VRRP addreess">Interface(?)</span></td> <td><span title="Interface for VRRP addreess">Interface(?)</span></td>
<td>VRRP IP</td> <td>VRRP IP</td>
<td><span title="HAProxy-WI will try install HAProxy">HAProxy(?)</span></td> <td><span title="HAProxy-WI will try install HAProxy">HAProxy(?)</span></td>
<td><span title="HAProxy-WI will try install Nginx">Nginx(?)</span></td>
<td>SYN flood protect</td> <td>SYN flood protect</td>
<td></td> <td></td>
</tr> </tr>
@ -33,6 +34,7 @@
<td>{{ input('interface', size='7') }}</td> <td>{{ input('interface', size='7') }}</td>
<td>{{ input('vrrp-ip', size='14') }}</td> <td>{{ input('vrrp-ip', size='14') }}</td>
<td>{{ checkbox('hap') }}</td> <td>{{ checkbox('hap') }}</td>
<td>{{ checkbox('nginx') }}</td>
<td>{{ checkbox('syn_flood') }}</td> <td>{{ checkbox('syn_flood') }}</td>
<td> <td>
<a class="ui-button ui-widget ui-corner-all" id="create" title="Create HA configuration">Create</a> <a class="ui-button ui-widget ui-corner-all" id="create" title="Create HA configuration">Create</a>
@ -48,7 +50,8 @@
<td><span title="Interface for VRRP addreess">Interface(?)</span></td> <td><span title="Interface for VRRP addreess">Interface(?)</span></td>
<td>VRRP IP</td> <td>VRRP IP</td>
<td><span title="If checked HAProxy-WI will restart Keepalived">Restart(?)</span></td> <td><span title="If checked HAProxy-WI will restart Keepalived">Restart(?)</span></td>
<td style="width: 20%;"></td> <td style="width: 23%;"></td>
<td></td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
@ -72,6 +75,7 @@
<td>{{ input('vrrp-ip-add', size='14') }}</td> <td>{{ input('vrrp-ip-add', size='14') }}</td>
<td>{{ checkbox('kp') }}</td> <td>{{ checkbox('kp') }}</td>
<td></td> <td></td>
<td></td>
<td> <td>
<a class="ui-button ui-widget ui-corner-all" id="add-vrrp" title="Add HA configuration">Add</a> <a class="ui-button ui-widget ui-corner-all" id="add-vrrp" title="Add HA configuration">Add</a>
</td> </td>

View File

@ -47,37 +47,55 @@
</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}}')"> <span class="service-start" onclick="confirmAjaxAction('start', '{{action_service}}', '{{s.2}}')"></span>
</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}}')"> <span class="service-stop" onclick="confirmAjaxAction('stop', '{{action_service}}', '{{s.2}}')"></span>
</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">
<img src=/inc/images/update.png alt="restart" class="icon-hapservs"> <span class="service-reload" onclick="confirmAjaxAction('restart', '{{action_service}}', '{{s.2}}')"></span>
</a> </a>
</span> </span>
{% endif %} {% endif %}
@ -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,21 +123,51 @@
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>
{% if serv %} {% if serv %}
<div id="ajax-server-{{s.0}}" class="ajax-server"></div> <div id="ajax-server-{{s.0}}" class="ajax-server"></div>
<div class="div-server div-backends"> <div class="div-server div-backends">
<div class="server-name"> <div class="server-name backends">
Backends: Backends:
</div> </div>
<div style="margin-top: 10px;" id="top-{{s.1}}"></div> <div style="margin-top: 10px;" id="top-{{s.1}}"></div>
@ -126,7 +178,7 @@
</div> </div>
{% if serv %} {% if serv %}
<div id="refresh" style="text-align: right;margin-right: 105px;clear: both;display: block;padding-top: 20px;margin-bottom: -25px;" title="Refresh metrics" onclick="showMetrics()"> <div id="refresh" style="text-align: right;margin-right: 105px;clear: both;display: block;padding-top: 20px;margin-bottom: -25px;" title="Refresh metrics" onclick="showMetrics()">
<img src="/inc/images/update.png" alt="Refresh" class="icon"> <span class="service-reload"></span>
</div> </div>
{% for s in servers %} {% for s in servers %}
<div class="chart-container" style="display: block; width: 90%; height: 300px;"> <div class="chart-container" style="display: block; width: 90%; height: 300px;">
@ -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 %}

View File

@ -50,6 +50,16 @@
</div> </div>
</div> </div>
</div> </div>
<div class="div-pannel">
<div class="div-server">
<div class="server-name">
<span title="Create presaved options" class="span-link" id="add4">Create presaved options</span>
</div>
<div class="server-desc">
Create, edit and delete options with given parameters. And after use them as autocomplete in the "Add" sections
</div>
</div>
</div>
</div> </div>
<div id="middle-collumn"> <div id="middle-collumn">
<div class="div-pannel"> <div class="div-pannel">
@ -92,6 +102,16 @@
</div> </div>
</div> </div>
</div> </div>
<div class="div-pannel">
<div class="div-server">
<div class="server-name">
<span title="Create presaved servers" class="span-link" id="add5">Create presaved servers</span>
</div>
<div class="server-desc">
Create, edit and delete servers. And after use them as autocomplete in the "Add" sections
</div>
</div>
</div>
</div> </div>
<div id="right-collumn"> <div id="right-collumn">
<div class="div-pannel"> <div class="div-pannel">
@ -134,5 +154,15 @@
</div> </div>
</div> </div>
</div> </div>
<div class="div-pannel">
<div class="div-server">
<div class="server-name">
<span title="Create userlists" class="span-link" id="add6">Create userlists</span>
</div>
<div class="server-desc">
Create userlists. And use it in the "Add" sections
</div>
</div>
</div>
</div> </div>
</div> </div>

View File

@ -34,16 +34,12 @@
<td>{{ checkbox('typeip') }}</td> <td>{{ checkbox('typeip') }}</td>
</tr> </tr>
<tr> <tr>
<td class="padding20" title="Alert if backend change status">Alert</td> <td class="padding20" title="Is there HAProxy?">HAProxy</td>
<td>{{ checkbox('alert') }} </td> <td>{{ checkbox('haproxy') }} </td>
</tr> </tr>
<tr> <tr>
<td class="padding20" title="Enable save and show metrics">Metrics</td> <td class="padding20" title="Is there Nginx?">Nginx</td>
<td>{{ checkbox('metrics') }}</td> <td>{{ checkbox('nginx') }}</td>
</tr>
<tr>
<td class="padding20" title="Keep start HAProxy service if down">Start</td>
<td>{{ checkbox('active') }}</td>
</tr> </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>

View File

@ -16,24 +16,16 @@
{% endif %} {% endif %}
</td> </td>
<td class="checkbox"> <td class="checkbox">
{% set id = 'alert-' + server.0|string() %} {% set id = 'haproxy-' + server.0|string() %}
{% if server.8 == 1 %} {% if server.15 == 1 %}
{{ checkbox(id, checked='checked') }} {{ checkbox(id, checked='checked') }}
{% else %} {% else %}
{{ checkbox(id) }} {{ checkbox(id) }}
{% endif %} {% endif %}
</td> </td>
<td class="checkbox"> <td class="checkbox">
{% set id = 'metrics-' + server.0|string() %} {% set id = 'nginx-' + server.0|string() %}
{% if server.9 == 1 %} {% if server.14 == 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') }} {{ checkbox(id, checked='checked') }}
{% else %} {% else %}
{{ checkbox(id) }} {{ checkbox(id) }}

View File

@ -1,28 +0,0 @@
<td class="padding10 first-collumn">
{% if user.6 == 1%}
<input type="text" id="login-{{user.0}}" value="{{user.1}}" class="form-control" readonly>
{% else %}
<input type="text" id="login-{{user.0}}" value="{{user.1}}" class="form-control">
{% endif %}
</td>
<td>
{% if user.6 != 1%}
<span title="Change password" style="cursor: pointer">
<img src="/inc/images/edit.png" alt="Edit" width="15" style="margin-bottom: -3px; padding-left: 15px;" onclick="openChangeUserPasswordDialog('{{user.0}}')" />
</span>
{% endif %}
</td>
<td class="checkbox">
{% if user.7 == 1 %}
<label for="activeuser-{{user.0}}"></label><input type="checkbox" id="activeuser-{{user.0}}" checked>
{% else %}
<label for="activeuser-{{user.0}}"></label><input type="checkbox" id="activeuser-{{user.0}}">
{% endif %}
</td>
<td>
{% if user.6 == 1%}
<input type="text" id="email-{{user.0}}" value="{{user.2}}" class="form-control" readonly>
{% else %}
<input type="text" id="email-{{user.0}}" value="{{user.2}}" class="form-control">
{% endif %}
</td>

View File

@ -9,8 +9,7 @@
</td> </td>
<td> <td>
{% if user.6 != 1%} {% if user.6 != 1%}
<span title="Change password" style="cursor: pointer"> <span title="Change password" style="cursor: pointer; margin-left: 15px;" class="div-pic" onclick="openChangeUserPasswordDialog('{{user.0}}')">
<img src="/inc/images/edit.png" alt="Edit" width="15" style="margin-bottom: -3px; padding-left: 15px;" onclick="openChangeUserPasswordDialog('{{user.0}}')" />
</span> </span>
{% endif %} {% endif %}
</td> </td>

View File

@ -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>

View File

@ -17,7 +17,7 @@ th, tr, td {
<script src="/inc/chart.min.js"></script> <script src="/inc/chart.min.js"></script>
<div id="table_metrics"></div> <div id="table_metrics"></div>
<div id="refresh" style="text-align: right;margin-top: 20px;margin-right: 10px;" title="Refresh metrics" onclick="showMetrics()"> <div id="refresh" style="text-align: right;margin-top: 20px;margin-right: 10px;" title="Refresh metrics" onclick="showMetrics()">
<img src="/inc/images/update.png" alt="Refresh" class="icon"> <span class="service-reload"></span>
</div> </div>
{% for s in servers %} {% for s in servers %}
<div class="chart-container"> <div class="chart-container">

View File

@ -10,16 +10,24 @@
hostnamea.push("{{s[1]}}") hostnamea.push("{{s[1]}}")
{% endfor %} {% endfor %}
</script> </script>
<style>
.fa-sync-alt { margin-bottom: -1px; }
</style>
<table class="overview-wi"> <table class="overview-wi">
<tr class="overviewHead"> <tr class="overviewHead">
<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">
<a href="/app/hapservers.py?service=nginx" title="Nginx servers overview" class="logs_link">
Nginx
</a>
</td>
<td class="padding10"> <td class="padding10">
Keealived Keealived
</td> </td>
@ -29,7 +37,9 @@
</a> </a>
</td class="padding10"> </td class="padding10">
<td> <td>
<a onclick="showOverview(ip, hostnamea)" title="Refresh" style="float: right; margin-right: 25px;"><img src="/inc/images/update.png" alt="hostname" class="icon"></a> <a onclick="showOverview(ip, hostnamea)" title="Refresh" style="float: right; margin-right: 25px;">
<span class="service-reload"></span>
</a>
</td> </td>
</tr> </tr>
{% for s in servers %} {% for s in servers %}
@ -48,7 +58,9 @@
{% endif %} {% endif %}
</td> </td>
<td> <td>
<a onclick="showOverviewHapWI()" title="Refresh" style="float: right; margin-right: 25px;"><img src="/inc/images/update.png" alt="restart" class="icon"></a> <a onclick="showOverviewHapWI()" title="Refresh" style="float: right; margin-right: 25px;">
<span class="service-reload"></span>
</a>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -169,9 +181,9 @@
{% if counter <= 2 %} {% if counter <= 2 %}
<tr class="{{ loop.cycle('odd', 'even') }}"> <tr class="{{ loop.cycle('odd', 'even') }}">
<td class="padding10 first-collumn-wi"> <td class="padding10 first-collumn-wi">
<a href="users.py#users" title="Edit user" class="logs_link"> <a href="users.py#users" title="Edit user" class="logs_link div-pic">
{{ USER.1 }} {{ USER.1 }}
<img src="/inc/images/edit.png" alt="Edit" width="15" style="margin-bottom: -3px;" />
</a> </a>
</td> </td>
{% for group in groups %} {% for group in groups %}
@ -184,9 +196,8 @@
{% else %} {% else %}
<tr style="display: none;" class="show-users {{ loop.cycle('odd', 'even') }}"> <tr style="display: none;" class="show-users {{ loop.cycle('odd', 'even') }}">
<td class="padding10 first-collumn-wi"> <td class="padding10 first-collumn-wi">
<a href="users.py#users" title="Edit user" class="logs_link"> <a href="users.py#users" title="Edit user" class="logs_link div-pic">
{{ USER.1 }} {{ USER.1 }}
<img src="/inc/images/edit.png" alt="Edit" width="15" style="margin-bottom: -3px;" />
</a> </a>
</td> </td>
{% for group in groups %} {% for group in groups %}
@ -218,9 +229,8 @@
{% if counter <= 2 %} {% if counter <= 2 %}
<tr class="{{ loop.cycle('odd', 'even') }}"> <tr class="{{ loop.cycle('odd', 'even') }}">
<td class="padding10 first-collumn-wi"> <td class="padding10 first-collumn-wi">
<a href="users.py#groups" title="Edit groups" class="logs_link"> <a href="users.py#groups" title="Edit groups" class="logs_link div-pic">
{{ group.1 }} {{ group.1 }}
<img src="/inc/images/edit.png" alt="Edit" width="15" style="margin-bottom: -3px;" />
</a> </a>
</td> </td>
<td class="third-collumn-wi" colspan="2">{{ group.2 }}</td> <td class="third-collumn-wi" colspan="2">{{ group.2 }}</td>
@ -228,9 +238,8 @@
{% else %} {% else %}
<tr style="display: none;" class="show-groups {{ loop.cycle('odd', 'even') }}"> <tr style="display: none;" class="show-groups {{ loop.cycle('odd', 'even') }}">
<td class="padding10 first-collumn-wi"> <td class="padding10 first-collumn-wi">
<a href="users.py#groups" title="Edit groups" class="logs_link"> <a href="users.py#groups" title="Edit groups" class="logs_link div-pic">
{{ group.1 }} {{ group.1 }}
<img src="/inc/images/edit.png" alt="Edit" width="15" style="margin-bottom: -3px;" />
</a> </a>
</td> </td>
<td class="third-collumn-wi" colspan="2">{{ group.2 }}</td> <td class="third-collumn-wi" colspan="2">{{ group.2 }}</td>

View File

@ -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,8 @@
<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> <th class="checkbox-head">HAProxy</th>
<td class="checkbox-head"><span title="Enable save and show metrics">Metrics</span></td> <th class="checkbox-head">Nginx</th>
<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 +273,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 +305,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 +467,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 );
} }

View File

@ -32,7 +32,9 @@
Metrics Metrics
</td> </td>
<td> <td>
<a onclick="showOverviewWaf(ip, hostnamea)" title="Refresh" style="float: right; margin-right: 25px;"><img src="/inc/images/update.png" alt="Refresh" class="icon"></a> <a onclick="showOverviewWaf(ip, hostnamea)" title="Refresh" style="float: right; margin-right: 25px;">
<span class="service-reload"></span>
</a>
</td> </td>
</tr> </tr>
{% for s in servers_all %} {% for s in servers_all %}
@ -46,7 +48,7 @@
<script src="/inc/chart.min.js"></script> <script src="/inc/chart.min.js"></script>
<script src="/inc/waf.js"></script> <script src="/inc/waf.js"></script>
<div id="refresh" style="text-align: right;margin-top: 20px;margin-right: 20px;" title="Refresh metrics" onclick="showWafMetrics()"> <div id="refresh" style="text-align: right;margin-top: 20px;margin-right: 20px;" title="Refresh metrics" onclick="showWafMetrics()">
<img src="/inc/images/update.png" alt="Refresh" class="icon"> <span class="service-reload"></span>
</div> </div>
{% for s in servers %} {% for s in servers %}
<div class="chart-container"> <div class="chart-container">

View File

@ -35,11 +35,18 @@ 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' format = 'conf'
elif service == 'nginx':
configs_dir = funct.get_config_var('configs', 'nginx_save_configs_dir')
title = "Working with versions Nginx configs"
files = funct.get_files(dir=configs_dir, format='conf')
action = 'versions.py?service=nginx'
format = 'conf'
servers = sql.get_dick_permit(nginx=1)
else: else:
title = "Working with versions HAProxy configs" title = "Working with versions HAProxy configs"
files = funct.get_files() files = funct.get_files()
@ -59,7 +66,7 @@ if serv is not None and form.getvalue('del') is not None:
funct.logging(serv, "versions.py were deleted configs: %s" % form.getvalue(get)) funct.logging(serv, "versions.py were deleted configs: %s" % form.getvalue(get))
except OSError as e: except OSError as e:
stderr = "Error: %s - %s." % (e.filename,e.strerror) stderr = "Error: %s - %s." % (e.filename,e.strerror)
print('<meta http-equiv="refresh" content="10; url=versions.py?serv=%s&open=open&service=%s">' % (form.getvalue('serv'), service)) print('<meta http-equiv="refresh" content="10; url=versions.py?service=%s&serv=%s&open=open">' % (service, form.getvalue('serv')))
if serv is not None and form.getvalue('config') is not None: if serv is not None and form.getvalue('config') is not None:
@ -71,7 +78,9 @@ if serv is not None and form.getvalue('config') is not None:
except: 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)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 109 KiB

View File

@ -680,33 +680,24 @@ $( function() {
}); });
$( "#tabs" ).tabs( "option", "active", 0 ); $( "#tabs" ).tabs( "option", "active", 0 );
} ); } );
$( "#add4" ).on( "click", function() { $( "#add3" ).on( "click", function() {
$('.menu li ul li').each(function () { $('.menu li ul li').each(function () {
$(this).find('a').css('padding-left', '20px') $(this).find('a').css('padding-left', '20px')
$(this).find('a').css('border-left', '0px solid #5D9CEB'); $(this).find('a').css('border-left', '0px solid #5D9CEB');
$(this).children("#add4").css('padding-left', '30px');; $(this).children("#add3").css('padding-left', '30px');
$(this).children("#add4").css('border-left', '4px solid #5D9CEB'); $(this).children("#add3").css('border-left', '4px solid #5D9CEB');
}); });
$( "#tabs" ).tabs( "option", "active", 4 ); $( "#tabs" ).tabs( "option", "active", 4 );
} ); } );
$( "#add5" ).on( "click", function() { $( "#add4" ).on( "click", function() {
$('.menu li ul li').each(function () {
$(this).find('a').css('padding-left', '20px')
$(this).find('a').css('border-left', '0px solid #5D9CEB');
$(this).children("#add5").css('padding-left', '30px');;
$(this).children("#add5").css('border-left', '4px solid #5D9CEB');
});
$( "#tabs" ).tabs( "option", "active", 5 ); $( "#tabs" ).tabs( "option", "active", 5 );
} ); } );
$( "#add6" ).on( "click", function() { $( "#add5" ).on( "click", function() {
$('.menu li ul li').each(function () {
$(this).find('a').css('padding-left', '20px')
$(this).find('a').css('border-left', '0px solid #5D9CEB');
$(this).children("#add6").css('padding-left', '30px');
$(this).children("#add6").css('border-left', '4px solid #5D9CEB');
});
$( "#tabs" ).tabs( "option", "active", 6 ); $( "#tabs" ).tabs( "option", "active", 6 );
} ); } );
$( "#add6" ).on( "click", function() {
$( "#tabs" ).tabs( "option", "active", 7 );
} );
$( "#add7" ).on( "click", function() { $( "#add7" ).on( "click", function() {
$('.menu li ul li').each(function () { $('.menu li ul li').each(function () {
$(this).find('a').css('padding-left', '20px') $(this).find('a').css('padding-left', '20px')
@ -714,15 +705,6 @@ $( function() {
$(this).children("#add7").css('padding-left', '30px'); $(this).children("#add7").css('padding-left', '30px');
$(this).children("#add7").css('border-left', '4px solid #5D9CEB'); $(this).children("#add7").css('border-left', '4px solid #5D9CEB');
}); });
$( "#tabs" ).tabs( "option", "active", 7 );
} );
$( "#add8" ).on( "click", function() {
$('.menu li ul li').each(function () {
$(this).find('a').css('padding-left', '20px')
$(this).find('a').css('border-left', '0px solid #5D9CEB');
$(this).children("#add8").css('padding-left', '30px');
$(this).children("#add8").css('border-left', '4px solid #5D9CEB');
});
$( "#tabs" ).tabs( "option", "active", 8 ); $( "#tabs" ).tabs( "option", "active", 8 );
} ); } );
} }

View File

@ -50,7 +50,7 @@
.config-show::before { .config-show::before {
display: none; display: none;
font-family: "Font Awesome 5 Solid"; font-family: "Font Awesome 5 Solid";
content: "\f10a"; content: "\f6ff";
} }
.compare::before { .compare::before {
display: none; display: none;
@ -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";
@ -185,4 +190,43 @@
font-family: "Font Awesome 5 Solid"; font-family: "Font Awesome 5 Solid";
content: "\f093"; content: "\f093";
padding-left: 5px; padding-left: 5px;
}
.backends::before {
display: none;
font-family: "Font Awesome 5 Solid";
content: "\f233";
padding-left: 5px;
}
.div-pic::after {
display: none;
font-family: "Font Awesome 5 Solid";
content: "\f303";
}
.fa-pencil-alt{
padding-left: 7px;
color: #5cb85c !important;
}
.service-start::after {
display: none;
font-family: "Font Awesome 5 Solid";
content: "\f04b";
}
.fa-play, .fa-stop, .fa-sync-alt {
width: 3px;
color: #a0d100 !important;
cursor: pointer;
margin-bottom: 3px;
}
.service-stop::after {
display: none;
font-family: "Font Awesome 5 Solid";
content: "\f04d";
}
.fa-stop {
color: red !important;
}
.service-reload::after {
display: none;
font-family: "Font Awesome 5 Solid";
content: "\f2f1";
} }

6
inc/fa-solid.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 832 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 722 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 932 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 847 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 674 B

View File

@ -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() {
@ -41,7 +42,6 @@ function showHapserversCallBack(serv, hostnamea) {
} ); } );
} }
function overviewHapserverBackends(serv, hostnamea) { function overviewHapserverBackends(serv, hostnamea) {
console.log("#top-"+hostnamea)
$.ajax( { $.ajax( {
url: "options.py", url: "options.py",
data: { data: {
@ -110,6 +110,7 @@ function showOverviewServer(name,ip,id) {
$(".div-pannel").css('height', '70px'); $(".div-pannel").css('height', '70px');
$("#div-pannel-"+id).insertBefore('#up-pannel') $("#div-pannel-"+id).insertBefore('#up-pannel')
$("#ajax-server-"+id).html(data); $("#ajax-server-"+id).html(data);
$.getScript("/inc/fontawesome.min.js")
} }
} ); } );
} }
@ -139,6 +140,32 @@ function ajaxActionServers(action, id) {
} }
} ); } );
} }
function ajaxActionNginxServers(action, id) {
var bad_ans = 'Bad config, check please';
$.ajax( {
url: "options.py",
data: {
action_nginx: action,
serv: id,
token: $('#token').val()
},
success: function( data ) {
data = data.replace(/\s+/g,' ');
if( data == 'Bad config, check please ' ) {
alert(data);
} else {
if (cur_url[0] == "hapservers.py") {
location.reload()
} else {
setTimeout(showOverview(ip, hostnamea), 2000)
}
}
},
error: function(){
alert(w.data_error);
}
} );
}
function ajaxActionWafServers(action, id) { function ajaxActionWafServers(action, id) {
var bad_ans = 'Bad config, check please'; var bad_ans = 'Bad config, check please';
$.ajax( { $.ajax( {
@ -162,33 +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() {
var id = $(this).attr('id');
confirmAjaxAction("start", "waf", id);
});
$('.stop-waf').click(function() {
var id = $(this).attr('id');
confirmAjaxAction("stop", "waf", id);
});
$('.restart-waf').click(function() {
var id = $(this).attr('id');
confirmAjaxAction("restart", "waf", id);
});
$( "#show-all-users" ).click( function() { $( "#show-all-users" ).click( function() {
$( ".show-users" ).show("fast"); $( ".show-users" ).show("fast");
$( "#show-all-users" ).text("Hide"); $( "#show-all-users" ).text("Hide");
@ -235,6 +235,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 +260,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() {
@ -263,4 +269,45 @@ function confirmAjaxAction(action, service, id) {
} }
} }
}); });
}
function updateHapWIServer(id) {
var alert_en = 0;
var metrics = 0;
var active = 0;
if ($('#alert-'+id).is(':checked')) {
alert_en = '1';
}
if ($('#metrics-'+id).is(':checked')) {
metrics = '1';
}
if ($('#active-'+id).is(':checked')) {
active = '1';
}
$.ajax( {
url: "options.py",
data: {
updatehapwiserver: id,
metrics: metrics,
alert_en: alert_en,
active: active,
token: $('#token').val()
},
type: "POST",
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1') {
$("#ajax-servers").append(data);
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
});
} else {
$('.alert-danger').remove();
$("#server-"+id).addClass( "update", 1000 );
setTimeout(function() {
$( "#server-"+id ).removeClass( "update" );
}, 2500 );
}
}
} );
} }

View File

@ -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');
@ -124,13 +154,14 @@ function setRefreshInterval(interval) {
if (interval == "0") { if (interval == "0") {
Cookies.remove('auto-refresh'); Cookies.remove('auto-refresh');
pauseAutoRefresh(); pauseAutoRefresh();
$('.auto-refresh').prepend('<img src=/inc/images/update.png alt="restart" class="icon">'); $('.auto-refresh').prepend('<span class="service-reload"></span>');
$('.auto-refresh').css('margin-top', '-3px'); $('.auto-refresh').css('margin-top', '-3px');
$('#1').text('Auto-refresh'); $('#1').text('Auto-refresh');
$('#0').text('Auto-refresh'); $('#0').text('Auto-refresh');
$('.auto-refresh-pause').css('display', 'none'); $('.auto-refresh-pause').css('display', 'none');
$('.auto-refresh-resume').css('display', 'none'); $('.auto-refresh-resume').css('display', 'none');
hideAutoRefreshDiv(); hideAutoRefreshDiv();
$.getScript("/inc/fontawesome.min.js")
} else { } else {
clearInterval(intervalId); clearInterval(intervalId);
Cookies.set('auto-refresh', interval, { expires: 365 }); Cookies.set('auto-refresh', interval, { expires: 365 });
@ -216,12 +247,13 @@ function showStats() {
data: { data: {
act: "stats", act: "stats",
serv: $("#serv").val(), serv: $("#serv").val(),
service: $("#service").val(),
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("Stats", "Stats", cur_url[0]+"?serv="+$("#serv").val()); window.history.pushState("Stats", "Stats", cur_url[0]+"?service="+$("#service").val()+"&serv="+$("#serv").val());
wait(); wait();
} }
} ); } );
@ -236,6 +268,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 +287,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 +299,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 +364,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 +383,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 +391,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 +431,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 +807,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');
} }
} }
} ); } );

View File

@ -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,10 +290,10 @@ 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: #f3f8fb;
border: 1px solid #ddd; border: 1px solid #ddd;
} }
.line, .line3 { .line, .line3 {
@ -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 {
@ -806,30 +806,33 @@ label {
margin: 25px; margin: 25px;
margin-left: 440px; margin-left: 440px;
margin-bottom: 0; margin-bottom: 0;
width: 60em; width: 750px;
display: none; display: none;
margin-top: px; margin-top: px;
margin-bottom: 0px; margin-bottom: 0px;
margin-top: 0px; margin-top: 0px;
height: 183px; height: 185px;
padding-bottom: 0px;
padding-top: 10px;
padding-left: 15px;
padding-right: 15px;
} }
.haproxy-info { .haproxy-info {
display: inline-block; display: inline-block;
width: 160px; width: 160px;
padding-left: 30px; padding-left: 30px;
padding-top: 35px; padding-top: 15px;
font-size: 12px; font-size: 12px;
float: left; float: left;
} }
.top-info { .top-info {
display: inline-block; display: inline-block;
width: 350px; width: 350px;
margin-top: 30px; margin-top: 10px;
font-size: 10px; font-size: 10px;
} }
.update-icon { .update-icon {
float: right; float: right;
margin-top: 35px;
margin-right: 15px; margin-right: 15px;
} }
.span-link { .span-link {

View File

@ -53,9 +53,13 @@ $( function() {
var ipformat = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; var ipformat = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
$('#create').click(function() { $('#create').click(function() {
var hap = 0; var hap = 0;
var nginx = 0;
var syn_flood = 0; var syn_flood = 0;
if ($('#hap').is(':checked')) { if ($('#hap').is(':checked')) {
hap = '1'; hap = '1';
}
if ($('#nginx').is(':checked')) {
nginx = '1';
} }
if ($('#syn_flood').is(':checked')) { if ($('#syn_flood').is(':checked')) {
syn_flood = '1'; syn_flood = '1';
@ -78,6 +82,7 @@ $( function() {
interface: $("#interface").val(), interface: $("#interface").val(),
vrrpip: $('#vrrp-ip').val(), vrrpip: $('#vrrp-ip').val(),
hap: hap, hap: hap,
nginx: nginx,
syn_flood: syn_flood, syn_flood: syn_flood,
token: $('#token').val() token: $('#token').val()
}, },
@ -178,6 +183,41 @@ $( function() {
} }
} ); } );
}); });
$('#nginx_install').click(function() {
$("#ajax").html('')
var syn_flood = 0;
if ($('#nginx_syn_flood').is(':checked')) {
syn_flood = '1';
}
$("#ajax").html('<div class="alert alert-warning">Please don\'t close and don\'t represh page. Wait until the work is completed. This may take some time </div>');
$.ajax( {
url: "options.py",
data: {
install_nginx: $('#nginxaddserv').val(),
syn_flood: syn_flood,
token: $('#token').val()
},
type: "POST",
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1' || data.indexOf('FAILED') != '-1') {
$("#ajax").html('<div class="alert alert-danger">'+data+'</div>');
} else if (data.indexOf('success') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-success">'+data+'</div>');
} else if (data.indexOf('Info') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
} else {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
}
}
} );
});
$('#update_haproxy_wi').click(function() { $('#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,23 +663,19 @@ 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 haproxy = 0;
var metrics = 0; var nginx = 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')) { if ($('#haproxy').is(':checked')) {
var alert_en = '1'; haproxy = '1';
} }
if ($('#metrics').is(':checked')) { if ($('#nginx').is(':checked')) {
var metrics = '1'; nginx = '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" );
@ -656,14 +692,13 @@ function addServer() {
newport: $('#new-port').val(), newport: $('#new-port').val(),
newservergroup: newservergroup, newservergroup: newservergroup,
typeip: typeip, typeip: typeip,
haproxy: haproxy,
nginx: nginx,
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",
@ -909,25 +944,20 @@ function cloneServer(id) {
} else { } else {
$('#typeip').prop('checked', false) $('#typeip').prop('checked', false)
} }
if ($('#alert-'+id).is(':checked')) { if ($('#haproxy-'+id).is(':checked')) {
$('#alert').prop('checked', true) $('#haproxy').prop('checked', true)
} else { } else {
$('#alert').prop('checked', false) $('#haproxy').prop('checked', false)
} }
if ($('#metrics-'+id).is(':checked')) { if ($('#nginx-'+id).is(':checked')) {
$('#metrics').prop('checked', true) $('#nginx').prop('checked', true)
} else { } else {
$('#metrics').prop('checked', false) $('#nginx').prop('checked', false)
}
if ($('#active-'+id).is(':checked')) {
$('#active').prop('checked', true)
} else {
$('#active').prop('checked', false)
} }
$('#enable').checkboxradio("refresh"); $('#enable').checkboxradio("refresh");
$('#typeip').checkboxradio("refresh"); $('#typeip').checkboxradio("refresh");
$('#alert').checkboxradio("refresh"); $('#haproxy').checkboxradio("refresh");
$('#active').checkboxradio("refresh"); $('#nginx').checkboxradio("refresh");
$('#new-server-add').val($('#hostname-'+id).val()) $('#new-server-add').val($('#hostname-'+id).val())
$('#new-ip').val($('#ip-'+id).val()) $('#new-ip').val($('#ip-'+id).val())
$('#new-port').val($('#port-'+id).val()) $('#new-port').val($('#port-'+id).val())
@ -1161,28 +1191,27 @@ 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 haproxy = 0;
var metrics = 0; var nginx = 0;
var active = 0;
if ($('#typeip-'+id).is(':checked')) { if ($('#typeip-'+id).is(':checked')) {
typeip = '1'; typeip = '1';
} }
if ($('#haproxy-'+id).is(':checked')) {
haproxy = '1';
}
if ($('#nginx-'+id).is(':checked')) {
nginx = '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") { console.log(cur_url[0])
servergroup = $('#servergroup-'+id).val(); if (cur_url[0].split('#')[0] == "servers.py") {
servergroup = $('#new-server-group-add').val();
console.log('1')
} }
console.log(servergroup)
$.ajax( { $.ajax( {
url: "options.py", url: "options.py",
data: { data: {
@ -1190,14 +1219,13 @@ function updateServer(id) {
port: $('#port-'+id).val(), port: $('#port-'+id).val(),
servergroup: servergroup, servergroup: servergroup,
typeip: typeip, typeip: typeip,
haproxy: haproxy,
nginx: nginx,
enable: enable, enable: enable,
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",

View File

@ -1,3 +1,5 @@
var awesome = "/inc/fontawesome.min.js"
$( function() { $( function() {
$( "#ajaxwafstatus input" ).change(function() { $( "#ajaxwafstatus input" ).change(function() {
var id = $(this).attr('id'); var id = $(this).attr('id');
@ -32,6 +34,7 @@ function showOverviewWafCallBack(serv, hostnamea) {
$( "input[type=submit], button" ).button(); $( "input[type=submit], button" ).button();
$( "input[type=checkbox]" ).checkboxradio(); $( "input[type=checkbox]" ).checkboxradio();
$.getScript('/inc/overview.js'); $.getScript('/inc/overview.js');
$.getScript(awesome);
} }
} ); } );
} }