mirror of https://github.com/Aidaho12/haproxy-wi
parent
b7476c7d55
commit
28b85c0bac
|
@ -638,7 +638,7 @@ def update_db_v_5_4_3_1(**kwargs):
|
|||
|
||||
|
||||
def update_ver():
|
||||
query = Version.update(version='5.5.0.0')
|
||||
query = Version.update(version='5.5.1.0')
|
||||
try:
|
||||
query.execute()
|
||||
except:
|
||||
|
|
|
@ -829,6 +829,7 @@ def install_nginx(server_ip, **kwargs):
|
|||
def update_haproxy_wi(service):
|
||||
import distro
|
||||
restart_service = ''
|
||||
|
||||
if distro.id() == 'ubuntu':
|
||||
try:
|
||||
if service == 'roxy-wi-keep_alive':
|
||||
|
@ -836,11 +837,13 @@ def update_haproxy_wi(service):
|
|||
except Exception:
|
||||
pass
|
||||
|
||||
if service == 'roxy-wi':
|
||||
if service != 'roxy-wi':
|
||||
restart_service = ' && sudo systemctl restart ' + service
|
||||
|
||||
cmd = 'sudo -S apt-get update && sudo apt-get install ' + service + restart_service
|
||||
else:
|
||||
if service != 'roxy-wi':
|
||||
restart_service = ' && sudo systemctl restart ' + service
|
||||
cmd = 'sudo -S yum -y update ' + service + restart_service
|
||||
|
||||
output, stderr = subprocess_execute(cmd)
|
||||
|
|
|
@ -18,6 +18,7 @@ except:
|
|||
form = funct.form
|
||||
serv = funct.is_ip_or_dns(form.getvalue('serv'))
|
||||
service = form.getvalue('service')
|
||||
user_id = form.getvalue('user_id')
|
||||
|
||||
|
||||
if service == 'nginx':
|
||||
|
@ -41,6 +42,16 @@ elif service == 'haproxy':
|
|||
if funct.check_is_server_in_group(serv):
|
||||
server_id = sql.select_server_id_by_ip(serv)
|
||||
history = sql.select_action_history_by_server_id_and_service(server_id, service)
|
||||
elif service == 'server':
|
||||
if serv:
|
||||
title = serv + ' history'
|
||||
if funct.check_is_server_in_group(serv):
|
||||
server_id = sql.select_server_id_by_ip(serv)
|
||||
history = sql.select_action_history_by_server_id(server_id)
|
||||
elif service == 'user':
|
||||
if user_id:
|
||||
title = 'User history'
|
||||
history = sql.select_action_history_by_user_id(user_id)
|
||||
|
||||
users = sql.select_users()
|
||||
|
||||
|
|
|
@ -495,9 +495,7 @@ if act == "overviewHapserverBackends":
|
|||
except Exception as e:
|
||||
funct.logging('localhost', ' Cannot generate a cfg path ' + str(e), haproxywi=1)
|
||||
try:
|
||||
if service == 'nginx':
|
||||
error = funct.get_config(serv, cfg, nginx=1)
|
||||
elif service == 'keepalived':
|
||||
if service == 'keepalived':
|
||||
error = funct.get_config(serv, cfg, keepalived=1)
|
||||
else:
|
||||
error = funct.get_config(serv, cfg)
|
||||
|
@ -556,7 +554,7 @@ if act == "overview":
|
|||
import http.cookies
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
async def async_get_overview(serv1, serv2, user_uuid):
|
||||
async def async_get_overview(serv1, serv2, user_uuid, server_id):
|
||||
user_id = sql.get_user_id_by_uuid(user_uuid)
|
||||
user_services = sql.select_user_services(user_id)
|
||||
if '1' in user_services:
|
||||
|
@ -587,7 +585,7 @@ if act == "overview":
|
|||
haproxy_process = funct.server_status(funct.subprocess_execute(cmd))
|
||||
|
||||
if keepalived == 1:
|
||||
command = ["ps ax |grep keepalived|grep -v grep|wc -l"]
|
||||
command = ["ps ax |grep keepalived|grep -v grep|wc -l|tr -d '\n'"]
|
||||
keepalived_process = funct.ssh_command(serv2, command)
|
||||
|
||||
if nginx == 1:
|
||||
|
@ -607,7 +605,8 @@ if act == "overview":
|
|||
keepalived,
|
||||
keepalived_process,
|
||||
nginx,
|
||||
nginx_process)
|
||||
nginx_process,
|
||||
server_id)
|
||||
return server_status
|
||||
|
||||
|
||||
|
@ -619,7 +618,7 @@ if act == "overview":
|
|||
template = env.get_template('overview.html')
|
||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
user_uuid = cookie.get('uuid')
|
||||
futures = [async_get_overview(server[1], server[2], user_uuid.value) for server in sql.select_servers(server=serv)]
|
||||
futures = [async_get_overview(server[1], server[2], user_uuid.value, server[0]) for server in sql.select_servers(server=serv)]
|
||||
for i, future in enumerate(asyncio.as_completed(futures)):
|
||||
result = await future
|
||||
servers.append(result)
|
||||
|
@ -3953,6 +3952,8 @@ if act == 'showListOfVersion':
|
|||
configver = form.getvalue('configver')
|
||||
for_delver = form.getvalue('for_delver')
|
||||
style = form.getvalue('style')
|
||||
users = sql.select_users()
|
||||
|
||||
if service == 'keepalived':
|
||||
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
||||
files = funct.get_files(dir=configs_dir, format='conf')
|
||||
|
@ -3982,6 +3983,7 @@ if act == 'showListOfVersion':
|
|||
configver=configver,
|
||||
for_delver=for_delver,
|
||||
configs=configs,
|
||||
users=users,
|
||||
style=style)
|
||||
print(template)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
template:
|
||||
src: /var/www/haproxy-wi/app/scripts/ansible/roles/haproxy/templates/haproxy_rsyslog.conf.j2
|
||||
dest: /etc/rsyslog.d/49-haproxy.conf
|
||||
force: no
|
||||
force: yes
|
||||
ignore_errors: yes
|
||||
notify: restart rsyslog
|
||||
|
||||
|
|
|
@ -30,7 +30,11 @@ defaults
|
|||
maxconn 3000
|
||||
|
||||
listen stats
|
||||
bind *:{{STAT_PORT}}
|
||||
bind *:{{STAT_PORT}}
|
||||
{% if ansible_os_family == "RedHat" and HAPVER != '2.5.1-1' %}
|
||||
option http-use-htx
|
||||
http-request use-service prometheus-exporter if { path /metrics }
|
||||
{% endif %}
|
||||
stats enable
|
||||
stats uri /stats
|
||||
stats realm HAProxy-04\ Statistics
|
||||
|
|
|
@ -144,7 +144,6 @@
|
|||
</div>
|
||||
</div>
|
||||
{% include 'include/admins_dialogs.html' %}
|
||||
{% include 'include/change_pass_form.html' %}
|
||||
<div id="change-user-groups-dialog" style="display: none;">
|
||||
<div id="change-user-groups-form"></div>
|
||||
</div>
|
||||
|
|
|
@ -1,37 +1,39 @@
|
|||
{% for service in service_status %}
|
||||
<td class="padding10 first-collumn">
|
||||
<a href="/app/hapservers.py?serv={{ service.1 }}" title="{{service.0 }}'s overview" class="logs_link">
|
||||
{% for service in service_status %}
|
||||
<td class="padding10 first-collumn">
|
||||
<a href="/app/history.py?service=server&serv={{ service.1 }}" title="{{service.0 }} history" class="logs_link">
|
||||
{{ service.0 }}
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
{% if service.2|int() == 0 %}
|
||||
<span class="serverNone server-status" title="HAProxy is not installed" style="margin-left: 25px !important;"></span>
|
||||
<span class="serverNone server-status" title="HAProxy is not installed"
|
||||
{% else %}
|
||||
{% if service.3|int() >= 1 %}
|
||||
<span class="serverUp server-status" title="running {{ service.3 }} processes" style="margin-left: 25px !important;"></span>
|
||||
<span class="serverUp server-status" title="running {{ service.3 }} processes"
|
||||
{% else %}
|
||||
<span class="serverDown server-status" title="HAProxy is down" style="margin-left: 25px !important;"></span>
|
||||
<span class="serverDown server-status" title="HAProxy is down"
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
style="margin-left: 25px !important;" id="haproxy_{{service.10}}"></span>
|
||||
</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>
|
||||
<span class="serverNone server-status" title="Nginx is not installed"
|
||||
{% else %}
|
||||
{% if service.9|int() >= 1 %}
|
||||
<span class="serverUp server-status" title="Nginx is running" style="margin-left: 4px !important;"></span>
|
||||
<span class="serverUp server-status" title="Nginx is running"
|
||||
{% else %}
|
||||
<span class="serverDown server-status" title="Nginx is down" style="margin-left: 4px !important;"></span>
|
||||
<span class="serverDown server-status" title="Nginx is down"
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
style="margin-left: 4px !important;" id="nginx_{{service.10}}"></span>
|
||||
</td>
|
||||
<td class="padding10 first-collumn">
|
||||
{% if service.6|int() == 0 %}
|
||||
<span class="serverNone server-status" title="Keepalived is not installed" style="margin-left: 4px !important;"></span>
|
||||
<span class="serverNone server-status" title="Keepalived is not installed" style="margin-left: 4px !important;"></span>
|
||||
{% else %}
|
||||
{% if service.7|int() >= 1 %}
|
||||
<span class="serverUp server-status" title="running {{service.7 }} processes" style="margin-left: 4px !important;"></span>
|
||||
<span class="serverUp server-status" title="running {{service.7 }} processes" style="margin-left: 4px !important;"></span>
|
||||
{% else %}
|
||||
<span class="serverDown server-status" title="Keepalived is down" style="margin-left: 4px !important;"></span>
|
||||
{% endif %}
|
||||
|
@ -39,12 +41,12 @@
|
|||
</td>
|
||||
<td class="third-collumn-wi">
|
||||
{% if service.5.0|length() == 0 %}
|
||||
<span class="serverNone server-status" title="WAF is not installed" style="margin-left: 4px !important;"></span>
|
||||
<span class="serverNone server-status" title="WAF is not installed" style="margin-left: 4px !important;"></span>
|
||||
{% elif service.5.0 != '' and service.4|int() == 0 %}
|
||||
<span class="serverDown server-status" title="WAF is down" style="margin-left: 4px !important;"></span>
|
||||
{% elif service.5.0 != '' and service.4|int() >= 1 %}
|
||||
<span class="serverUp server-status" title="running {{ service.4 }} processes" style="margin-left: 4px !important;"></span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
{% endfor %}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
$('#table_version').on('page.dt')
|
||||
.DataTable( {
|
||||
"pageLength": 25,
|
||||
"order": [ 4, "desc" ],
|
||||
"order": [ 6, "desc" ],
|
||||
stateSave: true,
|
||||
"columnDefs": [
|
||||
{
|
||||
|
@ -55,6 +55,7 @@
|
|||
<label for="new_select_all" id="new_label_select_all"></label>
|
||||
<input type="checkbox" id="new_select_all">
|
||||
</th>
|
||||
<th>User</th>
|
||||
<th class="padding10 first-collumn" style="width: 30%">
|
||||
Local path
|
||||
</th>
|
||||
|
@ -77,6 +78,13 @@
|
|||
<label for="{{c.id}}" id="select_{{c.id}}"></label>
|
||||
<input type="checkbox" value="{{c.local_path}}" name="{{c.local_path}}" id="{{c.id}}">
|
||||
</td>
|
||||
<td>
|
||||
{% for u in users %}
|
||||
{% if u.user_id == c.user_id %}
|
||||
{{ u.username }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td class="padding10 first-collumn" title="{{c.local_path}}">
|
||||
{% set show = '...'+c.local_path.split('/')[-1] %}
|
||||
{{ copy_to_clipboard(id=c.local_path, value=c.local_path, show=show) }}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
<th style="min-width: 17px;"></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -151,6 +152,9 @@
|
|||
{{ input(id, size='20') }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<a href="history.py?service=server&serv={{server.2}}" title="View history for this server" class="history"></a>
|
||||
</td>
|
||||
<td style="min-width: 17px;">
|
||||
<a class="info" onclick="showServerInfo('{{server.0}}', '{{server.2}}')" id="server_info_link-{{server.0}}" title="Show server info" style="cursor: pointer; color: var(--green-color)"></a>
|
||||
</td>
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
<th style="width: 100%">Services</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -78,7 +79,10 @@
|
|||
</td>
|
||||
{% endif %}
|
||||
<td>
|
||||
<span title="Change user groups" style="cursor: pointer; margin-left: 15px;" class="div-pic" onclick="openChangeUserServiceDialog('{{user.user_id}}')">
|
||||
<span title="Change user's services" style="cursor: pointer; margin-left: 15px;" class="div-pic" onclick="openChangeUserServiceDialog('{{user.user_id}}')">
|
||||
</td>
|
||||
<td>
|
||||
<a href="history.py?service=user&user_id={{user.user_id}}" title="View history for this user" class="history"></a>
|
||||
</td>
|
||||
<td>
|
||||
<a class="add" onclick="cloneUser({{user.user_id}})" id="clone-{{user.user_id}}" title="Clone {{user.1}}" style="cursor: pointer;"></a>
|
||||
|
|
Loading…
Reference in New Issue