Pavel Loginov 2021-07-01 13:19:23 +06:00
parent 93f19e8a06
commit bb48e6d36c
10 changed files with 262 additions and 91 deletions

View File

@ -272,7 +272,7 @@ def return_ssh_keys_path(serv, **kwargs):
return ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name return ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name
def ssh_connect(serv, **kwargs): def ssh_connect(serv):
import paramiko import paramiko
from paramiko import SSHClient from paramiko import SSHClient
import sql import sql
@ -304,10 +304,13 @@ def ssh_connect(serv, **kwargs):
except paramiko.SSHException as sshException: except paramiko.SSHException as sshException:
return 'error: Unable to establish SSH connection: %s ' % sshException return 'error: Unable to establish SSH connection: %s ' % sshException
except paramiko.PasswordRequiredException as e: except paramiko.PasswordRequiredException as e:
logging('localhost', ' ' + str(e), haproxywi=1)
return 'error: %s ' % e return 'error: %s ' % e
except paramiko.BadHostKeyException as badHostKeyException: except paramiko.BadHostKeyException as badHostKeyException:
logging('localhost', ' ' + str(badHostKeyException), haproxywi=1)
return 'error: Unable to verify server\'s host key: %s ' % badHostKeyException return 'error: Unable to verify server\'s host key: %s ' % badHostKeyException
except Exception as e: except Exception as e:
logging('localhost', ' ' + str(e), haproxywi=1)
if e == "No such file or directory": if e == "No such file or directory":
return 'error: %s. Check ssh key' % e return 'error: %s. Check ssh key' % e
elif e == "Invalid argument": elif e == "Invalid argument":
@ -1015,7 +1018,10 @@ def server_status(stdout):
for line in stdout: for line in stdout:
if "Ncat: " not in line: if "Ncat: " not in line:
for k in line: for k in line:
try:
proc_count = k.split(":")[1] proc_count = k.split(":")[1]
except Exception:
proc_count = 1
else: else:
proc_count = 0 proc_count = 0
return proc_count return proc_count

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import funct import funct
import sql import sql
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
@ -13,7 +12,6 @@ funct.check_login()
try: try:
user, user_id, role, token, servers = funct.get_users_params() user, user_id, role, token, servers = funct.get_users_params()
users = sql.select_users() users = sql.select_users()
groups = sql.select_groups()
services = [] services = []
except: except:
pass pass
@ -26,13 +24,21 @@ cmd = "ps ax |grep -e 'keep_alive.py' |grep -v grep |wc -l"
keep_alive, stderr = funct.subprocess_execute(cmd) keep_alive, stderr = funct.subprocess_execute(cmd)
if service == 'nginx': if service == 'nginx':
title = "Nginx servers overview" title = 'Nginx servers overview'
servers = sql.get_dick_permit(virt=1, nginx=1) servers = sql.get_dick_permit(virt=1, nginx=1)
service = 'nginx' service = 'nginx'
if serv: if serv:
if funct.check_is_server_in_group(serv): if funct.check_is_server_in_group(serv):
servers = sql.select_servers(server=serv) servers = sql.select_servers(server=serv)
autorefresh = 1 autorefresh = 1
elif service == 'keepalived':
title = 'Keepalived servers overview'
servers = sql.get_dick_permit(virt=1, keepalived=1)
service = 'keepalived'
if serv:
if funct.check_is_server_in_group(serv):
servers = sql.select_servers(server=serv)
autorefresh = 1
else: else:
title = "HAProxy servers overview" title = "HAProxy servers overview"
service = 'haproxy' service = 'haproxy'
@ -69,7 +75,19 @@ for s in servers:
servers_with_status.append(s[11]) servers_with_status.append(s[11])
if service == 'nginx': if service == 'nginx':
cmd = [ cmd = [
"/usr/sbin/nginx -v && systemctl status nginx |grep -e 'Active' |awk '{print $2, $9$10$11$12$13}' && ps ax |grep nginx:|grep -v grep |wc -l"] "/usr/sbin/nginx -v 2>&1|awk '{print $3}' && systemctl status nginx |grep -e 'Active' |awk '{print $2, $9$10$11$12$13}' && ps ax |grep nginx:|grep -v grep |wc -l"]
out = funct.ssh_command(s[2], cmd)
h = ()
out1 = []
for k in out.split():
out1.append(k)
h = (out1,)
servers_with_status.append(h)
servers_with_status.append(h)
servers_with_status.append(s[17])
elif service == 'keepalived':
cmd = [
"/usr/sbin/keepalived -v 2>&1|head -1|awk '{print $2}' && systemctl status keepalived |grep -e 'Active' |awk '{print $2, $9$10$11$12$13}' && ps ax |grep keepalived|grep -v grep |wc -l"]
out = funct.ssh_command(s[2], cmd) out = funct.ssh_command(s[2], cmd)
h = () h = ()
out1 = [] out1 = []
@ -102,7 +120,6 @@ template = template.render(h2=1,
role=role, role=role,
user=user, user=user,
users=users, users=users,
groups=groups,
servers=servers_with_status1, servers=servers_with_status1,
keep_alive=''.join(keep_alive), keep_alive=''.join(keep_alive),
serv=serv, serv=serv,

View File

@ -516,26 +516,39 @@ if act == "overview":
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
async def async_get_overview(serv1, serv2): async def async_get_overview(serv1, serv2):
commands2 = ["ps ax |grep waf/bin/modsecurity |grep -v grep |wc -l"] haproxy = sql.select_haproxy(serv2)
cmd = 'echo "show info" |nc %s %s -w 1|grep -e "Process_num"' % (serv2, sql.get_setting('haproxy_sock_port'))
keepalived = sql.select_keealived(serv2) keepalived = sql.select_keealived(serv2)
nginx = sql.select_nginx(serv2)
waf = sql.select_waf_servers(serv2)
haproxy_process = ''
keepalived_process = ''
nginx_process = ''
waf_process = ''
if haproxy == 1:
cmd = 'echo "show info" |nc %s %s -w 1|grep -e "Process_num"' % (serv2, sql.get_setting('haproxy_sock_port'))
haproxy_process = funct.server_status(funct.subprocess_execute(cmd))
if keepalived == 1: if keepalived == 1:
command = ["ps ax |grep keepalived|grep -v grep|wc -l"] command = ["ps ax |grep keepalived|grep -v grep|wc -l"]
keepalived_process = funct.ssh_command(serv2, command) keepalived_process = funct.ssh_command(serv2, command)
else:
keepalived_process = ''
nginx = sql.select_nginx(serv2)
if nginx == 1: if nginx == 1:
command = ["ps ax |grep nginx:|grep -v grep|wc -l"] # command = ["ps ax |grep nginx:|grep -v grep|wc -l"]
nginx_process = funct.ssh_command(serv2, command) # nginx_process = funct.ssh_command(serv2, command)
else: nginx_cmd = 'echo "something" |nc %s %s -w 1' % (serv2, sql.get_setting('nginx_stats_port'))
nginx_process = '' nginx_process = funct.server_status(funct.subprocess_execute(nginx_cmd))
if len(waf) == 1:
commands2 = ["ps ax |grep waf/bin/modsecurity |grep -v grep |wc -l"]
waf_process = funct.ssh_command(serv2, commands2)
server_status = (serv1, server_status = (serv1,
serv2, serv2,
funct.server_status(funct.subprocess_execute(cmd)), haproxy_process,
sql.select_servers(server=serv2, keep_alive=1), sql.select_servers(server=serv2, keep_alive=1),
funct.ssh_command(serv2, commands2), waf_process,
sql.select_waf_servers(serv2), waf,
keepalived, keepalived,
keepalived_process, keepalived_process,
nginx, nginx,
@ -610,19 +623,19 @@ if act == "overviewServers":
if service == 'haproxy': if service == 'haproxy':
cmd = 'echo "show info" |nc %s %s -w 1|grep -e "node\|Nbproc\|Maxco\|MB\|Nbthread"' % (serv2, sql.get_setting('haproxy_sock_port')) cmd = 'echo "show info" |nc %s %s -w 1|grep -e "node\|Nbproc\|Maxco\|MB\|Nbthread"' % (serv2, sql.get_setting('haproxy_sock_port'))
out = funct.subprocess_execute(cmd) out = funct.subprocess_execute(cmd)
out1 = "" return_out = ""
for k in out: for k in out:
if "Ncat:" not in k: if "Ncat:" not in k:
for r in k: for r in k:
out1 += r return_out += r
out1 += "<br />" return_out += "<br />"
else: else:
out1 = "Cannot connect to HAProxy" return_out = "Cannot connect to HAProxy"
else: else:
out1 = '' return_out = ''
server_status = (serv1, serv2, out1) server_status = (serv1, serv2, return_out)
return server_status return server_status
@ -647,11 +660,11 @@ if act == "overviewServers":
print(template) print(template)
id = form.getvalue('id') server_id = form.getvalue('id')
name = form.getvalue('name') name = form.getvalue('name')
service = form.getvalue('service') service = form.getvalue('service')
ioloop = asyncio.get_event_loop() ioloop = asyncio.get_event_loop()
ioloop.run_until_complete(get_runner_overviewServers(server1=name, server2=serv, id=id, service=service)) ioloop.run_until_complete(get_runner_overviewServers(server1=name, server2=serv, id=server_id, service=service))
ioloop.close() ioloop.close()
if form.getvalue('action'): if form.getvalue('action'):
@ -995,6 +1008,9 @@ if form.getvalue('master'):
ETH = form.getvalue('interface') ETH = form.getvalue('interface')
IP = form.getvalue('vrrpip') IP = form.getvalue('vrrpip')
syn_flood = form.getvalue('syn_flood') syn_flood = form.getvalue('syn_flood')
virt_server = form.getvalue('virt_server')
haproxy = form.getvalue('hap')
nginx = form.getvalue('nginx')
script = "install_keepalived.sh" script = "install_keepalived.sh"
fullpath = funct.get_config_var('main', 'fullpath') fullpath = funct.get_config_var('main', 'fullpath')
proxy = sql.get_setting('proxy') proxy = sql.get_setting('proxy')
@ -1024,6 +1040,12 @@ if form.getvalue('master'):
sql.update_keepalived(master) sql.update_keepalived(master)
if virt_server is not None:
group_id = sql.get_group_id_by_server_ip(master)
cred_id = sql.get_cred_id_by_server_ip(master)
hostname = sql.get_hostname_by_server_ip(master)
sql.add_server(hostname+'-VIP', IP, group_id, '1', '1', '1', cred_id, ssh_port, 'VRRP IP for '+master, haproxy, nginx, '0')
if form.getvalue('master_slave'): if form.getvalue('master_slave'):
master = form.getvalue('master') master = form.getvalue('master')
slave = form.getvalue('slave') slave = form.getvalue('slave')
@ -1768,6 +1790,7 @@ if form.getvalue('newserver') is not None:
hostname = form.getvalue('servername') hostname = form.getvalue('servername')
ip = form.getvalue('newip') ip = form.getvalue('newip')
group = form.getvalue('newservergroup') group = form.getvalue('newservergroup')
scan_server = form.getvalue('scan_server')
typeip = form.getvalue('typeip') typeip = form.getvalue('typeip')
haproxy = form.getvalue('haproxy') haproxy = form.getvalue('haproxy')
nginx = form.getvalue('nginx') nginx = form.getvalue('nginx')
@ -1782,6 +1805,30 @@ if form.getvalue('newserver') is not None:
if sql.add_server(hostname, ip, group, typeip, enable, master, cred, port, desc, haproxy, nginx, firewall): if sql.add_server(hostname, ip, group, typeip, enable, master, cred, port, desc, haproxy, nginx, firewall):
try:
if scan_server == '1':
nginx_config_path = sql.get_setting('nginx_config_path')
haproxy_config_path = sql.get_setting('haproxy_config_path')
haproxy_dir = sql.get_setting('haproxy_dir')
keepalived_config_path = '/etc/keepalived/keepalived.conf'
if funct.is_file_exists(ip, nginx_config_path):
sql.update_nginx(ip)
if funct.is_file_exists(ip, haproxy_config_path):
sql.update_haproxy(ip)
if funct.is_file_exists(ip, keepalived_config_path):
sql.update_keepalived(ip)
if funct.is_file_exists(ip, haproxy_dir + '/waf/bin/modsecurity'):
sql.insert_waf_metrics_enable(ip, "0")
if funct.is_service_active(ip, 'firewalld'):
sql.update_firewall(ip)
except:
pass
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True) env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)

View File

@ -70,6 +70,57 @@
&emsp;&emsp;{{ line }} &emsp;&emsp;{{ line }}
</span><br /> </span><br />
{% endif %} {% endif %}
{% elif service == 'keepalived' %}
{%- if "global_defs {" in line -%}
{% if i > 1 %}
</div>
{% endif %}
<span class="param">{{ line }}
</span><div>
{% continue %}
{% endif %}
{%- if "vrrp_instance " in line -%}
{% if i > 1 %}
</div>
{% endif %}
<span class="param">{{ line }}
</span><div>
{% continue %}
{% endif %}
{%- if "vrrp_script " in line -%}
{% if i > 1 %}
</div>
{% endif %}
<span class="param">{{ line }}
</span><div>
{% continue %}
{% endif %}
{% if "state " in line or "interface" in line or "priority" in line or "}" in line %}
{% if "#" not in line %}
<span class="numRow">
{{ i }}
</span>
<span class="paramInSec">
&emsp;&emsp;{{ line }}
</span><br />
{% continue %}
{% endif %}
{% endif %}
{% if "#" in line %}
<span class="numRow">
{{ i }}
</span>
<span class="comment">
&emsp;&emsp;{{ line }}
</span><br />
{% continue %}
{% endif %}
{% if line|length > 1 %}
<span class="configLine">
<span class="numRow">{{ i }}</span>
&emsp;&emsp;{{ line }}
</span><br />
{% endif %}
{% else %} {% else %}
{% if line.startswith('global') %} {% if line.startswith('global') %}
<span class="param">{{ line }} <span class="param">{{ line }}
@ -231,7 +282,7 @@
</div> </div>
{% if configver %} {% if configver %}
<br> <br>
<center> <div style="text-align: center;">
{% if role <= 3 %} {% if role <= 3 %}
{% if not is_serv_protected or role <= 2 %} {% if not is_serv_protected or role <= 2 %}
<form action="versions.py?service={{service}}" method="post"> <form action="versions.py?service={{service}}" method="post">
@ -247,5 +298,5 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
<div class="alert alert-info"><b>Note:</b> If you reconfigure Master server, Slave will reconfigured automatically</div> <div class="alert alert-info"><b>Note:</b> If you reconfigure Master server, Slave will reconfigured automatically</div>
</center> </div>
{% endif %} {% endif %}

View File

@ -47,7 +47,7 @@
<div class="top-menu"> <div class="top-menu">
<div class="LogoText"> <div class="LogoText">
<span id="logo_text"> <span id="logo_text">
<a href="https://haproxy-wi.org" title="Roxy-WI site" target="_blank"> <a href="https://roxy-wi.org" title="Roxy-WI site" target="_blank">
<img src="/inc/images/logo_menu.png" alt="logo" width="170" /> <img src="/inc/images/logo_menu.png" alt="logo" width="170" />
</a> </a>
</span> </span>
@ -235,17 +235,17 @@
</div> </div>
<div id="version"></div> <div id="version"></div>
<div id="logo_footer"> <div id="logo_footer">
<a href="https://haproxy-wi.org" title="Roxy-WI official site" target="_blank"> <a href="https://roxy-wi.org" title="Roxy-WI official site" target="_blank">
<img src="/inc/images/logo_footer.png" alt="logo" id="logo_footer_img" /> <img src="/inc/images/logo_footer.png" alt="logo" id="logo_footer_img" />
</a> </a>
</div> </div>
<div class="footer-div"> <div class="footer-div">
<a href="https://haproxy-wi.org" class="footer-link" target="_blank" title="About Roxy-WI">About</a> <a href="https://roxy-wi.org" class="footer-link" target="_blank" title="About Roxy-WI">About</a>
<a href="https://github.com/hap-wi/haproxy-wi/issues" class="footer-link" target="_blank" title="Community help">Help</a> <a href="https://github.com/hap-wi/roxy-wi/issues" class="footer-link" target="_blank" title="Community help">Help</a>
<a href="https://sd.haproxy-wi.org" class="footer-link" target="_blank" title="Service Desk">SD</a> <a href="https://sd.roxy-wi.org" class="footer-link" target="_blank" title="Service Desk">SD</a>
<a href="https://haproxy-wi.org/contacts.py" class="footer-link" target="_blank">Contacts</a> <a href="https://roxy-wi.org/contacts.py" class="footer-link" target="_blank">Contacts</a>
<a href="https://haproxy-wi.org/cabinet.py" class="footer-link" target="_blank" title="Private cabinet">Cabinet</a> <a href="https://roxy-wi.org/cabinet.py" class="footer-link" target="_blank" title="Private cabinet">Cabinet</a>
<a href="https://haproxy-wi.org/legal.py" class="footer-link" target="_blank" title="Legal Note">Legal</a> <a href="https://roxy-wi.org/legal.py" class="footer-link" target="_blank" title="Legal Note">Legal</a>
</div> </div>
</div> </div>
<div id="show-user-settings"> <div id="show-user-settings">

View File

@ -22,24 +22,17 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</select> </select>
{% if service != 'keepalived' %}
<a class="ui-button ui-widget ui-corner-all" title="Show running config" onclick="showConfig()">Open</a> <a class="ui-button ui-widget ui-corner-all" title="Show running config" onclick="showConfig()">Open</a>
{% if service != 'keepalived' %}
<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 %} {% endif %}
{% if service != 'keepalived' and service != 'nginx'%} {% if service != 'keepalived' and service != 'nginx'%}
<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>
{% endif %} {% endif %}
{% if service != 'keepalived' %}
<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="Compare configs" onclick="showCompareConfigs()">Compare</a>
{% if role <= 3 %} {% if role <= 3 %}
<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 %}
{% else %}
{% if role <= 3 %}
<button type="submit" value="open" name="open" class="btn btn-default" title="Edit running config">Edit</button>
<a class="ui-button ui-widget ui-corner-all" title="Show versions" onclick="openVersions()">Versions</a>
{% endif %}
{% endif %}
</form> </form>
</p> </p>
{% endif %} {% endif %}
@ -70,9 +63,12 @@
{% if service != '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 %}
{% if service != 'keepalived' %}
<div class="alert alert-info alert-two-rows"><b>Note:</b> When reconfiguring the master server, the slave will be reconfigured automatically</div>
{% endif %}
</center>
</p> </p>
</form> </form>
<div class="alert alert-info alert-two-rows"><b>Note:</b> When reconfiguring the master server, the slave will be reconfigured automatically</div>
{% endif %} {% endif %}
{% endif %} {% endif %}
</center> </center>

View File

@ -30,7 +30,7 @@
var hostnamea = [] var hostnamea = []
{% for s in servers %} {% for s in servers %}
ip.push("{{s[2]}}") ip.push("{{s[2]}}")
var host = "{{s[1]}}" var host = "{{s[2]}}"
host = host.replace(/\./g, '\\.'); host = host.replace(/\./g, '\\.');
hostnamea.push(host) hostnamea.push(host)
{% endfor %} {% endfor %}
@ -90,7 +90,7 @@
showOverviewServer('{{s.1}}', server_ip, '{{s.0}}', '{{service}}'); showOverviewServer('{{s.1}}', server_ip, '{{s.0}}', '{{service}}');
{% if service == 'nginx' %} {% if service == 'nginx' %}
showNginxConnections(server_ip) showNginxConnections(server_ip)
{% else %} {% elif service == 'haproxy' %}
showBytes(server_ip) showBytes(server_ip)
{% endif %} {% endif %}
} }
@ -115,12 +115,18 @@
{% set checker_desc = 'Checker monitors Nginx services. If Nginx service is down, Checker will alert via Telegram' %} {% set checker_desc = 'Checker monitors Nginx services. If Nginx service is down, Checker will alert via Telegram' %}
{% set is_auto_start_enabled = s.8.0.17 %} {% set is_auto_start_enabled = s.8.0.17 %}
{% set is_checker_enabled = s.8.0.19 %} {% set is_checker_enabled = s.8.0.19 %}
{% if s.5.0.3 == 'active' %} {% if s.5.0.1 == 'active' %}
{% set additional_status_class = 'div-server-head-up' %} {% set additional_status_class = 'div-server-head-up' %}
{% else %} {% else %}
{% set additional_status_class = 'div-server-head-down' %} {% set additional_status_class = 'div-server-head-down' %}
{% endif %} {% endif %}
{% elif service == 'keepalived' %}
{% if s.5.0.1 == 'active' %}
{% set additional_status_class = 'div-server-head-up' %}
{% else %} {% else %}
{% set additional_status_class = 'div-server-head-down' %}
{% endif %}
{% elif service == 'haproxy' %}
{% set checker_desc = 'Checker monitors HAProxy services and its backends. If some backend or HAProxy service is down, Checker will alert via Telegram' %} {% set checker_desc = 'Checker monitors HAProxy services and its backends. If some backend or HAProxy service is down, Checker will alert via Telegram' %}
{% set is_auto_start_enabled = s.8.0.12 %} {% set is_auto_start_enabled = s.8.0.12 %}
{% set is_checker_enabled = s.8.0.8 %} {% set is_checker_enabled = s.8.0.8 %}
@ -134,8 +140,8 @@
<div class="server-name"> <div class="server-name">
<input type="hidden" id="server-name-{{s.0}}" value="{{s.1}}" /> <input type="hidden" id="server-name-{{s.0}}" value="{{s.1}}" />
<input type="hidden" id="service" value="{{service}}" /> <input type="hidden" id="service" value="{{service}}" />
{% if service == 'nginx' %} {% if service == 'nginx' or service == 'keepalived' %}
{% if s.5.0.3 == 'active' %} {% if s.5.0.1 == 'active' %}
<span class="serverUp server-status" title="Uptime: {{s.5.0.4}}"></span> <span class="serverUp server-status" title="Uptime: {{s.5.0.4}}"></span>
{% else %} {% else %}
<span class="serverDown server-status" title="Downtime: : {{s.5.0.4}}"></span> <span class="serverDown server-status" title="Downtime: : {{s.5.0.4}}"></span>
@ -152,7 +158,7 @@
{% else %} {% else %}
{{s.1}} {{s.1}}
{% endif %} {% endif %}
{% if s.6|int() >= 1 %} {% if s.6|int() >= 1 and service != 'keepalived' %}
<span <span
{% if keep_alive|int() >= 1 %} {% if keep_alive|int() >= 1 %}
class="shield green" title="Auto start enabled"> class="shield green" title="Auto start enabled">
@ -168,6 +174,8 @@
<span class="server-action"> <span class="server-action">
{% if service == 'nginx' %} {% if service == 'nginx' %}
{% set action_service = 'nginx' %} {% set action_service = 'nginx' %}
{% elif service == 'keepalived' %}
{% set action_service = 'keepalived' %}
{% else %} {% else %}
{% set action_service = 'hap' %} {% set action_service = 'hap' %}
{% endif %} {% endif %}
@ -189,10 +197,15 @@
<div class="server-desc"> <div class="server-desc">
{{s.3}} {{s.3}}
<br /> <br />
{% if service == 'nginx' %} {% if service == 'nginx' or service == 'keepalived' %}
Version: {{s.5.0.2}} Process_num: {{s.5.0.5}} {% if s.5.0.3 == 'active' %} Version: {{s.5.0.0}} Process_num: {{s.5.0.3}}
<br /> <br />
Uptime: {% else %} Downtime: {% endif %} {{s.5.0.4}} {% if s.5.0.1 == 'active' %}
Uptime:
{% else %}
Downtime:
{% endif %}
{{s.5.0.2}}
{% else %} {% else %}
{% if s.5.0 is defined %} {% if s.5.0 is defined %}
{{s.5.0.0}} {{s.5.0.1}} {{s.5.0.0}} {{s.5.0.1}}
@ -204,16 +217,16 @@
{% endif %} {% endif %}
<span title="Date of last configuration edit"> <span title="Date of last configuration edit">
Last edit: Last edit:
<span id="{{s.1}}"></span> <span id="edit_date_{{s.2}}"></span>
</span> </span>
<br /> <br />
IP: {{s.2}} IP: <b>{{s.2}}</b>
{% if s.7.0.0 != None %} {% if s.7.0.0 != None %}
Master for: {{ s.7.0.1 }} Master for: <b>{{ s.7.0.1 }}</b>
{% endif %} {% endif %}
</div> </div>
<div class="server-act-links" id="server-{{s.8.0.0|string()}}-{{service}}"> <div class="server-act-links" id="server-{{s.8.0.0|string()}}-{{service}}">
{% if role <= 2 %} {% if role <= 2 and service != 'keepalived' %}
{% set id = 'alert-' + s.8.0.0|string() %} {% set id = 'alert-' + s.8.0.0|string() %}
{% if is_checker_enabled == 1 %} {% if is_checker_enabled == 1 %}
{{ checkbox(id, title=checker_desc, value='1', desc='Checker', checked='checked') }} {{ checkbox(id, title=checker_desc, value='1', desc='Checker', checked='checked') }}
@ -237,15 +250,21 @@
{% endif %} {% endif %}
</div> </div>
<div class="server-act-links"> <div class="server-act-links">
<a href="/app/config.py?service={{service}}&serv={{s.2}}&showConfig" class="ui-button ui-widget ui-corner-all" title="Open running config">Open</a> {% if service != 'keepalived' %}
<a href="/app/config.py?service={{service}}&serv={{s.2}}&showConfig" class="ui-button ui-widget ui-corner-all" title="Open running config">Config</a>
{% else %}
<a href="/app/config.py?service={{service}}" class="ui-button ui-widget ui-corner-all" title="Edit running config">Config</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> <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' %} {% if service != 'nginx' and service != 'keepalived' %}
<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>
{% endif %} {% endif %}
<a href="/app/viewsttats.py?service={{service}}&serv={{s.2}}" class="ui-button ui-widget ui-corner-all" title="View stat">Stats</a> {% if service != 'keepalived' %}
<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> <a href="/app/viewsttats.py?service={{service}}&serv={{s.2}}" class="ui-button ui-widget ui-corner-all" title="View {{service}} statistics">Stat</a>
<a href="/app/logs.py?service={{service}}&serv={{s.2}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" class="ui-button ui-widget ui-corner-all" title="View {{service}} log">Log</a>
{% endif %}
{% if role <= 2 %} {% if role <= 2 %}
<a href="/app/versions.py?service={{service}}&serv={{s.2}}&open=open" class="ui-button ui-widget ui-corner-all">Versions</a> <a href="/app/versions.py?service={{service}}&serv={{s.2}}&open=open" class="ui-button ui-widget ui-corner-all" title="View/Rollback to previous config">Versions</a>
{% endif %} {% endif %}
</div> </div>
</div> </div>
@ -256,11 +275,13 @@
<div class="server-name backends"> <div class="server-name backends">
{% if service == 'haproxy' %} {% if service == 'haproxy' %}
Backends: Backends:
{% elif service == 'keepalived' %}
VRRP addresses:
{% else %} {% else %}
Virtual hosts: Virtual hosts:
{% endif %} {% endif %}
</div> </div>
<div style="margin-top: 10px;" id="top-{{s.1}}"></div> <div style="margin-top: 10px;" id="top-{{s.2}}"></div>
</div> </div>
{% endif %} {% endif %}
{% endfor %} {% endfor %}

