Changelog: https://roxy-wi.org/changelog.py#6
pull/321/head
Pavel Loginov 2022-04-29 13:28:48 +03:00
parent 7e3ee72cf0
commit 1f49943fae
17 changed files with 172 additions and 98 deletions

View File

@ -163,7 +163,7 @@ def default_values():
print(str(e))
try:
Groups.insert(name='All', description='All servers are included in this group by default').on_conflict_ignore().execute()
Groups.insert(name='Default', description='All servers are included in this group by default', group_id=1).on_conflict_ignore().execute()
except Exception as e:
print(str(e))
@ -179,11 +179,6 @@ def default_values():
except Exception as e:
print(str(e))
try:
Groups.insert(name='All', description='All servers are included in this group by default').on_conflict_ignore().execute()
except Exception as e:
print(str(e))
data_source = [
{'code': 'RW', 'name': 'Rwanda'},
{'code': 'SO', 'name': 'Somalia'},
@ -687,6 +682,17 @@ def update_db_v_6_0(**kwargs):
print('Updating... DB has been updated to version 6.0.0.0')
def update_db_v_6_0_1(**kwargs):
query = Groups.update(name='Default').where(Groups.group_id == '1')
try:
query.execute()
except Exception as e:
print("An error occurred:", e)
else:
if kwargs.get('silent') != 1:
print("Updating... DB has been updated to version 6.0.0.0-1")
def update_ver():
query = Version.update(version='6.0.0.0')
try:
@ -713,6 +719,7 @@ def update_all():
update_db_v_5_4_3()
update_db_v_5_4_3_1()
update_db_v_6_0()
update_db_v_6_0_1()
update_ver()
@ -734,6 +741,7 @@ def update_all_silent():
update_db_v_5_4_3(silent=1)
update_db_v_5_4_3_1(silent=1)
update_db_v_6_0(silent=1)
update_db_v_6_0_1(silent=1)
update_ver()

View File

@ -716,7 +716,7 @@ def install_haproxy(server_ip, **kwargs):
os.system("cp scripts/%s ." % script)
if haproxy_ver is None:
haproxy_ver = '2.4.9-1'
haproxy_ver = '2.5.1-1'
if proxy is not None and proxy != '' and proxy != 'None':
proxy_serv = proxy
@ -1473,7 +1473,7 @@ def get_remote_files(server_ip: str, config_dir: str, file_format: str):
if file_format == 'conf':
commands = ['sudo ls ' + config_dir + '*/*.' + file_format]
else:
commands = ['sudo ls ' + config_dir + '/*.' + file_format]
commands = ['sudo ls ' + config_dir + '|grep ' + file_format + '$']
config_files = ssh_command(server_ip, commands)
return config_files

View File

@ -22,7 +22,7 @@ try:
services = '0'
if not stderr:
if service_ver[0] == '* is not installed' or service_ver == '':
if service_ver[0] == ' is not installed' or service_ver == '':
servers = ''
else:
if service == 'nginx':
@ -37,6 +37,12 @@ try:
except Exception as e:
pass
try:
user_status, user_plan = funct.return_user_status()
except Exception as e:
user_status, user_plan = 0, 0
funct.logging('localhost', 'Cannot get a user plan: ' + str(e), haproxywi=1)
template = template.render(h2=1, title=title,
autorefresh=1,
@ -46,5 +52,7 @@ template = template.render(h2=1, title=title,
services=services,
user_services=user_services,
service=service,
user_status=user_status,
user_plan=user_plan,
token=token)
print(template)

View File

@ -1748,6 +1748,7 @@ if form.getvalue('metrics_hapwi_cpu'):
if form.getvalue('new_metrics'):
serv = form.getvalue('server')
hostname = sql.get_hostname_by_server_ip(serv)
time_range = form.getvalue('time_range')
metric = sql.select_metrics(serv, time_range=time_range)
metrics = {'chartData': {}}
@ -1771,7 +1772,7 @@ if form.getvalue('new_metrics'):
metrics['chartData']['curr_con'] = curr_con
metrics['chartData']['curr_ssl_con'] = curr_ssl_con
metrics['chartData']['sess_rate'] = sess_rate
metrics['chartData']['server'] = server
metrics['chartData']['server'] = hostname + ' (' + server + ')'
import json
@ -1779,6 +1780,7 @@ if form.getvalue('new_metrics'):
if form.getvalue('new_http_metrics'):
serv = form.getvalue('server')
hostname = sql.get_hostname_by_server_ip(serv)
time_range = form.getvalue('time_range')
metric = sql.select_metrics_http(serv, time_range=time_range)
metrics = {'chartData': {}}
@ -1805,7 +1807,7 @@ if form.getvalue('new_http_metrics'):
metrics['chartData']['http_3xx'] = http_3xx
metrics['chartData']['http_4xx'] = http_4xx
metrics['chartData']['http_5xx'] = http_5xx
metrics['chartData']['server'] = server
metrics['chartData']['server'] = hostname + ' (' + server + ')'
import json
@ -1813,6 +1815,7 @@ if form.getvalue('new_http_metrics'):
if form.getvalue('new_waf_metrics'):
serv = form.getvalue('server')
hostname = sql.get_hostname_by_server_ip(serv)
time_range = form.getvalue('time_range')
metric = sql.select_waf_metrics(serv, time_range=time_range)
metrics = {'chartData': {}}
@ -1828,7 +1831,7 @@ if form.getvalue('new_waf_metrics'):
metrics['chartData']['labels'] = labels
metrics['chartData']['curr_con'] = curr_con
metrics['chartData']['server'] = serv
metrics['chartData']['server'] = hostname + ' (' + serv + ')'
import json
@ -1836,6 +1839,7 @@ if form.getvalue('new_waf_metrics'):
if form.getvalue('new_nginx_metrics'):
serv = form.getvalue('server')
hostname = sql.get_hostname_by_server_ip(serv)
time_range = form.getvalue('time_range')
metric = sql.select_nginx_metrics(serv, time_range=time_range)
metrics = {'chartData': {}}
@ -1851,7 +1855,7 @@ if form.getvalue('new_nginx_metrics'):
metrics['chartData']['labels'] = labels
metrics['chartData']['curr_con'] = curr_con
metrics['chartData']['server'] = serv
metrics['chartData']['server'] = hostname + ' (' + serv + ')'
import json
@ -3774,18 +3778,29 @@ if form.getvalue('loadchecker'):
services = funct.get_services_status()
groups = sql.select_groups()
page = form.getvalue('page')
if page == 'servers.py':
user_group = funct.get_user_group(id=1)
telegrams = sql.get_user_telegram_by_group(user_group)
slacks = sql.get_user_slack_by_group(user_group)
try:
user_status, user_plan = funct.return_user_status()
except Exception as e:
user_status, user_plan = 0, 0
funct.logging('localhost', 'Cannot get a user plan: ' + str(e), haproxywi=1)
if user_status:
if page == 'servers.py':
user_group = funct.get_user_group(id=1)
telegrams = sql.get_user_telegram_by_group(user_group)
slacks = sql.get_user_slack_by_group(user_group)
else:
telegrams = sql.select_telegram()
slacks = sql.select_slack()
else:
telegrams = sql.select_telegram()
slacks = sql.select_slack()
telegrams = ''
slacks = ''
template = template.render(services=services,
telegrams=telegrams,
groups=groups,
slacks=slacks,
user_status=user_status,
user_plan=user_plan,
page=page)
print(template)

View File

@ -41,6 +41,12 @@ else:
cmd = "systemctl is-active roxy-wi-portscanner"
port_scanner, port_scanner_stderr = funct.subprocess_execute(cmd)
try:
user_status, user_plan = funct.return_user_status()
except Exception as e:
user_status, user_plan = 0, 0
funct.logging('localhost', 'Cannot get a user plan: ' + str(e), haproxywi=1)
output_from_parsed_template = template.render(h2=1, autorefresh=0,
title=title,
@ -53,5 +59,7 @@ output_from_parsed_template = template.render(h2=1, autorefresh=0,
port_scanner=''.join(port_scanner),
port_scanner_stderr=port_scanner_stderr,
user_services=user_services,
user_status=user_status,
user_plan=user_plan,
token=token)
print(output_from_parsed_template)

View File

@ -42,6 +42,11 @@ else:
title = "SMON Dashboard"
autorefresh = 1
try:
user_status, user_plan = funct.return_user_status()
except Exception as e:
user_status, user_plan = 0, 0
funct.logging('localhost', 'Cannot get a user plan: ' + str(e), haproxywi=1)
template = template.render(h2=1, title=title,
autorefresh=autorefresh,
@ -56,5 +61,7 @@ template = template.render(h2=1, title=title,
action=action,
sort=sort,
user_services=user_services,
user_status=user_status,
user_plan=user_plan,
token=token)
print(template)

View File

@ -36,7 +36,7 @@
<tbody>
{% for group in groups %}
<tr id="group-{{ group.group_id }}" class="{{ loop.cycle('odd', 'even') }}">
{% if group.name == "All" %}
{% if group.name == "Default" %}
<td class="padding10 first-collumn">{{ group.name }}</td>
<td>{{ group.description }}</td>
<td></td>

View File

@ -1,4 +1,7 @@
{% from 'include/input_macros.html' import input, select %}
{% if user_status == 0 or user_plan == 'user' %}
{% include 'include/no_sub.html' %}
{% else %}
{% for s in services %}
{% if s.0 == 'roxy-wi-checker' %}
{% if s.3 != '* is not installed' and s.3 != '' %}
@ -122,3 +125,4 @@
{% endif %}
{% endif %}
{% endfor %}
{% endif %}

View File

@ -61,11 +61,13 @@
{% if user %}
<li><a href="/app/overview.py" title="Server and service status" class="overview-link">Overview</a></li>
{% if '1' in user_services %}
<li class="p_menu"><a title="Actions with Haproxy" class="config-show">Haproxy</a>
<li class="p_menu">
<a href="/app/hapservers.py" title="HAProxy servers overview" class="config-show">Haproxy</a>
<ul class="v_menu">
<li><a href="/app/hapservers.py" title="HAProxy servers overview" 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/viewsttats.py" title="HAProxy statistics " class="stats head-submenu">Stats</a></li>
<li><a href="/app/logs.py" title="HAProxy logs " class="logs head-submenu">Logs</a></li>
<li><a href="/app/runtimeapi.py" title="Runtime API - Roxy-WI" class="runtime head-submenu">Runtime API</a></li>
<li><a href="/app/metrics.py" title="HAProxy's metrics" class="metrics head-submenu">Metrics</a></li>
{% if role <= 3 %}
@ -80,11 +82,12 @@
{% endif %}
{% if '2' in user_services %}
<li class="p_menu">
<a title="Actions with NGINX" class="nginx-menu">NGINX</a>
<a href="/app/hapservers.py?service=nginx" title="Overview NGINX servers" class="nginx-menu">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="Working with NGINX configs" class="edit head-submenu">Configs</a></li>
<li><a href="/app/viewsttats.py?service=nginx" title="NGINX statistics" class="stats head-submenu">Stats</a></li>
<li><a href="/app/logs.py?service=nginx" title="NGINX logs " class="logs head-submenu">Logs</a></li>
<li><a href="/app/metrics.py?service=nginx" title="NGINX's metrics" class="metrics head-submenu">Metrics</a></li>
{% if role <= 3 %}
<li><a href="/app/versions.py?service=nginx" title="Working with versions NGINX configs" class="version head-submenu">Versions</a></li>
@ -95,10 +98,11 @@
{% endif %}
{% if '4' in user_services %}
<li class="p_menu">
<a title="Actions with Apache" class="apache-menu">Apache</a>
<a href="/app/hapservers.py?service=apache" title="Overview Apache servers" class="apache-menu">Apache</a>
<ul class="v_menu">
<li><a href="/app/hapservers.py?service=apache" title="Overview Apache servers" class="overview-link head-submenu">Overview</a></li>
<li><a href="/app/config.py?service=apache" title="Working with Apache configs" class="edit head-submenu">Configs</a></li>
<li><a href="/app/logs.py?service=apache" title="Apache logs " class="logs head-submenu">Logs</a></li>
{% if role <= 3 %}
<li><a href="/app/versions.py?service=apache" title="Working with versions Apache configs" class="version head-submenu">Versions</a></li>
<li><a href="/app/add.py?service=apache#ssl" title="Add proxy: Upload SSL certificates - Roxy-WI" class="cert head-submenu" id="add3">SSL</a></li>
@ -109,7 +113,7 @@
{% if '3' in user_services %}
{% if role <= 2 %}
<li class="p_menu">
<a title="Keepalived" class="ha">Keepalived</a>
<a href="/app/hapservers.py?service=keepalived" title="Overview Keepalived servers" class="ha">Keepalived</a>
<ul class="v_menu">
<li><a href="/app/hapservers.py?service=keepalived" title="Overview Keepalived servers" class="overview-link head-submenu">Overview</a> </li>
<li><a href="/app/ha.py" title="Create and configure HA cluster - Roxy-WI" class="keepalived head-submenu">HA</a></li>

View File

@ -1,72 +1,79 @@
<table class="overview" id="ajax-backup-table">
<tr class="overviewHead">
<td class="padding10 first-collumn">Servers</td>
<td class="padding10">Remote server</td>
<td class="padding10">Remote folder</td>
<td class="padding10">Backup type</td>
<td class="padding10">Period time</td>
<td class="padding10">Credentials</td>
<td class="padding10">Description</td>
<td style="margin-left: 5px;"></td>
<td></td>
</tr>
{% for b in backups %}
{% for s in servers %}
{% if b.server in s.2 %}
<tr id="backup-table-{{b.id}}">
<td class="padding10 first-collumn">
{% set id = 'backup-server-' + b.id|string() %}
{{ copy_to_clipboard(id=id, value=b.server) }}
</td>
<td>
{{ input('backup-rserver-'+b.id|string(), value=b.rhost, size='14') }}
</td>
<td>
{{ input('backup-rpath-'+b.id|string(), value=b.rpath) }}
</td>
<td>
{% set values = {'backup':'backup','synchronization':'synchronization'} %}
{{ select('backup-type-'+b.id|string(), values=values, selected=b.backup_type, required='required', class='force_close') }}
</td>
<td>
{% set values = {'hourly':'hourly','daily':'daily','weekly':'weekly', 'monthly':'monthly'} %}
{{ select('backup-time-'+b.id|string(), values=values, selected=b.time, required='required', class='force_close') }}
</td>
<td>
<select id="backup-credentials-{{b.id}}" required>
<option disabled selected>Choose credentials</option>
{% for ssh in sshs %}
{% if ssh.enable == 1 %}
{% if ssh.id == b.cred %}
<option value="{{ssh.id}}" selected="selected">{{ssh.name}}</option>
{% else %}
<option value="{{ssh.id}}">{{ssh.name}}</option>
<div id="backup_tabs">
{% if user_status == 0 or user_plan == 'user' %}
{% include 'include/no_sub.html' %}
{% else %}
<table class="overview" id="ajax-backup-table">
<tr class="overviewHead">
<td class="padding10 first-collumn">Servers</td>
<td class="padding10">Remote server</td>
<td class="padding10">Remote folder</td>
<td class="padding10">Backup type</td>
<td class="padding10">Period</td>
<td class="padding10">Credentials</td>
<td class="padding10">Description</td>
<td style="margin-left: 5px;"></td>
<td></td>
</tr>
{% for b in backups %}
{% for s in servers %}
{% if b.server in s.2 %}
<tr id="backup-table-{{b.id}}">
<td class="padding10 first-collumn">
{% set id = 'backup-server-' + b.id|string() %}
{{ copy_to_clipboard(id=id, value=b.server) }}
</td>
<td>
{{ input('backup-rserver-'+b.id|string(), value=b.rhost, size='14') }}
</td>
<td>
{{ input('backup-rpath-'+b.id|string(), value=b.rpath) }}
</td>
<td>
{% set values = {'backup':'backup','synchronization':'synchronization'} %}
{{ select('backup-type-'+b.id|string(), values=values, selected=b.backup_type, required='required', class='force_close') }}
</td>
<td>
{% set values = {'hourly':'hourly','daily':'daily','weekly':'weekly', 'monthly':'monthly'} %}
{{ select('backup-time-'+b.id|string(), values=values, selected=b.time, required='required', class='force_close') }}
</td>
<td>
<select id="backup-credentials-{{b.id}}" required>
<option disabled selected>Choose credentials</option>
{% for ssh in sshs %}
{% if ssh.enable == 1 %}
{% if ssh.id == b.cred %}
<option value="{{ssh.id}}" selected="selected">{{ssh.name}}</option>
{% else %}
<option value="{{ssh.id}}">{{ssh.name}}</option>
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
</select>
{% endfor %}
</select>
</td>
<td>
{% if b.description is not none %}
{{ input('backup-description-'+b.id|string(), value=b.description) }}
{% else %}
{{ input('backup-description-'+b.id|string()) }}
{% endif %}
</td>
<td>
<a class="add" onclick="cloneBackup({{b.id}})" id="clone-backup{{b.id}}" title="Clone {{b.server}}" style="cursor: pointer;"></a>
</td>
<td>
{% if b.description is not none %}
{{ input('backup-description-'+b.id|string(), value=b.description) }}
{% else %}
{{ input('backup-description-'+b.id|string()) }}
{% endif %}
<a class="delete" onclick="confirmDeleteBackup({{b.id}})" title="Delete backup {{b.server}}" style="cursor: pointer;"></a>
</td>
<td>
<a class="add" onclick="cloneBackup({{b.id}})" id="clone-backup{{b.id}}" title="Clone {{b.server}}" style="cursor: pointer;"></a>
</td>
<td>
<a class="delete" onclick="confirmDeleteBackup({{b.id}})" title="Delete backup {{b.server}}" style="cursor: pointer;"></a>
</td>
</tr>
{% endif %}
{% endfor %}
{% endfor %}
</table>
<br /><span class="add-button" title="Add a new backup job" id="add-backup-button">+ Add backup</span>
<br /><br />
<div id="ajax-backup"></div>
<div class="add-note alert addName alert-info" style="width: inherit; margin-right: 15px;">
You can read the description of all parameters <a href="https://roxy-wi.org/description.py?description=backup" title="Backup description" target="_blank">here</a>
</div>
</tr>
{% endif %}
{% endfor %}
{% endfor %}
</table>
<br /><span class="add-button" title="Add a new backup job" id="add-backup-button">+ Add backup</span>
<br /><br />
<div id="ajax-backup"></div>
<div class="add-note alert addName alert-info" style="width: inherit; margin-right: 15px;">
You can read the description of all parameters <a href="https://roxy-wi.org/description.py?description=backup" title="Backup description" target="_blank">here</a>
</div>
</div>
{% endif %}
</div>

View File

@ -16,7 +16,9 @@
<link href="/inc/chart.min.css" rel="stylesheet">
<script src="/inc/metrics.js"></script>
<script src="/inc/chart.min.js"></script>
{% if services == '0' %}
{% if user_status == 0 or user_plan == 'user' %}
{% include 'include/no_sub.html' %}
{% elif services == '0' %}
<div style="text-align: center;">
<br />
<h3>You have not installed Metrics service.

View File

@ -25,6 +25,9 @@
padding-top: 5px !important;
}
</style>
{% if user_status == 0 or user_plan == 'user' %}
{% include 'include/no_sub.html' %}
{% else %}
{% if history %}
{% include 'include/port_scan_history.html' %}
{% elif port_scanner_stderr != '' %}
@ -245,4 +248,5 @@
} );
}
</script>
{% endif %}
{% endblock %}

