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

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python3
import funct
import sql
from jinja2 import Environment, FileSystemLoader
@ -13,7 +12,6 @@ funct.check_login()
try:
user, user_id, role, token, servers = funct.get_users_params()
users = sql.select_users()
groups = sql.select_groups()
services = []
except:
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)
if service == 'nginx':
title = "Nginx servers overview"
title = 'Nginx servers overview'
servers = sql.get_dick_permit(virt=1, nginx=1)
service = 'nginx'
if serv:
if funct.check_is_server_in_group(serv):
servers = sql.select_servers(server=serv)
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:
title = "HAProxy servers overview"
service = 'haproxy'
@ -69,7 +75,19 @@ for s in servers:
servers_with_status.append(s[11])
if service == 'nginx':
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)
h = ()
out1 = []
@ -102,7 +120,6 @@ template = template.render(h2=1,
role=role,
user=user,
users=users,
groups=groups,
servers=servers_with_status1,
keep_alive=''.join(keep_alive),
serv=serv,

View File

@ -516,26 +516,39 @@ if act == "overview":
from jinja2 import Environment, FileSystemLoader
async def async_get_overview(serv1, serv2):
commands2 = ["ps ax |grep waf/bin/modsecurity |grep -v grep |wc -l"]
cmd = 'echo "show info" |nc %s %s -w 1|grep -e "Process_num"' % (serv2, sql.get_setting('haproxy_sock_port'))
haproxy = sql.select_haproxy(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:
command = ["ps ax |grep keepalived|grep -v grep|wc -l"]
keepalived_process = funct.ssh_command(serv2, command)
else:
keepalived_process = ''
nginx = sql.select_nginx(serv2)
if nginx == 1:
command = ["ps ax |grep nginx:|grep -v grep|wc -l"]
nginx_process = funct.ssh_command(serv2, command)
else:
nginx_process = ''
# command = ["ps ax |grep nginx:|grep -v grep|wc -l"]
# nginx_process = funct.ssh_command(serv2, command)
nginx_cmd = 'echo "something" |nc %s %s -w 1' % (serv2, sql.get_setting('nginx_stats_port'))
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,
serv2,
funct.server_status(funct.subprocess_execute(cmd)),
haproxy_process,
sql.select_servers(server=serv2, keep_alive=1),
funct.ssh_command(serv2, commands2),
sql.select_waf_servers(serv2),
waf_process,
waf,
keepalived,
keepalived_process,
nginx,
@ -610,19 +623,19 @@ if act == "overviewServers":
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'))
out = funct.subprocess_execute(cmd)
out1 = ""
return_out = ""
for k in out:
if "Ncat:" not in k:
for r in k:
out1 += r
out1 += "<br />"
return_out += r
return_out += "<br />"
else:
out1 = "Cannot connect to HAProxy"
return_out = "Cannot connect to HAProxy"
else:
out1 = ''
return_out = ''
server_status = (serv1, serv2, out1)
server_status = (serv1, serv2, return_out)
return server_status
@ -647,11 +660,11 @@ if act == "overviewServers":
print(template)
id = form.getvalue('id')
server_id = form.getvalue('id')
name = form.getvalue('name')
service = form.getvalue('service')
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()
if form.getvalue('action'):
@ -995,6 +1008,9 @@ if form.getvalue('master'):
ETH = form.getvalue('interface')
IP = form.getvalue('vrrpip')
syn_flood = form.getvalue('syn_flood')
virt_server = form.getvalue('virt_server')
haproxy = form.getvalue('hap')
nginx = form.getvalue('nginx')
script = "install_keepalived.sh"
fullpath = funct.get_config_var('main', 'fullpath')
proxy = sql.get_setting('proxy')
@ -1024,6 +1040,12 @@ if form.getvalue('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'):
master = form.getvalue('master')
slave = form.getvalue('slave')
@ -1768,6 +1790,7 @@ if form.getvalue('newserver') is not None:
hostname = form.getvalue('servername')
ip = form.getvalue('newip')
group = form.getvalue('newservergroup')
scan_server = form.getvalue('scan_server')
typeip = form.getvalue('typeip')
haproxy = form.getvalue('haproxy')
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):
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
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)

View File

@ -70,6 +70,57 @@
&emsp;&emsp;{{ line }}
</span><br />
{% 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 %}
{% if line.startswith('global') %}
<span class="param">{{ line }}
@ -231,7 +282,7 @@
</div>
{% if configver %}
<br>
<center>
<div style="text-align: center;">
{% if role <= 3 %}
{% if not is_serv_protected or role <= 2 %}
<form action="versions.py?service={{service}}" method="post">
@ -247,5 +298,5 @@
{% endif %}
{% endif %}
<div class="alert alert-info"><b>Note:</b> If you reconfigure Master server, Slave will reconfigured automatically</div>
</center>
</div>
{% endif %}