View File

@ -27,19 +27,23 @@
<td>{{ checkbox('typeip') }}</td> <td>{{ checkbox('typeip') }}</td>
</tr> </tr>
<tr> <tr>
<td class="padding20 help_cursor" title="Scan the server for HAProxy, Nginx, Keepalived and Firewalld services">Scan the server</td>
<td>{{ checkbox('scan_server', checked='checked') }}</td>
</tr>
<tr class="services_for_scan" style="display: none">
<td class="padding20" title="Is there HAProxy?">HAProxy</td> <td class="padding20" title="Is there HAProxy?">HAProxy</td>
<td>{{ checkbox('haproxy') }} </td> <td>{{ checkbox('haproxy') }} </td>
</tr> </tr>
<tr> <tr class="services_for_scan" style="display: none">
<td class="padding20" title="Is there Nginx?">Nginx</td> <td class="padding20" title="Is there Nginx?">Nginx</td>
<td>{{ checkbox('nginx') }}</td> <td>{{ checkbox('nginx') }}</td>
</tr> </tr>
<tr> <tr class="services_for_scan" style="display: none">
<td class="padding20" title="Is there Firewall?">Firewall</td> <td class="padding20" title="Is there Firewall?">Firewall</td>
<td>{{ checkbox('firewall') }}</td> <td>{{ checkbox('firewall') }}</td>
</tr> </tr>
<tr> <tr>
<td class="padding20" title="Actions with master config will automatically apply on slave">Slave for</td> <td class="padding20 help_cursor" title="Actions with master config will automatically apply on slave">Slave for</td>
<td> <td>
<select id="slavefor"> <select id="slavefor">
<option value="0" selected>Not slave</option> <option value="0" selected>Not slave</option>

