mirror of https://github.com/Aidaho12/haproxy-wi
parent
fb3b1d1867
commit
88296e5909
|
@ -852,7 +852,7 @@ def update_db_v_6_3_13_1():
|
|||
), fields=[SmonTcpCheck.smon_id, SmonTcpCheck.ip, SmonTcpCheck.port]
|
||||
).on_conflict_ignore().execute()
|
||||
except Exception as e:
|
||||
if e.args[0] == 'duplicate column name: haproxy' or str(e) == 'type object \'SMON\' has no attribute \'ip\'':
|
||||
if e.args[0] == 'no such column: t1.name' or str(e) == 'type object \'SMON\' has no attribute \'ip\'':
|
||||
print('Updating... DB has been updated to version 6.3.13-1')
|
||||
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.13.0').execute()
|
||||
Version.update(version='6.3.14.0').execute()
|
||||
except Exception:
|
||||
print('Cannot update version')
|
||||
|
||||
|
|
|
@ -649,6 +649,18 @@ class SmonPingCheck(BaseModel):
|
|||
primary_key = False
|
||||
|
||||
|
||||
class SmonDnsCheck(BaseModel):
|
||||
smon_id = ForeignKeyField(SMON, on_delete='Cascade', unique=True)
|
||||
ip = CharField()
|
||||
port = IntegerField(constraints=[SQL('DEFAULT 53')])
|
||||
resolver = CharField()
|
||||
record_type = CharField()
|
||||
|
||||
class Meta:
|
||||
table_name = 'smon_dns_check'
|
||||
primary_key = False
|
||||
|
||||
|
||||
def create_tables():
|
||||
with conn:
|
||||
conn.create_tables([User, Server, Role, Telegram, Slack, UUID, Token, ApiToken, Groups, UserGroups, ConfigVersion,
|
||||
|
@ -657,4 +669,4 @@ def create_tables():
|
|||
ProvisionedServers, MetricsHttpStatus, SMON, WafRules, Alerts, GeoipCodes, NginxMetrics,
|
||||
SystemInfo, Services, UserName, GitSetting, CheckerSetting, ApacheMetrics, ProvisionParam,
|
||||
WafNginx, ServiceStatus, KeepaliveRestart, PD, SmonHistory, SmonTcpCheck, SmonHttpCheck,
|
||||
SmonPingCheck])
|
||||
SmonPingCheck, SmonDnsCheck])
|
||||
|
|
|
@ -2501,6 +2501,13 @@ def insert_smon_tcp(smon_id, hostname, port):
|
|||
out_error(e)
|
||||
|
||||
|
||||
def insert_smon_dns(smon_id: int, hostname: str, port: int, resolver: str, record_type: str) -> None:
|
||||
try:
|
||||
SmonDnsCheck.insert(smon_id=smon_id, ip=hostname, port=port, resolver=resolver, record_type=record_type).execute()
|
||||
except Exception as e:
|
||||
out_error(e)
|
||||
|
||||
|
||||
def insert_smon_http(smon_id, url, body):
|
||||
try:
|
||||
SmonHttpCheck.insert(smon_id=smon_id, url=url, body=body).execute()
|
||||
|
@ -2565,6 +2572,16 @@ def select_en_smon_http() -> object:
|
|||
return query_res
|
||||
|
||||
|
||||
def select_en_smon_dns() -> object:
|
||||
query = SmonDnsCheck.select(SmonDnsCheck, SMON).join_from(SmonDnsCheck, SMON).where(SMON.en == '1')
|
||||
try:
|
||||
query_res = query.execute()
|
||||
except Exception as e:
|
||||
out_error(e)
|
||||
else:
|
||||
return query_res
|
||||
|
||||
|
||||
def select_smon_tcp(user_group):
|
||||
if user_group == 1:
|
||||
query = SmonTcpCheck.select()
|
||||
|
@ -2593,6 +2610,20 @@ def select_smon_http(user_group):
|
|||
return query_res
|
||||
|
||||
|
||||
def select_smon_dns(user_group):
|
||||
if user_group == 1:
|
||||
query = SmonDnsCheck.select()
|
||||
else:
|
||||
query = SmonDnsCheck.select().where(SMON.user_group == user_group)
|
||||
|
||||
try:
|
||||
query_res = query.execute()
|
||||
except Exception as e:
|
||||
out_error(e)
|
||||
else:
|
||||
return query_res
|
||||
|
||||
|
||||
def select_smon_by_id(last_id):
|
||||
query = SMON.select().where(SMON.id == last_id)
|
||||
try:
|
||||
|
@ -2608,9 +2639,10 @@ def select_smon_check_by_id(last_id, check_type):
|
|||
query = SmonPingCheck.select().where(SmonPingCheck.smon_id == last_id)
|
||||
elif check_type == 'tcp':
|
||||
query = SmonTcpCheck.select().where(SmonTcpCheck.smon_id == last_id)
|
||||
elif check_type == 'dns':
|
||||
query = SmonDnsCheck.select().where(SmonDnsCheck.smon_id == last_id)
|
||||
else:
|
||||
query = SmonHttpCheck.select().where(SmonHttpCheck.smon_id == last_id)
|
||||
print(query)
|
||||
try:
|
||||
query_res = query.execute()
|
||||
except Exception as e:
|
||||
|
@ -2650,7 +2682,7 @@ def update_smonTcp(smon_id, ip, port):
|
|||
return False
|
||||
|
||||
|
||||
def update_smonPing(smon_id, ip, port):
|
||||
def update_smonPing(smon_id, ip):
|
||||
query = (SmonPingCheck.update(ip=ip).where(SmonPingCheck.smon_id == smon_id))
|
||||
try:
|
||||
query.execute()
|
||||
|
@ -2660,6 +2692,17 @@ def update_smonPing(smon_id, ip, port):
|
|||
return False
|
||||
|
||||
|
||||
def update_smonDns(smon_id: int, ip: str, port: int, resolver: str, record_type: str):
|
||||
query = (SmonDnsCheck.update(ip=ip, port=port, resolver=resolver, record_type=record_type)
|
||||
.where(SmonDnsCheck.smon_id == smon_id))
|
||||
try:
|
||||
query.execute()
|
||||
return True
|
||||
except Exception as e:
|
||||
out_error(e)
|
||||
return False
|
||||
|
||||
|
||||
def update_smon(smon_id, name, telegram, slack, pd, group, desc, en):
|
||||
query = (SMON.update(
|
||||
name=name, telegram_channel_id=telegram, slack_channel_id=slack, pd_channel_id=pd, group=group, desc=desc, en=en
|
||||
|
@ -2826,6 +2869,8 @@ def select_one_smon(smon_id: int, check_id: int) -> object:
|
|||
query = SmonTcpCheck.select(SmonTcpCheck, SMON).join_from(SmonTcpCheck, SMON).where(SMON.id == smon_id)
|
||||
elif check_id == 2:
|
||||
query = SmonHttpCheck.select(SmonHttpCheck, SMON).join_from(SmonHttpCheck, SMON).where(SMON.id == smon_id)
|
||||
elif check_id == 5:
|
||||
query = SmonDnsCheck.select(SmonDnsCheck, SMON).join_from(SmonDnsCheck, SMON).where(SMON.id == smon_id)
|
||||
else:
|
||||
query = SmonPingCheck.select(SmonPingCheck, SMON).join_from(SmonPingCheck, SMON).where(SMON.id == smon_id)
|
||||
try:
|
||||
|
@ -3161,6 +3206,15 @@ def delete_alert_history(keep_interval: int, service: str):
|
|||
out_error(e)
|
||||
|
||||
|
||||
def delete_smon_history():
|
||||
cur_date = get_date.return_date('regular', timedelta_minus=1)
|
||||
query = SmonHistory.delete().where(SmonHistory.date < cur_date)
|
||||
try:
|
||||
query.execute()
|
||||
except Exception as e:
|
||||
out_error(e)
|
||||
|
||||
|
||||
def delete_portscanner_history(keep_interval: int):
|
||||
cur_date = get_date.return_date('regular', timedelta_minus=keep_interval)
|
||||
query = PortScannerHistory.delete().where(
|
||||
|
|
|
@ -56,7 +56,7 @@ def install_haproxy(server_ip: str, api=0, **kwargs):
|
|||
os.system(f"cp {full_path}/scripts/{script} {full_path}/{script}")
|
||||
|
||||
if haproxy_ver is None:
|
||||
haproxy_ver = '2.7.1-1'
|
||||
haproxy_ver = '2.8.0-1'
|
||||
|
||||
if proxy is not None and proxy != '' and proxy != 'None':
|
||||
proxy_serv = proxy
|
||||
|
|
|
@ -23,12 +23,14 @@ def create_smon() -> None:
|
|||
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'))
|
||||
|
||||
if check_type == 'tcp':
|
||||
try:
|
||||
port = int(port)
|
||||
except Exception:
|
||||
print('SMON error: port must number')
|
||||
print('SMON error: port must be a number')
|
||||
return None
|
||||
if port > 65535 or port < 0:
|
||||
print('SMON error: port must be 0-65535')
|
||||
|
@ -42,6 +44,8 @@ def create_smon() -> None:
|
|||
sql.insert_smon_tcp(last_id, hostname, port)
|
||||
elif check_type == 'http':
|
||||
sql.insert_smon_http(last_id, url, body)
|
||||
elif check_type == 'dns':
|
||||
sql.insert_smon_dns(last_id, hostname, port, resolver, record_type)
|
||||
|
||||
if last_id:
|
||||
lang = roxywi_common.get_user_lang()
|
||||
|
@ -72,6 +76,8 @@ def update_smon() -> None:
|
|||
group = common.checkAjaxInput(form.getvalue('updateSmonGroup'))
|
||||
desc = common.checkAjaxInput(form.getvalue('updateSmonDesc'))
|
||||
check_type = common.checkAjaxInput(form.getvalue('check_type'))
|
||||
resolver = common.checkAjaxInput(form.getvalue('updateSmonResServer'))
|
||||
record_type = common.checkAjaxInput(form.getvalue('updateSmonRecordType'))
|
||||
is_edited = False
|
||||
|
||||
if check_type == 'tcp':
|
||||
|
@ -93,7 +99,9 @@ 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_smonTcp(smon_id, ip)
|
||||
is_edited = sql.update_smonPing(smon_id, ip)
|
||||
elif check_type == 'dns':
|
||||
is_edited = sql.update_smonDns(smon_id, ip, port, resolver, record_type)
|
||||
|
||||
if is_edited:
|
||||
print("Ok")
|
||||
|
|
16
app/smon.py
16
app/smon.py
|
@ -39,6 +39,7 @@ smon_statuses = ''
|
|||
smon_ping = ''
|
||||
smon_tcp = ''
|
||||
smon_http = ''
|
||||
smon_dns = ''
|
||||
smon = ''
|
||||
|
||||
try:
|
||||
|
@ -55,6 +56,7 @@ if action == 'add':
|
|||
smon_ping = sql.select_smon_ping(user_group)
|
||||
smon_tcp = sql.select_smon_tcp(user_group)
|
||||
smon_http = sql.select_smon_http(user_group)
|
||||
smon_dns = sql.select_smon_dns(user_group)
|
||||
roxywi_auth.page_for_admin(level=3)
|
||||
if lang == 'ru':
|
||||
title = "SMON: Админка"
|
||||
|
@ -86,7 +88,6 @@ elif action == 'dashboard':
|
|||
dashboard_id = int(form.getvalue('dashboard_id'))
|
||||
check_id = int(form.getvalue('check_id'))
|
||||
smon_statuses = sql.select_smon_history(dashboard_id, check_id)
|
||||
title = ''
|
||||
smon_name = sql.get_smon_service_name_by_id(dashboard_id)
|
||||
cur_status = sql.get_last_smon_status_by_check(dashboard_id, check_id)
|
||||
check_interval = sql.get_setting('smon_check_interval')
|
||||
|
@ -116,11 +117,11 @@ elif action == 'dashboard':
|
|||
cert_day_diff = (ssl_expire_date - present).days
|
||||
|
||||
rendered_template = template.render(
|
||||
h2=1, title=title, autorefresh=autorefresh, role=user_params['role'], user=user_params['user'], smon=smon,
|
||||
group=user_group, lang=lang, user_status=user_subscription['user_status'], check_interval=check_interval,
|
||||
user_plan=user_subscription['user_plan'], token=user_params['token'], smon_statuses=smon_statuses, uptime=uptime,
|
||||
user_services=user_params['user_services'], cur_status=cur_status, avg_res_time=avg_res_time, smon_name=smon_name,
|
||||
cert_day_diff=cert_day_diff, check_id=check_id, dashboard_id=dashboard_id, last_resp_time=last_resp_time
|
||||
h2=1, autorefresh=0, role=user_params['role'], user=user_params['user'], smon=smon, group=user_group, lang=lang,
|
||||
user_status=user_subscription['user_status'], check_interval=check_interval, user_plan=user_subscription['user_plan'],
|
||||
token=user_params['token'], smon_statuses=smon_statuses, uptime=uptime, user_services=user_params['user_services'],
|
||||
cur_status=cur_status, avg_res_time=avg_res_time, smon_name=smon_name, cert_day_diff=cert_day_diff, check_id=check_id,
|
||||
dashboard_id=dashboard_id, last_resp_time=last_resp_time
|
||||
)
|
||||
print(rendered_template)
|
||||
sys.exit()
|
||||
|
@ -138,7 +139,8 @@ rendered_template = template.render(
|
|||
h2=1, title=title, autorefresh=autorefresh, role=user_params['role'], user=user_params['user'], group=user_group,
|
||||
telegrams=telegrams, slacks=slacks, pds=pds, lang=lang, smon=smon, smon_status=smon_status, smon_error=stderr,
|
||||
action=action, sort=sort, user_services=user_params['user_services'], user_status=user_subscription['user_status'],
|
||||
user_plan=user_subscription['user_plan'], token=user_params['token'], smon_ping=smon_ping, smon_tcp=smon_tcp, smon_http=smon_http
|
||||
user_plan=user_subscription['user_plan'], token=user_params['token'], smon_ping=smon_ping, smon_tcp=smon_tcp,
|
||||
smon_http=smon_http, smon_dns=smon_dns
|
||||
|
||||
)
|
||||
print(rendered_template)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% import 'languages/'+lang|default('en')+'.html' as lang %}
|
||||
{% from 'include/input_macros.html' import input, checkbox %}
|
||||
{% from 'include/input_macros.html' import input, checkbox, select %}
|
||||
{% for s in smon %}
|
||||
{% for s_service in smon_service %}
|
||||
<tr class="newserver" id="smon-{{s.id}}">
|
||||
|
@ -9,6 +9,8 @@
|
|||
{% include 'include/smon_ping_server.html' %}
|
||||
{% elif check_type == 'http' %}
|
||||
{% include 'include/smon_http_server.html' %}
|
||||
{% elif check_type == 'dns' %}
|
||||
{% include 'include/smon_dns_server.html' %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
{% set dis = [] %}
|
||||
{% for s in smon %}
|
||||
{% if s.en == 1 %}
|
||||
{% if s.status == 1 and s.http_status == 1 and s.body_status == 1 %}
|
||||
{% if s.status == 1 and s.body_status == 1 %}
|
||||
{% if up.append('1') %} {% endif %}
|
||||
{% else %}
|
||||
{% if down.append('1') %} {% endif %}
|
||||
|
@ -42,6 +42,10 @@
|
|||
{% set check_id = 4 %}
|
||||
{% set checks = lang.smon_page.desc.enabled_checks +': Ping' %}
|
||||
{% endif %}
|
||||
{% if s.check_type == 'dns' %}
|
||||
{% set check_id = 5 %}
|
||||
{% set checks = lang.smon_page.desc.enabled_checks +': DNS' %}
|
||||
{% endif %}
|
||||
{% if s.en == 1 %}
|
||||
{% if s.status == 1 and s.body_status == 1 %}
|
||||
{% set additional_classes = 'good div-server-head-up' %}
|
||||
|
@ -125,7 +129,7 @@
|
|||
</div>
|
||||
{% else %}
|
||||
<div class="down">
|
||||
{{lang.smon_page.desc.PORT_DOWN}}
|
||||
{{lang.smon_page.desc.DOWN}}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
<td class="padding10 first-collumn" style="width: 150px;">
|
||||
{% set id = 'smon-name-' + s.id|string() %}
|
||||
{{ input(id, value=s.name.strip("'"), size='20') }}
|
||||
</td>
|
||||
<td style="width: 150px;">
|
||||
{% set id = 'smon-ip-' + s.id|string() %}
|
||||
{{ input(id, value=s_service.ip, size='20') }}
|
||||
</td>
|
||||
<td>
|
||||
{% set id = 'smon-resolver-' + s.id|string() %}
|
||||
{{ input(id, value=s_service.resolver, size='20') }}
|
||||
</td>
|
||||
<td>
|
||||
{% set id = 'smon-port-' + s.id|string() %}
|
||||
{{ input(id, value=s_service.port, size='5') }}
|
||||
</td>
|
||||
<td>
|
||||
{% set id = 'smon-record_type-' + s.id|string() %}
|
||||
{% set check_types = {'a': 'A', 'aaa': 'AAA', 'caa': 'CAA', 'cname': 'CNAME', 'mx': 'MX', 'ns': 'NS',
|
||||
'ptr': 'PTR', 'sao': 'SAO', 'srv': 'SRV', 'txt': 'TXT'} %}
|
||||
{{ select(id, values=check_types, selected=s_service.record_type) }}
|
||||
</td>
|
||||
<td class="checkbox">
|
||||
{% set id = 'smon-enable-' + s.id|string() %}
|
||||
{% if s.en == 1 %}
|
||||
{{ checkbox(id, checked='checked') }}
|
||||
{% else %}
|
||||
{{ checkbox(id) }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<select id="smon-telegram-{{s.id}}">
|
||||
<option value="0">{{lang.words.disabled|title()}}</option>
|
||||
{% for t in telegrams %}
|
||||
{% if s.telegram_channel_id|int() == t.id|int() %}
|
||||
<option value="{{t.id}}" selected>{{t.chanel_name}}</option>
|
||||
{% else %}
|
||||
<option value="{{t.id}}">{{t.chanel_name}}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select id="smon-slack-{{s.id}}">
|
||||
<option value="0">{{lang.words.disabled|title()}}</option>
|
||||
{% for t in slacks %}
|
||||
{% if s.slack_channel_id|int() == t.id|int() %}
|
||||
<option value="{{t.id}}" selected>{{t.chanel_name}}</option>
|
||||
{% else %}
|
||||
<option value="{{t.id}}">{{t.chanel_name}}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select id="smon-pd-{{s.id}}">
|
||||
<option value="0">{{lang.words.disabled|title()}}</option>
|
||||
{% for t in pds %}
|
||||
{% if s.pd_channel_id|int() == t.id|int() %}
|
||||
<option value="{{t.id}}" selected>{{t.chanel_name}}</option>
|
||||
{% else %}
|
||||
<option value="{{t.id}}">{{t.chanel_name}}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
{% set id = 'smon-group-' + s.id|string() %}
|
||||
{% if s.group is not none %}
|
||||
{{ input(id, value=s.group, size='15') }}
|
||||
{% else %}
|
||||
{{ input(id, size='15') }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% set id = 'smon-desc-' + s.id|string() %}
|
||||
{% if s.desc is not none %}
|
||||
{{ input(id, value=s.desc.strip("'"), size='20') }}
|
||||
{% else %}
|
||||
{{ input(id, size='20') }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<a class="add" onclick="cloneSmom({{s.id}}, 'dns')" id="clone-{{s.id}}" title="{{lang.words.clone|title()}} {{s.ip}}" style="cursor: pointer; color: #000;"></a>
|
||||
</td>
|
||||
<td>
|
||||
<a class="delete" onclick="confirmDeleteSmon({{s.id}}, 'dns')" title="{{lang.words.delete|title()}} {{s.ip}}" style="cursor: pointer; color: #000;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
<script>
|
||||
$( function() {
|
||||
$("#smon-telegram-{{s.id}}" ).selectmenu({
|
||||
width: 160
|
||||
});
|
||||
$("#smon-slack-{{s.id}}" ).selectmenu({
|
||||
width: 160
|
||||
});
|
||||
$("#smon-pd-{{s.id}}" ).selectmenu({
|
||||
width: 160
|
||||
});
|
||||
$("#smon-record_type-{{s.id}}" ).selectmenu({
|
||||
width: 78
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -3,7 +3,7 @@
|
|||
{% block title %}{{ lang.menu_links.history.title }} {{ smon_name }}{% endblock %}
|
||||
{% block h2 %}{{ lang.menu_links.history.title }} {{ smon_name }}{% endblock %}
|
||||
{% block content %}
|
||||
{% set checking_types = {'1': 'TCP/UDP', '2': 'HTTP', '4': 'Ping'} %}
|
||||
{% set checking_types = {'1': 'TCP/UDP', '2': 'HTTP', '4': 'Ping', '5': 'DNS'} %}
|
||||
{% if user_status == 0 or user_plan == 'user' %}
|
||||
{% include 'include/no_sub.html' %}
|
||||
{% else %}
|
||||
|
@ -15,13 +15,17 @@
|
|||
{% set service_status = [] %}
|
||||
{% for s in smon %}
|
||||
{% set service_status = service_status.append(s.smon_id.en) %}
|
||||
<div id="smon_name" class="col-md-8">
|
||||
{% if check_id == 2 %}
|
||||
<div id="smon_name" class="col-md-8"><a href="{{s.url}}" title="{{lang.words.open|title()}}" target="_blank">{{s.url}}</a></div>
|
||||
<a href="{{s.url}}" title="{{lang.words.open|title()}}" target="_blank">{{s.url}}</a>
|
||||
{% elif check_id == 1 %}
|
||||
<div id="smon_name" class="col-md-8" title="{{s.desc}}">{{s.ip}}:{{s.port}}</div>
|
||||
{{s.ip}}:{{s.port}}
|
||||
{% elif check_id == 5 %}
|
||||
{{s.ip}} {{lang.phrases.resource_record_type}}: {{s.record_type|upper()}}
|
||||
{% else %}
|
||||
<div id="smon_name" class="col-md-8" title="{{s.desc}}">{{s.smon_id.name}}</div>
|
||||
{{s.smon_id.name}}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="row statuses wrap">
|
||||
|
@ -37,18 +41,18 @@
|
|||
<div id="check_interval">{{lang.words.checking|title()}} {{lang.words.every}} {{check_interval}} {{lang.words.minutes2}}</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
{% if service_status.0 %}
|
||||
{% if cur_status %}
|
||||
{% set add_class = 'serverUp' %}
|
||||
{% set status = lang.smon_page.desc.UP %}
|
||||
{% else %}
|
||||
{% set add_class = 'serverDown' %}
|
||||
{% set status = lang.smon_page.desc.DOWN %}
|
||||
{% endif %}
|
||||
{% if service_status.0 %}
|
||||
{% if cur_status %}
|
||||
{% set add_class = 'serverUp' %}
|
||||
{% set status = lang.smon_page.desc.UP %}
|
||||
{% else %}
|
||||
{% set add_class = 'serverNone' %}
|
||||
{% set status = lang.smon_page.desc.DISABLED %}
|
||||
{% set add_class = 'serverDown' %}
|
||||
{% set status = lang.smon_page.desc.DOWN %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% set add_class = 'serverNone' %}
|
||||
{% set status = lang.smon_page.desc.DISABLED %}
|
||||
{% endif %}
|
||||
<span class="{{add_class}} cur_status" style="font-size: 30px; border-radius: 50rem!important;min-width: 62px;">{{status}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -88,8 +88,5 @@
|
|||
$("#smon-pd-{{s.id}}" ).selectmenu({
|
||||
width: 160
|
||||
});
|
||||
$("#smon-proto-{{s.id}}" ).selectmenu({
|
||||
width: 78
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -319,6 +319,7 @@
|
|||
"ReqPerSec": "ReqPerSec",
|
||||
"BytesPerSec": "BytesPerSec",
|
||||
"became_master": "Became Master",
|
||||
"resource_record_type": "Resource Record Type",
|
||||
}
|
||||
%}
|
||||
{% set roles = {
|
||||
|
|
|
@ -319,6 +319,7 @@
|
|||
"ReqPerSec": "ReqPerSec",
|
||||
"BytesPerSec": "Octets par seconde",
|
||||
"became_master": "Devenu maître",
|
||||
"resource_record_type": "Type d'enregistrement de ressource",
|
||||
}
|
||||
%}
|
||||
{% set roles = {
|
||||
|
|
|
@ -319,6 +319,7 @@
|
|||
"ReqPerSec": "ReqPerSec",
|
||||
"BytesPerSec": "Bytes Por Segundo",
|
||||
"became_master": "Tornou-se mestre",
|
||||
"resource_record_type": "Tipo de registro de recurso",
|
||||
}
|
||||
%}
|
||||
{% set roles = {
|
||||
|
|
|
@ -319,6 +319,7 @@
|
|||
"ReqPerSec": "Запросов в секунду",
|
||||
"BytesPerSec": "Байт в секунду",
|
||||
"became_master": "Стал мастером",
|
||||
"resource_record_type": "Тип записи ресурса",
|
||||
}
|
||||
%}
|
||||
{% set roles = {
|
||||
|
|
|
@ -68,8 +68,8 @@
|
|||
<td class="padding10 first-collumn" style="width: 20%;">
|
||||
{% set values = dict() %}
|
||||
{% set values = {'2.3.0-1':'2.3.0-1','2.3.10-1':'2.3.10-1', '2.4.0-1':'2.4.0-1','2.4.9-1':'2.4.9-1',
|
||||
'2.4.15-1':'2.4.15-1','2.5.1-1':'2.5.1-1','2.6.0-1':'2.6.0-1','2.7.1-1':'2.7.1-1'} %}
|
||||
{{ select('hapver', values=values, selected='2.7.1-1', required='required') }}
|
||||
'2.4.15-1':'2.4.15-1','2.5.1-1':'2.5.1-1','2.6.0-1':'2.6.0-1','2.7.1-1':'2.7.1-1','2.8.0-1':'2.8.0-1'} %}
|
||||
{{ select('hapver', values=values, selected='2.8.0-1', required='required') }}
|
||||
</td>
|
||||
<td class="padding10 first-collumn">
|
||||
<select autofocus required name="haproxyaddserv" id="haproxyaddserv">
|
||||
|
|
|
@ -146,6 +146,40 @@
|
|||
</table>
|
||||
<br /><span class="add-button" title="{{lang.words.add|title()}} {{lang.words.w_a}} {{lang.words.new}} {{lang.words.server}}" id="add-smon-button-ping">+ {{lang.words.add|title()}}</span>
|
||||
<br /><br />
|
||||
<table class="overview overview-overflow" id="ajax-smon-dns" style="margin-bottom: 20px;">
|
||||
<thead>
|
||||
<caption><h3>DNS {{lang.words.checking}}</h3></caption>
|
||||
<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: 15%;">Resolver {{lang.words.server}}</th>
|
||||
<th style="width: 5%;">{{lang.words.port|title()}}</th>
|
||||
<th style="width: 10%;">{{lang.phrases.resource_record_type}}</th>
|
||||
<th style="width: 5%;">{{lang.words.enabled|title()}}</th>
|
||||
<th style="width: 15%;">Telegram</th>
|
||||
<th style="width: 15%;">Slack</th>
|
||||
<th style="width: 15%;">PagerDuty</th>
|
||||
<th style="width: 10%;">{{lang.words.group|title()}}</th>
|
||||
<th style="width: 100%;">{{lang.words.desc|title()}}</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for s in smon %}
|
||||
{% if s.check_type == 'dns' %}
|
||||
{% for s_service in smon_dns %}
|
||||
{% if s_service.smon_id|string() == s.id|string() %}
|
||||
<tr id="smon-dns-{{s.id}}">
|
||||
{% include 'include/smon_dns_server.html' %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<br /><span class="add-button" title="{{lang.words.add|title()}} {{lang.words.w_a}} {{lang.words.new}} {{lang.words.server}}" id="add-smon-button-dns">+ {{lang.words.add|title()}}</span>
|
||||
<br /><br />
|
||||
<div id="ajax"></div>
|
||||
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
||||
{{lang.phrases.read_about_parameters}} <a href="https://roxy-wi.org/services/smon" title="SMON service description" target="_blank">{{lang.words.here}}</a>
|
||||
|
@ -168,7 +202,7 @@
|
|||
<span class="need-field">*</span>
|
||||
</td>
|
||||
<td>
|
||||
{% set check_types = {'ping': 'Ping', 'tcp': 'TCP/UDP', 'http': 'HTTP(s)'} %}
|
||||
{% set check_types = {'dns': 'DNS', 'ping': 'Ping', 'tcp': 'TCP/UDP', 'http': 'HTTP(s)'} %}
|
||||
{{ select('check_type', values=check_types, selected='http') }}
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -181,7 +215,16 @@
|
|||
{{ input('new-smon-ip') }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="smon_tcp_check">
|
||||
<tr class="smon_dns_check">
|
||||
<td class="padding20">
|
||||
Resolver {{lang.words.server}}
|
||||
<span class="need-field">*</span>
|
||||
</td>
|
||||
<td>
|
||||
{{ input('new-smon-resolver-server', value='8.8.8.8') }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="smon_tcp_check smon_dns_check">
|
||||
<td class="padding20">
|
||||
{{lang.words.port|title()}}
|
||||
<span class="need-field">*</span>
|
||||
|
@ -190,19 +233,33 @@
|
|||
{{ input('new-smon-port', type='number', size='4') }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="smon_http_check">
|
||||
<td class="padding20">
|
||||
URL
|
||||
<span class="need-field">*</span>
|
||||
</td>
|
||||
<td>{{ input('new-smon-url', value='https://', title='proto://url[:port]/') }}</td>
|
||||
</tr>
|
||||
<tr class="smon_http_check">
|
||||
<td class="padding20">{{lang.words.body|title()}}</td>
|
||||
<td>{{ input('new-smon-body') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding20">{{lang.words.enable|title()}}</td>
|
||||
<td>
|
||||
{{ checkbox('new-smon-enable', checked='checked') }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="smon_http_check">
|
||||
<td class="padding20">URL</td>
|
||||
<td>{{ input('new-smon-url', value='https://', title='proto://url[:port]/') }}</td>
|
||||
</tr>
|
||||
<tr class="smon_http_check">
|
||||
<td class="padding20">{{lang.words.body|title()}}</td>
|
||||
<td>{{ input('new-smon-body') }}</td>
|
||||
<tr class="smon_dns_check">
|
||||
<td class="padding20">
|
||||
{{lang.phrases.resource_record_type}}
|
||||
<span class="need-field">*</span>
|
||||
</td>
|
||||
<td>
|
||||
{% set check_types = {'a': 'A', 'aaa': 'AAA', 'caa': 'CAA', 'cname': 'CNAME', 'mx': 'MX', 'ns': 'NS',
|
||||
'ptr': 'PTR', 'sao': 'SAO', 'srv': 'SRV', 'txt': 'TXT'} %}
|
||||
{{ select('new-smon-dns_record_type', values=check_types, selected='a') }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding20">Telegram</td>
|
||||
|
|
|
@ -50,7 +50,7 @@ function addNewSmonServer(dialog_id) {
|
|||
var valid = true;
|
||||
var check_type = $('#check_type').val();
|
||||
if (check_type == 'tcp') {
|
||||
allFields = $([]).add($('#new-smon-ip')).add($('#new-smon-port')).add($('#new-smon-hostname')).add($('#new-smon-name'))
|
||||
allFields = $([]).add($('#new-smon-ip')).add($('#new-smon-port')).add($('#new-smon-name'))
|
||||
allFields.removeClass("ui-state-error");
|
||||
valid = valid && checkLength($('#new-smon-ip'), "Hostname", 1);
|
||||
valid = valid && checkLength($('#new-smon-name'), "Name", 1);
|
||||
|
@ -68,6 +68,14 @@ function addNewSmonServer(dialog_id) {
|
|||
valid = valid && checkLength($('#new-smon-name'), "Name", 1);
|
||||
valid = valid && checkLength($('#new-smon-ip'), "Hostname", 1);
|
||||
}
|
||||
if (check_type == 'dns') {
|
||||
allFields = $([]).add($('#new-smon-ip')).add($('#new-smon-port')).add($('#new-smon-name')).add($('#new-smon-resolver-server'))
|
||||
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-port'), "Port", 1);
|
||||
valid = valid && checkLength($('#new-smon-resolver-server'), "Resolver server", 1);
|
||||
}
|
||||
var enable = 0;
|
||||
if ($('#new-smon-enable').is(':checked')) {
|
||||
enable = '1';
|
||||
|
@ -79,6 +87,8 @@ function addNewSmonServer(dialog_id) {
|
|||
newsmonname: $('#new-smon-name').val(),
|
||||
newsmon: $('#new-smon-ip').val(),
|
||||
newsmonport: $('#new-smon-port').val(),
|
||||
newsmonresserver: $('#new-smon-resolver-server').val(),
|
||||
newsmondns_record_type: $('#new-smon-dns_record_type').val(),
|
||||
newsmonenable: enable,
|
||||
newsmonurl: $('#new-smon-url').val(),
|
||||
newsmonbody: $('#new-smon-body').val(),
|
||||
|
@ -100,6 +110,8 @@ function addNewSmonServer(dialog_id) {
|
|||
table_id = 'ajax-smon-ping';
|
||||
} else if (check_type == 'tcp') {
|
||||
table_id = 'ajax-smon-tcp';
|
||||
} else if (check_type == 'dns') {
|
||||
table_id = 'ajax-smon-dns';
|
||||
}
|
||||
else {
|
||||
table_id = 'ajax-smon-http';
|
||||
|
@ -168,6 +180,8 @@ function updateSmon(id, check_type) {
|
|||
data: {
|
||||
updateSmonName: $('#smon-name-'+id).val(),
|
||||
updateSmonIp: $('#smon-ip-'+id).val(),
|
||||
updateSmonResServer: $('#smon-resolver-'+id).val(),
|
||||
updateSmonRecordType: $('#smon-record_type-'+id).val(),
|
||||
updateSmonPort: $('#smon-port-'+id).val(),
|
||||
updateSmonUrl: $('#smon-url-'+id).val(),
|
||||
updateSmonEn: enable,
|
||||
|
@ -208,6 +222,8 @@ function cloneSmom(id, check_type) {
|
|||
$('#new-smon-name').val($('#smon-name-'+id).val());
|
||||
$('#new-smon-ip').val($('#smon-ip-'+id).val());
|
||||
$('#new-smon-port').val($('#smon-port-'+id).val());
|
||||
$('#new-smon-resolver-server').val($('#smon-resolver-'+id).val());
|
||||
$('#new-smon-dns_record_typer').val($('#smon-record_type-'+id).val());
|
||||
$('#new-smon-url').val($('#smon-url-'+id).val());
|
||||
$('#new-smon-group').val($('#smon-group-'+id).val());
|
||||
$('#new-smon-description').val($('#smon-desc-'+id).val())
|
||||
|
@ -231,6 +247,10 @@ $( function() {
|
|||
addSmonServer.dialog('open');
|
||||
check_and_clear_check_type('ping');
|
||||
});
|
||||
$('#add-smon-button-dns').click(function() {
|
||||
addSmonServer.dialog('open');
|
||||
check_and_clear_check_type('dns');
|
||||
});
|
||||
$( "#ajax-smon-http input" ).change(function() {
|
||||
var id = $(this).attr('id').split('-');
|
||||
updateSmon(id[2], 'http');
|
||||
|
@ -255,6 +275,14 @@ $( function() {
|
|||
var id = $(this).attr('id').split('-');
|
||||
updateSmon(id[2], 'ping');
|
||||
});
|
||||
$( "#ajax-smon-dns input" ).change(function() {
|
||||
var id = $(this).attr('id').split('-');
|
||||
updateSmon(id[2], 'dns');
|
||||
});
|
||||
$( "#ajax-smon-dns select" ).on('selectmenuchange',function() {
|
||||
var id = $(this).attr('id').split('-');
|
||||
updateSmon(id[2], 'dns');
|
||||
});
|
||||
$( "#check_type" ).on('selectmenuchange',function() {
|
||||
check_and_clear_check_type($('#check_type').val());
|
||||
});
|
||||
|
@ -292,35 +320,43 @@ $( function() {
|
|||
});
|
||||
function check_and_clear_check_type(check_type) {
|
||||
if (check_type == 'http') {
|
||||
$('.smon_http_check').show();
|
||||
$('.smon_tcp_check').hide();
|
||||
$('.new_smon_hostname').hide();
|
||||
$("#check_type").val('http');
|
||||
$('#check_type').selectmenu("refresh");
|
||||
$('.smon_http_check').show();
|
||||
$('.smon_tcp_check').hide();
|
||||
$('#new-smon-port').val('');
|
||||
$('#new_smon_hostname').val('');
|
||||
clear_check_vals();
|
||||
$('.smon_http_check').show();
|
||||
} else if (check_type == 'tcp') {
|
||||
$('.smon_http_check').hide();
|
||||
$('.smon_tcp_check').show();
|
||||
$("#check_type").val('tcp');
|
||||
$('#check_type').selectmenu("refresh");
|
||||
$('.smon_tcp_check').show();
|
||||
$('.new_smon_hostname').show();
|
||||
$('.smon_http_check').hide();
|
||||
$('#new-smon-url').val('');
|
||||
$('#new-smon-body').val('');
|
||||
$('.smon_dns_check').hide();
|
||||
clear_check_vals();
|
||||
$('.smon_tcp_check').show();
|
||||
} else if (check_type == 'dns') {
|
||||
$("#check_type").val('dns');
|
||||
$('#check_type').selectmenu("refresh");
|
||||
$('.smon_tcp_check').hide();
|
||||
$('.new_smon_hostname').show();
|
||||
$('.smon_http_check').hide();
|
||||
clear_check_vals();
|
||||
$('#new-smon-port').val('53');
|
||||
$('.smon_dns_check').show();
|
||||
} else {
|
||||
$('.smon_http_check').hide();
|
||||
$('.new_smon_hostname').show();
|
||||
$('.smon_tcp_check').hide();
|
||||
$('.smon_dns_check').hide();
|
||||
$("#check_type").val('ping');
|
||||
$('#check_type').selectmenu("refresh");
|
||||
$('.smon_tcp_check').hide();
|
||||
$('.smon_http_check').hide();
|
||||
$('#new-smon-url').val('');
|
||||
$('#new-smon-body').val('');
|
||||
$('#new-smon-port').val('');
|
||||
clear_check_vals();
|
||||
|
||||
}
|
||||
}
|
||||
function clear_check_vals() {
|
||||
$('#new_smon_hostname').val('');
|
||||
$('#new-smon-url').val('');
|
||||
$('#new-smon-body').val('');
|
||||
$('#new-smon-port').val('');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue