v6.3.15.0

Changelog: https://roxy-wi.org/changelog#6_3_15
pull/364/head
Aidaho 2023-07-03 12:15:39 +03:00
parent 88296e5909
commit 9fc3ab236b
14 changed files with 94 additions and 33 deletions

View File

@ -901,7 +901,7 @@ def update_db_v_6_3_13_4():
print('Updating... DB has been updated to version 6.3.13-3')
elif e.args[0] == 'duplicate column name: check_type' or str(e) == '(1091, "Can\'t DROP COLUMN `http_status`; check that it exists")':
print('Updating... DB has been updated to version 6.3.13-3')
elif e.args[0] == 'duplicate column name: check_type' or str(e) == "'bool' object has no attribute 'sql'":
elif e.args[0] == 'table smon__tmp__ has no column named UNIQUE' or str(e) == "'bool' object has no attribute 'sql'":
print('Updating... DB has been updated to version 6.3.13-3')
else:
print("An error occurred:", e)
@ -916,7 +916,7 @@ def update_db_v_6_3_13_5():
def update_ver():
try:
Version.update(version='6.3.14.0').execute()
Version.update(version='6.3.15.0').execute()
except Exception:
print('Cannot update version')

View File

@ -2487,9 +2487,9 @@ def insert_smon(name, enable, group, desc, telegram, slack, pd, user_group, chec
return last_id
def insert_smon_ping(smon_id, hostname):
def insert_smon_ping(smon_id, hostname, packet_size):
try:
SmonPingCheck.insert(smon_id=smon_id, ip=hostname).execute()
SmonPingCheck.insert(smon_id=smon_id, ip=hostname, packet_size=packet_size).execute()
except Exception as e:
out_error(e)
@ -2682,8 +2682,8 @@ def update_smonTcp(smon_id, ip, port):
return False
def update_smonPing(smon_id, ip):
query = (SmonPingCheck.update(ip=ip).where(SmonPingCheck.smon_id == smon_id))
def update_smonPing(smon_id, ip, packet_size):
query = (SmonPingCheck.update(ip=ip, packet_size=packet_size).where(SmonPingCheck.smon_id == smon_id))
try:
query.execute()
return True

View File

@ -9,23 +9,8 @@ import modules.roxywi.common as roxywi_common
form = common.form
def create_smon() -> None:
user_group = roxywi_common.get_user_group(id=1)
name = common.checkAjaxInput(form.getvalue('newsmonname'))
hostname = common.checkAjaxInput(form.getvalue('newsmon'))
port = common.checkAjaxInput(form.getvalue('newsmonport'))
enable = common.checkAjaxInput(form.getvalue('newsmonenable'))
url = common.checkAjaxInput(form.getvalue('newsmonurl'))
body = common.checkAjaxInput(form.getvalue('newsmonbody'))
group = common.checkAjaxInput(form.getvalue('newsmongroup'))
desc = common.checkAjaxInput(form.getvalue('newsmondescription'))
telegram = common.checkAjaxInput(form.getvalue('newsmontelegram'))
slack = common.checkAjaxInput(form.getvalue('newsmonslack'))
pd = common.checkAjaxInput(form.getvalue('newsmonpd'))
check_type = common.checkAjaxInput(form.getvalue('newsmonchecktype'))
resolver = common.checkAjaxInput(form.getvalue('newsmonresserver'))
record_type = common.checkAjaxInput(form.getvalue('newsmondns_record_type'))
def create_smon(name: str, hostname: str, port: int, enable: int, url: str, body: str, group: int, desc: str, telegram: int,
slack: int, pd: int, packet_size: int, check_type: int, resolver: str, record_type: str, user_group: int, show_new=1) -> None:
if check_type == 'tcp':
try:
port = int(port)
@ -36,10 +21,15 @@ def create_smon() -> None:
print('SMON error: port must be 0-65535')
return None
if check_type == 'ping':
if int(packet_size) < 16:
print('SMON error: a packet size cannot be less than 16')
return None
last_id = sql.insert_smon(name, enable, group, desc, telegram, slack, pd, user_group, check_type)
if check_type == 'ping':
sql.insert_smon_ping(last_id, hostname)
sql.insert_smon_ping(last_id, hostname, packet_size)
elif check_type == 'tcp':
sql.insert_smon_tcp(last_id, hostname, port)
elif check_type == 'http':
@ -47,7 +37,7 @@ def create_smon() -> None:
elif check_type == 'dns':
sql.insert_smon_dns(last_id, hostname, port, resolver, record_type)
if last_id:
if last_id and show_new:
lang = roxywi_common.get_user_lang()
smon = sql.select_smon_by_id(last_id)
pds = sql.get_user_pd_by_group(user_group)
@ -59,6 +49,8 @@ def create_smon() -> None:
template = template.render(smon=smon, telegrams=telegrams, slacks=slacks, pds=pds, lang=lang, check_type=check_type,
smon_service=smon_service)
print(template)
if last_id:
roxywi_common.logging('SMON', f' A new server {name} to SMON has been add ', roxywi=1, login=1)
@ -78,6 +70,7 @@ def update_smon() -> None:
check_type = common.checkAjaxInput(form.getvalue('check_type'))
resolver = common.checkAjaxInput(form.getvalue('updateSmonResServer'))
record_type = common.checkAjaxInput(form.getvalue('updateSmonRecordType'))
packet_size = common.checkAjaxInput(form.getvalue('updateSmonPacket_size'))
is_edited = False
if check_type == 'tcp':
@ -90,6 +83,11 @@ def update_smon() -> None:
print('SMON error: port must be 0-65535')
return None
if check_type == 'ping':
if int(packet_size) < 16:
print('SMON error: a packet size cannot be less than 16')
return None
roxywi_common.check_user_group()
try:
@ -99,7 +97,7 @@ def update_smon() -> None:
elif check_type == 'tcp':
is_edited = sql.update_smonTcp(smon_id, ip, port)
elif check_type == 'ping':
is_edited = sql.update_smonPing(smon_id, ip)
is_edited = sql.update_smonPing(smon_id, ip, packet_size)
elif check_type == 'dns':
is_edited = sql.update_smonDns(smon_id, ip, port, resolver, record_type)

View File

@ -787,6 +787,7 @@ if form.getvalue('newserver') is not None:
page = page.split("#")[0]
port = common.checkAjaxInput(form.getvalue('newport'))
desc = common.checkAjaxInput(form.getvalue('desc'))
add_to_smon = common.checkAjaxInput(form.getvalue('add_to_smon'))
lang = roxywi_common.get_user_lang()
if ip == '':
@ -809,6 +810,12 @@ if form.getvalue('newserver') is not None:
print(template)
roxywi_common.logging(ip, f'A new server {hostname} has been created', roxywi=1, login=1, keep_history=1, service='server')
if add_to_smon:
import modules.tools.smon as smon_mod
user_group = roxywi_common.get_user_group(id=1)
smon_mod.create_smon(hostname, ip, 0, 1, 0, 0, hostname, desc, 0, 0, 0, 0, 'ping', 0, 0, user_group, 0)
except Exception as e:
print(f'error: {e}')
@ -987,7 +994,24 @@ if form.getvalue('getcurrentusergroup') is not None:
if form.getvalue('newsmonname') is not None:
import modules.tools.smon as smon_mod
smon_mod.create_smon()
user_group = roxywi_common.get_user_group(id=1)
name = common.checkAjaxInput(form.getvalue('newsmonname'))
hostname = common.checkAjaxInput(form.getvalue('newsmon'))
port = common.checkAjaxInput(form.getvalue('newsmonport'))
enable = common.checkAjaxInput(form.getvalue('newsmonenable'))
url = common.checkAjaxInput(form.getvalue('newsmonurl'))
body = common.checkAjaxInput(form.getvalue('newsmonbody'))
group = common.checkAjaxInput(form.getvalue('newsmongroup'))
desc = common.checkAjaxInput(form.getvalue('newsmondescription'))
telegram = common.checkAjaxInput(form.getvalue('newsmontelegram'))
slack = common.checkAjaxInput(form.getvalue('newsmonslack'))
pd = common.checkAjaxInput(form.getvalue('newsmonpd'))
check_type = common.checkAjaxInput(form.getvalue('newsmonchecktype'))
resolver = common.checkAjaxInput(form.getvalue('newsmonresserver'))
record_type = common.checkAjaxInput(form.getvalue('newsmondns_record_type'))
packet_size = common.checkAjaxInput(form.getvalue('newsmonpacket_size'))
smon_mod.create_smon(name, hostname, port, enable, url, body, group, desc, telegram, slack, pd, packet_size, check_type, resolver, record_type, user_group)
if form.getvalue('smondel') is not None:
import modules.tools.smon as smon_mod

View File

@ -26,6 +26,10 @@
<td class="padding20" title="{{lang.words.virtual|title()}} IP(VRRP)">{{lang.words.virt|title()}}</td>
<td>{{ checkbox('typeip') }}</td>
</tr>
<tr>
<td class="padding20 help_cursor" title="{{lang.phrases.add_to_smon_desc}}">{{lang.words.add|title()}} {{lang.words.in}} SMON</td>
<td>{{ checkbox('add_to_smon', checked='checked') }}</td>
</tr>
<tr>
<td class="padding20 help_cursor" title="{{lang.phrases.scan_title}}">{{lang.words.scan|title()}} {{lang.words.the}} {{lang.words.server}}</td>
<td>{{ checkbox('scan_server', checked='checked') }}</td>

View File

@ -6,6 +6,10 @@
{% set id = 'smon-ip-' + s.id|string() %}
{{ input(id, value=s_service.ip, size='20') }}
</td>
<td>
{% set id = 'smon-packet_size-' + s.id|string() %}
{{ input(id, value=s_service.packet_size, style='width: 40px;', type='number') }}
</td>
<td class="checkbox">
{% set id = 'smon-enable-' + s.id|string() %}
{% if s.en == 1 %}

View File

@ -320,6 +320,7 @@
"BytesPerSec": "BytesPerSec",
"became_master": "Became Master",
"resource_record_type": "Resource Record Type",
"add_to_smon_desc": "Add the server for checking by SMON ping",
}
%}
{% set roles = {

View File

@ -320,6 +320,7 @@
"BytesPerSec": "Octets par seconde",
"became_master": "Devenu maître",
"resource_record_type": "Type d'enregistrement de ressource",
"add_to_smon_desc": "Ajouter le serveur pour vérification par SMON ping",
}
%}
{% set roles = {
@ -432,7 +433,7 @@
"a_new_version": "Il existe une version plus récente",
"no_new_version": "Il n\'existe pas de version plus récente",
"main_app": "Application principale",
"for_updating": "Pour la mise à jour, vous devez utiliser Roxy-WI RPM ou DEB.",
"for_updating": "Pour la mise à jour, vous devez utiliser Roxy-WI RPM ou DEB",
"how_to_using_repo": "how to start using repository.",
"proxy_settings": "Si le serveur Roxy-WI utilise un proxy pour se connecter à Internet, ajoutez les paramètres du proxy à yum.conf.",
}
@ -463,6 +464,7 @@
"UNKNOWN": "INCONNU",
"PORT_DOWN": "PORT DOWN",
"DISABLED": "DÉSACTIVÉ",
"packet_size": "Taille du paquet",
}
}
%}
@ -646,7 +648,7 @@
"set": "définir",
"type": "type",
"typing": "typing",
"site": "taille",
"size": "taille",
"is": "est",
"w_empty": "vide",
"used": "used",