View File

@ -10,8 +10,9 @@
var hostnamea = [] var hostnamea = []
{% for s in servers %} {% for s in servers %}
ip.push("{{s[2]}}") ip.push("{{s[2]}}")
var host = "{{s[1]}}" var host = "{{s[2]}}"
host = host.replace(/\./g, '\\.'); host = host.replace(/\./g, '\\.');
host = host.replace(/ /g, '');
hostnamea.push(host) hostnamea.push(host)
{% endfor %} {% endfor %}
</script> </script>
@ -52,7 +53,7 @@
</td> </td>
</tr> </tr>
{% for s in servers %} {% for s in servers %}
<tr class="{{ loop.cycle('odd', 'even') }}" id="{{s[1]}}"></tr> <tr class="{{ loop.cycle('odd', 'even') }}" id="{{s[2]}}"></tr>
{% endfor %} {% endfor %}
</table> </table>
<table class="overview-wi"> <table class="overview-wi">
@ -95,7 +96,7 @@
{% endif %} {% endif %}
</td> </td>
</tr> </tr>
<tr> <tr class="odd">
<td class="padding10 first-collumn-wi"> <td class="padding10 first-collumn-wi">
{% if metrics_master == 'active' %} {% if metrics_master == 'active' %}
<span class="serverUp server-status" title="running {{ metrics_master }} master processes"></span> <span class="serverUp server-status" title="running {{ metrics_master }} master processes"></span>
@ -239,7 +240,7 @@
{% endif %} {% endif %}
</td> </td>
</tr> </tr>
<tr> <tr class="odd">
{% if role == 1 %} {% if role == 1 %}
<td class="padding10 first-collumn-wi"> <td class="padding10 first-collumn-wi">
{% if grafana|int() >= 1 %} {% if grafana|int() >= 1 %}