View File

@ -47,7 +47,7 @@
<div class="top-menu">
<div class="LogoText">
<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" />
</a>
</span>
@ -235,17 +235,17 @@
</div>
<div id="version"></div>
<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" />
</a>
</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://github.com/hap-wi/haproxy-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://haproxy-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://haproxy-wi.org/legal.py" class="footer-link" target="_blank" title="Legal Note">Legal</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/roxy-wi/issues" class="footer-link" target="_blank" title="Community help">Help</a>
<a href="https://sd.roxy-wi.org" class="footer-link" target="_blank" title="Service Desk">SD</a>
<a href="https://roxy-wi.org/contacts.py" class="footer-link" target="_blank">Contacts</a>
<a href="https://roxy-wi.org/cabinet.py" class="footer-link" target="_blank" title="Private cabinet">Cabinet</a>
<a href="https://roxy-wi.org/legal.py" class="footer-link" target="_blank" title="Legal Note">Legal</a>
</div>
</div>
<div id="show-user-settings">

View File

@ -22,23 +22,16 @@
{% endif %}
{% endfor %}
</select>
{% if service != 'keepalived' %}
<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>
{% endif %}
{% if service != 'keepalived' and service != 'nginx'%}
<a class="ui-button ui-widget ui-corner-all" title="Show map" onclick="showMap()">Map</a>
{% endif %}
{% if service != 'keepalived' %}
<a class="ui-button ui-widget ui-corner-all" title="Compare configs" onclick="showCompareConfigs()">Compare</a>
{% if role <= 3 %}
<a class="ui-button ui-widget ui-corner-all" title="Show versions" onclick="openVersions()">Versions</a>
{% 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 %}
<a class="ui-button ui-widget ui-corner-all" title="Compare configs" onclick="showCompareConfigs()">Compare</a>
{% if role <= 3 %}
<a class="ui-button ui-widget ui-corner-all" title="Show versions" onclick="openVersions()">Versions</a>
{% endif %}
</form>
</p>
@ -61,18 +54,21 @@
<textarea name="config" id="config_text_area" class="config" rows="35" cols="100">{{ config }}</textarea>
</div>
<p>
<center>
{% if service == 'haproxy' %}
<button type="submit" value="test" name="save" class="btn btn-default">Just test</button>
{% endif %}
<button type="submit" value="save" name="save" class="btn btn-default">Just save</button>
<button type="submit" value="" name="" class="btn btn-default">Save and restart</button>
{% if service != 'keepalived' %}
<button type="submit" value="reload" name="save" class="btn btn-default">Save and reload</button>
{% endif %}
<center>
{% if service == 'haproxy' %}
<button type="submit" value="test" name="save" class="btn btn-default">Just test</button>
{% endif %}
<button type="submit" value="save" name="save" class="btn btn-default">Just save</button>
<button type="submit" value="" name="" class="btn btn-default">Save and restart</button>
{% if service != 'keepalived' %}
<button type="submit" value="reload" name="save" class="btn btn-default">Save and reload</button>
{% 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>
</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 %}
</center>

View File

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

View File

@ -27,19 +27,23 @@
<td>{{ checkbox('typeip') }}</td>
</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>{{ checkbox('haproxy') }} </td>
</tr>
<tr>
<tr class="services_for_scan" style="display: none">
<td class="padding20" title="Is there Nginx?">Nginx</td>
<td>{{ checkbox('nginx') }}</td>
</tr>
<tr>
<tr class="services_for_scan" style="display: none">
<td class="padding20" title="Is there Firewall?">Firewall</td>
<td>{{ checkbox('firewall') }}</td>
</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>
<select id="slavefor">
<option value="0" selected>Not slave</option>

View File

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

View File

@ -16,7 +16,7 @@ function showHapserversCallBack(serv, hostnamea, service) {
token: $('#token').val()
},
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",
success: function( data ) {
@ -24,11 +24,11 @@ function showHapserversCallBack(serv, hostnamea, service) {
toastr.error(data);
} else {
if (data.indexOf('ls: cannot access') != '-1') {
$("#" + hostnamea).empty();
$("#" + hostnamea).html();
$("#edit_date_" + hostnamea).empty();
$("#edit_date_" + hostnamea).html();
} else {
$("#" + hostnamea).empty();
$("#" + hostnamea).html(data);
$("#edit_date_" + hostnamea).empty();
$("#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( {
url: "options.py",
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) {
var bad_ans = 'Bad config, check please';
$.ajax( {
@ -295,6 +321,8 @@ function confirmAjaxAction(action, service, id) {
ajaxActionWafServers(action, id)
} else if (service == "nginx") {
ajaxActionNginxServers(action, id)
} else if (service == "keepalived") {
ajaxActionKeepalivedServers(action, id)
}
},
Cancel: function() {