View File

@ -320,6 +320,7 @@
"BytesPerSec": "Bytes Por Segundo",
"became_master": "Tornou-se mestre",
"resource_record_type": "Tipo de registro de recurso",
"add_to_smon_desc": "Adicione o servidor para verificação por ping SMON",
}
%}
{% set roles = {

View File

@ -320,6 +320,7 @@
"BytesPerSec": "Байт в секунду",
"became_master": "Стал мастером",
"resource_record_type": "Тип записи ресурса",
"add_to_smon_desc": "Добавить сервер для проверки с помощью SMON ping",
}
%}
{% set roles = {
@ -432,7 +433,7 @@
"a_new_version": "Доступна новая версия",
"no_new_version": "Нет новой версии",
"main_app": "Главное приложение",
"for_updating": "Для обновления необходимо использовать Roxy-WI RPM или DEB.",
"for_updating": "Для обновления необходимо использовать Roxy-WI RPM или DEB",
"how_to_using_repo": "как начать пользоваться репозиторием.",
"proxy_settings": "Если сервер Roxy-WI использует прокси для подключения к Интернету, добавьте настройки прокси в yum.conf.",
}
@ -463,6 +464,7 @@
"UNKNOWN": "НЕИЗВЕСТНО",
"PORT_DOWN": "ПОРТ НЕ ДОСТ.",
"DISABLED": "ОТКЛ.",
"packet_size": "Размер пакета",
}
}
%}
@ -646,7 +648,7 @@
"set": "установить",
"type": "тип",
"typing": "печатать",
"site": "размер",
"size": "размер",
"is": "",
"w_empty": "пуста",
"used": "используется",