View File

@ -16,7 +16,7 @@ function showHapserversCallBack(serv, hostnamea, service) {
token: $('#token').val() token: $('#token').val()
}, },
beforeSend: function() { beforeSend: function() {
$("#"+hostnamea).html('<img class="loading_small_haproxyservers" src="/inc/images/loading.gif" />'); $("#edit_date_"+hostnamea).html('<img class="loading_small_haproxyservers" src="/inc/images/loading.gif" />');
}, },
type: "POST", type: "POST",
success: function( data ) { success: function( data ) {
@ -24,11 +24,11 @@ function showHapserversCallBack(serv, hostnamea, service) {
toastr.error(data); toastr.error(data);
} else { } else {
if (data.indexOf('ls: cannot access') != '-1') { if (data.indexOf('ls: cannot access') != '-1') {
$("#" + hostnamea).empty(); $("#edit_date_" + hostnamea).empty();
$("#" + hostnamea).html(); $("#edit_date_" + hostnamea).html();
} else { } else {
$("#" + hostnamea).empty(); $("#edit_date_" + hostnamea).empty();
$("#" + hostnamea).html(data); $("#edit_date_" + hostnamea).html(data);
} }
} }
} }
@ -86,7 +86,7 @@ function showOverviewCallBack(serv, hostnamea) {
} }
} ); } );
} }
function showOverviewServer(name,ip,id, service) { function showOverviewServer(name, ip, id, service) {
$.ajax( { $.ajax( {
url: "options.py", url: "options.py",
data: { data: {
@ -175,6 +175,32 @@ function ajaxActionNginxServers(action, id) {
} }
} ); } );
} }
function ajaxActionKeepalivedServers(action, id) {
var bad_ans = 'Bad config, check please';
$.ajax( {
url: "options.py",
data: {
action_keepalived: 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( {
@ -295,6 +321,8 @@ function confirmAjaxAction(action, service, id) {
ajaxActionWafServers(action, id) ajaxActionWafServers(action, id)
} else if (service == "nginx") { } else if (service == "nginx") {
ajaxActionNginxServers(action, id) ajaxActionNginxServers(action, id)
} else if (service == "keepalived") {
ajaxActionKeepalivedServers(action, id)
} }
}, },
Cancel: function() { Cancel: function() {