View File

@ -5,7 +5,9 @@
<script src="/inc/users.js"></script>
<script src="/inc/fontawesome.min.js"></script>
<script src="/inc/jquery.timeago.js" type="text/javascript"></script>
{% if smon_error != '' %}
{% if user_status == 0 or user_plan == 'user' %}
{% include 'include/no_sub.html' %}
{% elif smon_error != '' %}
<div style="text-align: center;">
<br />
<h3>You have not installed SMON service. Read <a href="https://roxy-wi.org/services.py?service=smon"

View File

@ -73,7 +73,7 @@
.add .fa-clone, .plus .fa-plus, .plus-after .fa-plus, .minus-after .fa-minus {
color: var(--green-color);
}
.plus-after > .fa-plus, .minus-after > .fa-minus {
.plus-after > .fa-plus, .minus-after > .fa-minus, .minus > .fa-minus, .plus > .fa-plus {
color: var(--blue-color);
}
.add-proxy::before {

View File

@ -54,6 +54,7 @@ $( function() {
$( "#saveconfig" ).on("click", ":submit", function(e){
var frm = $('#saveconfig');
var service = $('#service').val();
myCodeMirror.save();
$.ajax({
url: frm.attr('action'),
@ -64,7 +65,7 @@ $( function() {
if (data.indexOf('error: ') != '-1' || data.indexOf('Fatal') != '-1' || data.indexOf('Error') != '-1' || data.indexOf('failed ') != '-1' || data.indexOf('emerg] ') != '-1') {
toastr.clear();
toastr.error(data);
} else if (data.indexOf('command not found') != '-1') {
} else if (data.indexOf(service + ': command not found') != '-1') {
try {
var service = findGetParameter('service');
toastr.error('Cannot save config. There is no ' + service);

View File

@ -42,6 +42,10 @@ $( function() {
show_current_page($(this))
} else if(cur_url[0] == 'config.py' && cur_url[1].split('&')[0] == 'service=nginx' && link2 == 'config.py?service=nginx'){
show_current_page($(this))
} else if(cur_url[0] == 'logs.py' && cur_url[1].split('&')[0] == 'service=nginx' && link2 == 'logs.py?service=nginx'){
show_current_page($(this))
} else if(cur_url[0] == 'logs.py' && cur_url[1].split('&')[0] == 'service=apache' && link2 == 'logs.py?service=apache'){
show_current_page($(this))
} else if(cur_url[0] == 'hapservers.py' && cur_url[1].split('&')[0] == 'service=nginx' && link2 == 'hapservers.py?service=nginx'){
show_current_page($(this))
} else if(cur_url[0] == 'hapservers.py' && cur_url[1].split('&')[0] == 'service=keepalived' && link2 == 'hapservers.py?service=keepalived'){

View File

@ -595,8 +595,8 @@ ul{
background-color: #EBF1F1 !important;
}
.ui-state-active {
background-color: #4A89D8 !important;
border: none var(--blue-color) !important;
background-color: #376fb6 !important;
border: none var(--link-dark-blue) !important;
}
.ui-tabs-nav {
border-radius: 0 !important;