View File

@ -121,6 +121,7 @@
<tr class="overviewHead">
<th class="padding10 first-collumn" style="width: 200px;">{{lang.words.name|title()}}</th>
<th style="width: 15%;">{{lang.words.Hostname}}</th>
<th style="width: 2%;">{{lang.smon_page.desc.packet_size}}</th>
<th style="width: 5%;">{{lang.words.enabled|title()}}</th>
<th style="width: 15%;">Telegram</th>
<th style="width: 15%;">Slack</th>
@ -215,6 +216,15 @@
{{ input('new-smon-ip') }}
</td>
</tr>
<tr class="smon_ping_check">
<td class="padding20">
{{lang.smon_page.desc.packet_size}}
<span class="need-field">*</span>
</td>
<td>
{{ input('new-smon-packet_size', value='56', type='number') }}
</td>
</tr>
<tr class="smon_dns_check">
<td class="padding20">
Resolver {{lang.words.server}}

View File

@ -875,7 +875,7 @@ label {
color: #999;
padding-top: 5px;
height: 80px;
width: 390px;
width: 395px;
}
.add_proxy {
width: 380px;

View File

@ -63,10 +63,11 @@ function addNewSmonServer(dialog_id) {
valid = valid && checkLength($('#new-smon-url'), "URL", 1);
}
if (check_type == 'ping') {
allFields = $([]).add($('#new-smon-ip')).add($('#new-smon-name'))
allFields = $([]).add($('#new-smon-ip')).add($('#new-smon-name')).add($('#new-smon-packet_size'))
allFields.removeClass("ui-state-error");
valid = valid && checkLength($('#new-smon-name'), "Name", 1);
valid = valid && checkLength($('#new-smon-ip'), "Hostname", 1);
valid = valid && checkLength($('#new-smon-packet_size'), "Packet size", 1);
}
if (check_type == 'dns') {
allFields = $([]).add($('#new-smon-ip')).add($('#new-smon-port')).add($('#new-smon-name')).add($('#new-smon-resolver-server'))
@ -97,6 +98,7 @@ function addNewSmonServer(dialog_id) {
newsmontelegram: $('#new-smon-telegram').val(),
newsmonslack: $('#new-smon-slack').val(),
newsmonpd: $('#new-smon-pd').val(),
newsmonpacket_size: $('#new-smon-packet_size').val(),
newsmonchecktype: check_type,
token: $('#token').val()
},
@ -191,6 +193,7 @@ function updateSmon(id, check_type) {
updateSmonPD: $('#smon-pd-'+id).val(),
updateSmonGroup: $('#smon-group-'+id).val(),
updateSmonDesc: $('#smon-desc-'+id).val(),
updateSmonPacket_size: $('#smon-packet_size-'+id).val(),
check_type: check_type,
id: id,
token: $('#token').val()
@ -227,6 +230,7 @@ function cloneSmom(id, check_type) {
$('#new-smon-url').val($('#smon-url-'+id).val());
$('#new-smon-group').val($('#smon-group-'+id).val());
$('#new-smon-description').val($('#smon-desc-'+id).val())
$('#new-smon-packet_size').val($('#smon-packet_size-'+id).val())
$('#new-smon-telegram').val($('#smon-telegram-'+id+' option:selected').val()).change()
$('#new-smon-slack').val($('#smon-slack-'+id+' option:selected').val()).change()
$('#new-smon-pd').val($('#smon-pd-'+id+' option:selected').val()).change()
@ -324,6 +328,8 @@ function check_and_clear_check_type(check_type) {
$("#check_type").val('http');
$('#check_type').selectmenu("refresh");
$('.smon_tcp_check').hide();
$('.smon_ping_check').hide();
$('.smon_dns_check').hide();
clear_check_vals();
$('.smon_http_check').show();
} else if (check_type == 'tcp') {
@ -332,6 +338,7 @@ function check_and_clear_check_type(check_type) {
$('.new_smon_hostname').show();
$('.smon_http_check').hide();
$('.smon_dns_check').hide();
$('.smon_ping_check').hide();
clear_check_vals();
$('.smon_tcp_check').show();
} else if (check_type == 'dns') {
@ -340,6 +347,7 @@ function check_and_clear_check_type(check_type) {
$('.smon_tcp_check').hide();
$('.new_smon_hostname').show();
$('.smon_http_check').hide();
$('.smon_ping_check').hide();
clear_check_vals();
$('#new-smon-port').val('53');
$('.smon_dns_check').show();
@ -348,6 +356,7 @@ function check_and_clear_check_type(check_type) {
$('.new_smon_hostname').show();
$('.smon_tcp_check').hide();
$('.smon_dns_check').hide();
$('.smon_ping_check').show();
$("#check_type").val('ping');
$('#check_type').selectmenu("refresh");
clear_check_vals();
@ -359,4 +368,5 @@ function clear_check_vals() {
$('#new-smon-url').val('');
$('#new-smon-body').val('');
$('#new-smon-port').val('');
$('#new-smon-packet_size').val('');
}

View File

@ -1076,6 +1076,7 @@ function addServer(dialog_id) {
var nginx = 0;
var apache = 0;
var firewall = 0;
var add_to_smon = 0;
if ($('#scan_server').is(':checked')) {
scan_server = '1';
}
@ -1097,6 +1098,9 @@ function addServer(dialog_id) {
if ($('#firewall').is(':checked')) {
firewall = '1';
}
if ($('#add_to_smon').is(':checked')) {
add_to_smon = '1';
}
allFields = $( [] ).add( $('#new-server-add') ).add( $('#new-ip') ).add( $('#new-port') )
allFields.removeClass( "ui-state-error" );
valid = valid && checkLength( $('#new-server-add'), "Hostname", 1 );
@ -1124,6 +1128,7 @@ function addServer(dialog_id) {
nginx: nginx,
apache: apache,
firewall: firewall,
add_to_smon: add_to_smon,
enable: enable,
slave: $('#slavefor' ).val(),
cred: cred,