mirror of https://github.com/Aidaho12/haproxy-wi
parent
4a83b3696c
commit
940ca0b96d
|
@ -2550,9 +2550,9 @@ def insert_smon_dns(smon_id: int, hostname: str, port: int, resolver: str, recor
|
|||
out_error(e)
|
||||
|
||||
|
||||
def insert_smon_http(smon_id, url, body):
|
||||
def insert_smon_http(smon_id, url, body, http_method):
|
||||
try:
|
||||
SmonHttpCheck.insert(smon_id=smon_id, url=url, body=body).execute()
|
||||
SmonHttpCheck.insert(smon_id=smon_id, url=url, body=body, method=http_method).execute()
|
||||
except Exception as e:
|
||||
out_error(e)
|
||||
|
||||
|
@ -2704,8 +2704,8 @@ def delete_smon(smon_id, user_group):
|
|||
return True
|
||||
|
||||
|
||||
def update_smonHttp(smon_id, url, body):
|
||||
query = (SmonHttpCheck.update(url=url, body=body).where(SmonHttpCheck.smon_id == smon_id))
|
||||
def update_smonHttp(smon_id, url, body, method):
|
||||
query = (SmonHttpCheck.update(url=url, body=body, method=method).where(SmonHttpCheck.smon_id == smon_id))
|
||||
try:
|
||||
query.execute()
|
||||
return True
|
||||
|
|
|
@ -59,7 +59,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.8.0-1'
|
||||
haproxy_ver = '2.8.1-1'
|
||||
|
||||
if proxy is not None and proxy != '' and proxy != 'None':
|
||||
proxy_serv = proxy
|
||||
|
|
|
@ -10,7 +10,8 @@ form = common.form
|
|||
|
||||
|
||||
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:
|
||||
slack: int, pd: int, packet_size: int, check_type: int, resolver: str, record_type: str, user_group: int,
|
||||
http_method: str, show_new=1) -> None:
|
||||
if check_type == 'tcp':
|
||||
try:
|
||||
port = int(port)
|
||||
|
@ -33,7 +34,7 @@ def create_smon(name: str, hostname: str, port: int, enable: int, url: str, body
|
|||
elif check_type == 'tcp':
|
||||
sql.insert_smon_tcp(last_id, hostname, port)
|
||||
elif check_type == 'http':
|
||||
sql.insert_smon_http(last_id, url, body)
|
||||
sql.insert_smon_http(last_id, url, body, http_method)
|
||||
elif check_type == 'dns':
|
||||
sql.insert_smon_dns(last_id, hostname, port, resolver, record_type)
|
||||
|
||||
|
@ -71,6 +72,7 @@ def update_smon() -> None:
|
|||
resolver = common.checkAjaxInput(form.getvalue('updateSmonResServer'))
|
||||
record_type = common.checkAjaxInput(form.getvalue('updateSmonRecordType'))
|
||||
packet_size = common.checkAjaxInput(form.getvalue('updateSmonPacket_size'))
|
||||
http_method = common.checkAjaxInput(form.getvalue('updateSmon_http_method'))
|
||||
is_edited = False
|
||||
|
||||
if check_type == 'tcp':
|
||||
|
@ -88,12 +90,11 @@ def update_smon() -> None:
|
|||
print('SMON error: a packet size cannot be less than 16')
|
||||
return None
|
||||
|
||||
|
||||
roxywi_common.check_user_group()
|
||||
try:
|
||||
if sql.update_smon(smon_id, name, telegram, slack, pd, group, desc, en):
|
||||
if check_type == 'http':
|
||||
is_edited = sql.update_smonHttp(smon_id, url, body)
|
||||
is_edited = sql.update_smonHttp(smon_id, url, body, http_method)
|
||||
elif check_type == 'tcp':
|
||||
is_edited = sql.update_smonTcp(smon_id, ip, port)
|
||||
elif check_type == 'ping':
|
||||
|
|
|
@ -982,8 +982,10 @@ if form.getvalue('newsmonname') is not None:
|
|||
resolver = common.checkAjaxInput(form.getvalue('newsmonresserver'))
|
||||
record_type = common.checkAjaxInput(form.getvalue('newsmondns_record_type'))
|
||||
packet_size = common.checkAjaxInput(form.getvalue('newsmonpacket_size'))
|
||||
http_method = common.checkAjaxInput(form.getvalue('newsmon_http_method'))
|
||||
|
||||
smon_mod.create_smon(name, hostname, port, enable, url, body, group, desc, telegram, slack, pd, packet_size, check_type, resolver, record_type, user_group)
|
||||
smon_mod.create_smon(name, hostname, port, enable, url, body, group, desc, telegram, slack, pd, packet_size,
|
||||
check_type, resolver, record_type, user_group, http_method)
|
||||
|
||||
if form.getvalue('smondel') is not None:
|
||||
import modules.tools.smon as smon_mod
|
||||
|
|
|
@ -9,11 +9,20 @@
|
|||
http_proxy: "{{PROXY}}"
|
||||
https_proxy: "{{PROXY}}"
|
||||
|
||||
- name: Set dist short name if EL
|
||||
set_fact:
|
||||
distr_short_name: "el"
|
||||
when: ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS'
|
||||
|
||||
- name: install HAProxy {{HAPVER}} on EL{{ansible_facts['distribution_major_version']}}
|
||||
- name: Set dist short name if Amazon Linux
|
||||
set_fact:
|
||||
distr_short_name: "amzn"
|
||||
when: ansible_distribution == "Amazon"
|
||||
|
||||
- name: install HAProxy {{HAPVER}} on {{distr_short_name}}{{ansible_facts['distribution_major_version']}}
|
||||
yum:
|
||||
name:
|
||||
- http://repo.roxy-wi.org/haproxy-{{HAPVER}}.el{{ansible_facts['distribution_major_version']}}.x86_64.rpm
|
||||
- http://repo.roxy-wi.org/haproxy/haproxy-{{HAPVER}}.{{distr_short_name}}{{ansible_facts['distribution_major_version']}}.x86_64.rpm
|
||||
- socat
|
||||
- rsyslog
|
||||
state: present
|
||||
|
@ -28,11 +37,10 @@
|
|||
http_proxy: "{{PROXY}}"
|
||||
https_proxy: "{{PROXY}}"
|
||||
|
||||
|
||||
- name: Try to install another HAProxy {{HAPVER}} on EL{{ansible_facts['distribution_major_version']}}
|
||||
- name: Try to install another HAProxy {{HAPVER}} on {{distr_short_name}}{{ansible_facts['distribution_major_version']}}
|
||||
yum:
|
||||
name:
|
||||
- http://repo1.roxy-wi.org/haproxy-{{HAPVER}}.el{{ansible_facts['distribution_major_version']}}.x86_64.rpm
|
||||
- http://repo1.roxy-wi.org/haproxy/haproxy-{{HAPVER}}.{{distr_short_name}}{{ansible_facts['distribution_major_version']}}.x86_64.rpm
|
||||
- socat
|
||||
- rsyslog
|
||||
- bind-utils
|
||||
|
@ -48,10 +56,10 @@
|
|||
https_proxy: "{{PROXY}}"
|
||||
|
||||
|
||||
- name: set_fact from wi`
|
||||
- name: set_fact from wi
|
||||
set_fact:
|
||||
haproxy_from_wi: "yes"
|
||||
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and HAPVER|length > 0
|
||||
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS' or ansible_distribution == 'Amazon') and HAPVER|length > 0
|
||||
|
||||
|
||||
- name: install the latest version of HAProxy
|
||||
|
|
|
@ -18,6 +18,12 @@
|
|||
{% set id = 'smon-body-' + s.id|string() %}
|
||||
{{ input(id, value=s_service.body, size='20') }}
|
||||
</td>
|
||||
<td>
|
||||
{% set id = 'smon-http-method-' + s.id|string() %}
|
||||
{% set http_methods = {'get': 'GET', 'post': 'POST', 'put': 'PUT', 'patch': 'PATCH', 'delete': 'DELETE',
|
||||
'head': 'HEAD', 'options': 'OPTIONS'} %}
|
||||
{{ select(id, values=http_methods, selected=s_service.method) }}
|
||||
</td>
|
||||
<td>
|
||||
<select id="smon-telegram-{{s.id}}">
|
||||
<option value="0">{{lang.words.disabled|title()}}</option>
|
||||
|
|
|
@ -876,5 +876,6 @@
|
|||
"Hostname": "Hostname",
|
||||
"maps": "maps",
|
||||
"map": "map",
|
||||
"method": "method",
|
||||
}
|
||||
%}
|
||||
|
|
|
@ -876,5 +876,6 @@
|
|||
"Hostname": "Nome de anfitrião",
|
||||
"maps": "cartes",
|
||||
"map": "carte",
|
||||
"method": "méthode",
|
||||
}
|
||||
%}
|
||||
|
|
|
@ -876,5 +876,6 @@
|
|||
"Hostname": "Nom d'hôte",
|
||||
"maps": "mapas",
|
||||
"map": "mapa",
|
||||
"method": "método",
|
||||
}
|
||||
%}
|
||||
|
|
|
@ -876,5 +876,6 @@
|
|||
"Hostname": "Имя хоста",
|
||||
"maps": "карты",
|
||||
"map": "карта",
|
||||
"method": "метод",
|
||||
}
|
||||
%}
|
||||
|
|
|
@ -68,9 +68,8 @@
|
|||
</td>
|
||||
<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','2.8.0-1':'2.8.0-1'} %}
|
||||
{{ select('hapver', values=values, selected='2.8.0-1', required='required') }}
|
||||
{% set values = {'2.4.23-1':'2.4.23-1','2.5.14-1':'2.5.14-1', '2.6.14-1':'2.6.14-1','2.7.9-1':'2.7.9-1','2.8.1-1':'2.8.1-1'} %}
|
||||
{{ select('hapver', values=values, selected='2.8.1-1', required='required') }}
|
||||
</td>
|
||||
<td class="padding10 first-collumn">
|
||||
<select autofocus required name="haproxyaddserv" id="haproxyaddserv">
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
<th style="width: 15%;">URL</th>
|
||||
<th style="width: 5%;">{{lang.words.enabled|title()}}</th>
|
||||
<th style="width: 20%;">{{lang.words.body|title()}}</th>
|
||||
<th style="width: 20%;">HTTP {{lang.words.method}}</th>
|
||||
<th style="width: 11%;">Telegram</th>
|
||||
<th style="width: 11%;">Slack</th>
|
||||
<th style="width: 11%;">PagerDuty</th>
|
||||
|
@ -254,6 +255,14 @@
|
|||
<td class="padding20">{{lang.words.body|title()}}</td>
|
||||
<td>{{ input('new-smon-body') }}</td>
|
||||
</tr>
|
||||
<tr class="smon_http_check">
|
||||
<td class="padding20">HTTP {{lang.words.method}}</td>
|
||||
<td>
|
||||
{% set http_methods = {'get': 'GET', 'post': 'POST', 'put': 'PUT', 'patch': 'PATCH', 'delete': 'DELETE',
|
||||
'head': 'HEAD', 'options': 'OPTIONS'} %}
|
||||
{{ select('new-smon-method', values=http_methods, selected='get') }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding20">{{lang.words.enable|title()}}</td>
|
||||
<td>
|
||||
|
|
|
@ -99,6 +99,7 @@ function addNewSmonServer(dialog_id) {
|
|||
newsmonslack: $('#new-smon-slack').val(),
|
||||
newsmonpd: $('#new-smon-pd').val(),
|
||||
newsmonpacket_size: $('#new-smon-packet_size').val(),
|
||||
newsmon_http_method: $('#new-smon-method').val(),
|
||||
newsmonchecktype: check_type,
|
||||
token: $('#token').val()
|
||||
},
|
||||
|
@ -194,6 +195,7 @@ function updateSmon(id, check_type) {
|
|||
updateSmonGroup: $('#smon-group-'+id).val(),
|
||||
updateSmonDesc: $('#smon-desc-'+id).val(),
|
||||
updateSmonPacket_size: $('#smon-packet_size-'+id).val(),
|
||||
updateSmon_http_method: $('#smon-http_method-'+id).val(),
|
||||
check_type: check_type,
|
||||
id: id,
|
||||
token: $('#token').val()
|
||||
|
|
Loading…
Reference in New Issue