mirror of https://github.com/Aidaho12/haproxy-wi
parent
ec6db8265c
commit
3bcd2a5077
|
@ -222,7 +222,7 @@ def haproxy_section_add(haproxy_id):
|
||||||
|
|
||||||
@route('/haproxy/<haproxy_id>/section/delete', method=['POST'])
|
@route('/haproxy/<haproxy_id>/section/delete', method=['POST'])
|
||||||
@route('/haproxy/<haproxy_id:int>/section/delete', method=['POST'])
|
@route('/haproxy/<haproxy_id:int>/section/delete', method=['POST'])
|
||||||
def haproxy_section_add(haproxy_id):
|
def haproxy_section_delete(haproxy_id):
|
||||||
if not check_login(required_service=1):
|
if not check_login(required_service=1):
|
||||||
return dict(error=_error_auth)
|
return dict(error=_error_auth)
|
||||||
return api_funct.edit_section(haproxy_id, delete=1)
|
return api_funct.edit_section(haproxy_id, delete=1)
|
||||||
|
|
|
@ -124,8 +124,9 @@ def action_haproxy_waf(server_ip: str, action: str) -> str:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return str(e)
|
return str(e)
|
||||||
|
|
||||||
roxywi_common.logging(server_ip, f'HAProxy WAF service has been {action}ed', roxywi=1, login=1, keep_history=1,
|
roxywi_common.logging(
|
||||||
service='haproxy')
|
server_ip, f'HAProxy WAF service has been {action}ed', roxywi=1, login=1, keep_history=1, service='haproxy'
|
||||||
|
)
|
||||||
commands = [f"sudo systemctl {action} waf"]
|
commands = [f"sudo systemctl {action} waf"]
|
||||||
server_mod.ssh_command(server_ip, commands)
|
server_mod.ssh_command(server_ip, commands)
|
||||||
return f"success: WAF has been {action}"
|
return f"success: WAF has been {action}"
|
||||||
|
|
|
@ -227,7 +227,7 @@ def install_service(server_ip: str, service: str, docker: str, syn_flood_protect
|
||||||
show_installation_output(return_out['error'], return_out['output'], service_name, rc=return_out['rc'])
|
show_installation_output(return_out['error'], return_out['output'], service_name, rc=return_out['rc'])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise Exception(e)
|
raise Exception(e)
|
||||||
|
|
||||||
if service == 'nginx':
|
if service == 'nginx':
|
||||||
try:
|
try:
|
||||||
sql.update_nginx(server_ip)
|
sql.update_nginx(server_ip)
|
||||||
|
@ -322,8 +322,10 @@ def grafana_install():
|
||||||
return f'success: Grafana and Prometheus servers were installed. You can find Grafana on http://{host}:3000<br>'
|
return f'success: Grafana and Prometheus servers were installed. You can find Grafana on http://{host}:3000<br>'
|
||||||
|
|
||||||
|
|
||||||
def keepalived_master_install(master: str, eth: str, eth_slave: str, vrrp_ip: str, virt_server: int, syn_flood: int,
|
def keepalived_master_install(
|
||||||
return_to_master: int, haproxy: int, nginx: int, router_id: int, api=0) -> str:
|
master: str, eth: str, eth_slave: str, vrrp_ip: str, virt_server: int, syn_flood: int, return_to_master: int,
|
||||||
|
haproxy: int, nginx: int, router_id: int, api=0
|
||||||
|
) -> str:
|
||||||
script = "install_keepalived.sh"
|
script = "install_keepalived.sh"
|
||||||
proxy = sql.get_setting('proxy')
|
proxy = sql.get_setting('proxy')
|
||||||
keepalived_path_logs = sql.get_setting('keepalived_path_logs')
|
keepalived_path_logs = sql.get_setting('keepalived_path_logs')
|
||||||
|
@ -373,8 +375,9 @@ def keepalived_master_install(master: str, eth: str, eth_slave: str, vrrp_ip: st
|
||||||
return show_success_installation(service)
|
return show_success_installation(service)
|
||||||
|
|
||||||
|
|
||||||
def keepalived_slave_install(master: str, slave: str, eth: str, eth_slave: str, vrrp_ip: str, syn_flood: int,
|
def keepalived_slave_install(
|
||||||
haproxy: int, nginx: int, router_id: int, api=0) -> str:
|
master: str, slave: str, eth: str, eth_slave: str, vrrp_ip: str, syn_flood: int, haproxy: int, nginx: int, router_id: int, api=0
|
||||||
|
) -> str:
|
||||||
script = "install_keepalived.sh"
|
script = "install_keepalived.sh"
|
||||||
proxy = sql.get_setting('proxy')
|
proxy = sql.get_setting('proxy')
|
||||||
keepalived_path_logs = sql.get_setting('keepalived_path_logs')
|
keepalived_path_logs = sql.get_setting('keepalived_path_logs')
|
||||||
|
|
|
@ -173,6 +173,7 @@ def telegram_send_mess(mess, level, **kwargs):
|
||||||
try:
|
try:
|
||||||
bot = telebot.TeleBot(token=token_bot)
|
bot = telebot.TeleBot(token=token_bot)
|
||||||
bot.send_message(chat_id=channel_name, text=f'{level}: {mess}')
|
bot.send_message(chat_id=channel_name, text=f'{level}: {mess}')
|
||||||
|
return 'ok'
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
roxywi_common.logging('Roxy-WI server', str(e), roxywi=1)
|
roxywi_common.logging('Roxy-WI server', str(e), roxywi=1)
|
||||||
raise Exception(f'error: {e}')
|
raise Exception(f'error: {e}')
|
||||||
|
@ -206,6 +207,7 @@ def slack_send_mess(mess, level, **kwargs):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
client.chat_postMessage(channel=f'#{channel_name}', text=f'{level}: {mess}')
|
client.chat_postMessage(channel=f'#{channel_name}', text=f'{level}: {mess}')
|
||||||
|
return 'ok'
|
||||||
except SlackApiError as e:
|
except SlackApiError as e:
|
||||||
roxywi_common.logging('Roxy-WI server', str(e), roxywi=1)
|
roxywi_common.logging('Roxy-WI server', str(e), roxywi=1)
|
||||||
raise Exception(f'error: {e}')
|
raise Exception(f'error: {e}')
|
||||||
|
@ -250,6 +252,7 @@ def pd_send_mess(mess, level, server_ip=None, service_id=None, alert_type=None,
|
||||||
session.resolve(dedup_key)
|
session.resolve(dedup_key)
|
||||||
else:
|
else:
|
||||||
session.trigger(mess, 'Roxy-WI', dedup_key=dedup_key, severity=level, custom_details={'server': server_ip, 'alert': mess})
|
session.trigger(mess, 'Roxy-WI', dedup_key=dedup_key, severity=level, custom_details={'server': server_ip, 'alert': mess})
|
||||||
|
return 'ok'
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
roxywi_common.logging('Roxy-WI server', str(e), roxywi=1)
|
roxywi_common.logging('Roxy-WI server', str(e), roxywi=1)
|
||||||
raise Exception(f'error: {e}')
|
raise Exception(f'error: {e}')
|
||||||
|
|
|
@ -28,7 +28,6 @@ def load_checker() -> None:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
user_params = roxywi_common.get_users_params()
|
user_params = roxywi_common.get_users_params()
|
||||||
user = user_params['user']
|
|
||||||
except Exception:
|
except Exception:
|
||||||
return redirect(url_for('login_page'))
|
return redirect(url_for('login_page'))
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ def receiver(receiver_name):
|
||||||
group = common.checkAjaxInput(request.form.get('group'))
|
group = common.checkAjaxInput(request.form.get('group'))
|
||||||
page = common.checkAjaxInput(request.form.get('page'))
|
page = common.checkAjaxInput(request.form.get('page'))
|
||||||
page = page.split("#")[0]
|
page = page.split("#")[0]
|
||||||
|
|
||||||
return alerting.add_receiver_channel(receiver_name, token, channel, group, page)
|
return alerting.add_receiver_channel(receiver_name, token, channel, group, page)
|
||||||
elif request.method == 'PUT':
|
elif request.method == 'PUT':
|
||||||
token = common.checkAjaxInput(request.form.get('receiver_token'))
|
token = common.checkAjaxInput(request.form.get('receiver_token'))
|
||||||
|
|
|
@ -192,6 +192,7 @@ def versions(service, server_ip):
|
||||||
if 'No such file or directory' in str(e):
|
if 'No such file or directory' in str(e):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
configs_dir = get_config.get_config_var('configs', f'{service}_save_configs_dir')
|
||||||
os.remove(os.path.join(configs_dir, get))
|
os.remove(os.path.join(configs_dir, get))
|
||||||
try:
|
try:
|
||||||
file.add(get + "\n")
|
file.add(get + "\n")
|
||||||
|
|
|
@ -175,6 +175,7 @@ def get_list(server_ip, list_id, list_name):
|
||||||
def delete_ip_from_list():
|
def delete_ip_from_list():
|
||||||
ip_id = common.checkAjaxInput(request.form.get('list_ip_id_for_delete'))
|
ip_id = common.checkAjaxInput(request.form.get('list_ip_id_for_delete'))
|
||||||
ip = common.is_ip_or_dns(request.form.get('list_ip_for_delete'))
|
ip = common.is_ip_or_dns(request.form.get('list_ip_for_delete'))
|
||||||
|
serv = common.is_ip_or_dns(request.form.get('serv'))
|
||||||
list_id = common.checkAjaxInput(request.form.get('list_id_for_delete'))
|
list_id = common.checkAjaxInput(request.form.get('list_id_for_delete'))
|
||||||
list_name = common.checkAjaxInput(request.form.get('list_name'))
|
list_name = common.checkAjaxInput(request.form.get('list_name'))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue