diff --git a/app/create_db.py b/app/create_db.py
index 1bd51d4d..9588d06b 100644
--- a/app/create_db.py
+++ b/app/create_db.py
@@ -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')
diff --git a/app/modules/db/db_model.py b/app/modules/db/db_model.py
index 6486580b..3ad80665 100644
--- a/app/modules/db/db_model.py
+++ b/app/modules/db/db_model.py
@@ -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])
diff --git a/app/modules/db/sql.py b/app/modules/db/sql.py
index 8a98e6ae..ae9950a6 100755
--- a/app/modules/db/sql.py
+++ b/app/modules/db/sql.py
@@ -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(
diff --git a/app/modules/service/installation.py b/app/modules/service/installation.py
index c4998683..86deb4a6 100644
--- a/app/modules/service/installation.py
+++ b/app/modules/service/installation.py
@@ -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
diff --git a/app/modules/tools/smon.py b/app/modules/tools/smon.py
index 1949a2b2..a86f2afc 100644
--- a/app/modules/tools/smon.py
+++ b/app/modules/tools/smon.py
@@ -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")
diff --git a/app/smon.py b/app/smon.py
index edd40c16..e5e41005 100644
--- a/app/smon.py
+++ b/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)
diff --git a/app/templates/ajax/show_new_smon.html b/app/templates/ajax/show_new_smon.html
index 6e2376f8..5d88f658 100644
--- a/app/templates/ajax/show_new_smon.html
+++ b/app/templates/ajax/show_new_smon.html
@@ -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 %}
@@ -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 %}
diff --git a/app/templates/ajax/smon_dashboard.html b/app/templates/ajax/smon_dashboard.html
index 84947db4..bcf2095d 100644
--- a/app/templates/ajax/smon_dashboard.html
+++ b/app/templates/ajax/smon_dashboard.html
@@ -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 @@
{% else %}
- {{lang.smon_page.desc.PORT_DOWN}}
+ {{lang.smon_page.desc.DOWN}}
{% endif %}
{% else %}
diff --git a/app/templates/include/smon_dns_server.html b/app/templates/include/smon_dns_server.html
new file mode 100644
index 00000000..37a0b1ae
--- /dev/null
+++ b/app/templates/include/smon_dns_server.html
@@ -0,0 +1,105 @@
+
+ {% set id = 'smon-name-' + s.id|string() %}
+ {{ input(id, value=s.name.strip("'"), size='20') }}
+ |
+
+ {% set id = 'smon-ip-' + s.id|string() %}
+ {{ input(id, value=s_service.ip, size='20') }}
+ |
+
+ {% set id = 'smon-resolver-' + s.id|string() %}
+ {{ input(id, value=s_service.resolver, size='20') }}
+ |
+
+ {% set id = 'smon-port-' + s.id|string() %}
+ {{ input(id, value=s_service.port, size='5') }}
+ |
+
+ {% 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) }}
+ |
+
+ {% set id = 'smon-enable-' + s.id|string() %}
+ {% if s.en == 1 %}
+ {{ checkbox(id, checked='checked') }}
+ {% else %}
+ {{ checkbox(id) }}
+ {% endif %}
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+ {% 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 %}
+ |
+
+ {% 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 %}
+ |
+
+
+ |
+
+
+ |
+
+
diff --git a/app/templates/include/smon_history.html b/app/templates/include/smon_history.html
index e133b4c7..bbaa982e 100644
--- a/app/templates/include/smon_history.html
+++ b/app/templates/include/smon_history.html
@@ -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) %}
+
{% if check_id == 2 %}
-
+
{{s.url}}
{% elif check_id == 1 %}
-
{{s.ip}}:{{s.port}}
+ {{s.ip}}:{{s.port}}
+ {% elif check_id == 5 %}
+ {{s.ip}} {{lang.phrases.resource_record_type}}: {{s.record_type|upper()}}
{% else %}
-
{{s.smon_id.name}}
+ {{s.smon_id.name}}
{% endif %}
+
{% endfor %}
@@ -37,18 +41,18 @@
{{lang.words.checking|title()}} {{lang.words.every}} {{check_interval}} {{lang.words.minutes2}}
- {% 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 %}
{{status}}
diff --git a/app/templates/include/smon_tcp_server.html b/app/templates/include/smon_tcp_server.html
index 89c54b32..e9e15dff 100644
--- a/app/templates/include/smon_tcp_server.html
+++ b/app/templates/include/smon_tcp_server.html
@@ -88,8 +88,5 @@
$("#smon-pd-{{s.id}}" ).selectmenu({
width: 160
});
- $("#smon-proto-{{s.id}}" ).selectmenu({
- width: 78
- });
});
diff --git a/app/templates/languages/en.html b/app/templates/languages/en.html
index 6bdebbfa..fa775563 100644
--- a/app/templates/languages/en.html
+++ b/app/templates/languages/en.html
@@ -319,6 +319,7 @@
"ReqPerSec": "ReqPerSec",
"BytesPerSec": "BytesPerSec",
"became_master": "Became Master",
+ "resource_record_type": "Resource Record Type",
}
%}
{% set roles = {
diff --git a/app/templates/languages/fr.html b/app/templates/languages/fr.html
index ab19c52c..fc6edef5 100644
--- a/app/templates/languages/fr.html
+++ b/app/templates/languages/fr.html
@@ -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 = {
diff --git a/app/templates/languages/pt-br.html b/app/templates/languages/pt-br.html
index b8d671e0..6bc7b5b6 100644
--- a/app/templates/languages/pt-br.html
+++ b/app/templates/languages/pt-br.html
@@ -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 = {
diff --git a/app/templates/languages/ru.html b/app/templates/languages/ru.html
index 2041911b..784a7a3f 100644
--- a/app/templates/languages/ru.html
+++ b/app/templates/languages/ru.html
@@ -319,6 +319,7 @@
"ReqPerSec": "Запросов в секунду",
"BytesPerSec": "Байт в секунду",
"became_master": "Стал мастером",
+ "resource_record_type": "Тип записи ресурса",
}
%}
{% set roles = {
diff --git a/app/templates/servers.html b/app/templates/servers.html
index 41e5c685..2253c057 100644
--- a/app/templates/servers.html
+++ b/app/templates/servers.html
@@ -68,8 +68,8 @@
{% 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') }}
|
|
- {% 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') }}
|
@@ -181,7 +215,16 @@
{{ input('new-smon-ip') }}
-
+
+
+ Resolver {{lang.words.server}}
+ *
+ |
+
+ {{ input('new-smon-resolver-server', value='8.8.8.8') }}
+ |
+
+
{{lang.words.port|title()}}
*
@@ -190,19 +233,33 @@
{{ input('new-smon-port', type='number', size='4') }}
|
+
+
+ URL
+ *
+ |
+ {{ input('new-smon-url', value='https://', title='proto://url[:port]/') }} |
+
+
+ {{lang.words.body|title()}} |
+ {{ input('new-smon-body') }} |
+
{{lang.words.enable|title()}} |
{{ checkbox('new-smon-enable', checked='checked') }}
|
-
- URL |
- {{ input('new-smon-url', value='https://', title='proto://url[:port]/') }} |
-
-
- {{lang.words.body|title()}} |
- {{ input('new-smon-body') }} |
+
+
+ {{lang.phrases.resource_record_type}}
+ *
+ |
+
+ {% 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') }}
+ |
Telegram |
diff --git a/inc/smon-6.3.13.js b/inc/smon-6.3.13.js
index e35a9489..1396f976 100644
--- a/inc/smon-6.3.13.js
+++ b/inc/smon-6.3.13.js
@@ -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('');
+}