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