From 49202813e2cf81cfbe9632ed1064ffb70e7ebb8e Mon Sep 17 00:00:00 2001 From: Aidaho Date: Thu, 3 Aug 2023 22:33:44 +0300 Subject: [PATCH] v6.3.17.0 Changelog: https://roxy-wi.org/changelog#6_3_17 --- app/modules/tools/checker.py | 55 ++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/app/modules/tools/checker.py b/app/modules/tools/checker.py index e5b4549..211a298 100644 --- a/app/modules/tools/checker.py +++ b/app/modules/tools/checker.py @@ -1,11 +1,15 @@ from jinja2 import Environment, FileSystemLoader import modules.db.sql as sql -import modules.roxywi.common as roxywi_common +import modules.common.common as common import modules.roxywi.roxy as roxywi_mod +import modules.roxywi.common as roxywi_common + +form = common.form -def load_checker(page: str) -> None: +def load_checker() -> None: + page = form.getvalue('page') groups = sql.select_groups() services = roxywi_mod.get_services_status() lang = roxywi_common.get_user_lang() @@ -58,3 +62,50 @@ def load_checker(page: str) -> None: keepalived_servers=keepalived_servers, haproxy_settings=haproxy_settings, nginx_settings=nginx_settings, keepalived_settings=keepalived_settings, apache_settings=apache_settings, page=page, lang=lang) print(template) + + +def update_haproxy_settings() -> None: + setting_id = int(form.getvalue('updateHaproxyCheckerSettings')) + email = int(form.getvalue('email')) + service_alert = int(form.getvalue('server')) + backend_alert = int(form.getvalue('backend')) + maxconn_alert = int(form.getvalue('maxconn')) + telegram_id = int(form.getvalue('telegram_id')) + slack_id = int(form.getvalue('slack_id')) + pd_id = int(form.getvalue('pd_id')) + + if sql.update_haproxy_checker_settings(email, telegram_id, slack_id, pd_id, service_alert, backend_alert, + maxconn_alert, setting_id): + print('ok') + else: + print('error: Cannot update Checker settings') + + +def update_keepalived_settings() -> None: + setting_id = int(form.getvalue('updateKeepalivedCheckerSettings')) + email = int(form.getvalue('email')) + service_alert = int(form.getvalue('server')) + backend_alert = int(form.getvalue('backend')) + telegram_id = int(form.getvalue('telegram_id')) + slack_id = int(form.getvalue('slack_id')) + pd_id = int(form.getvalue('pd_id')) + + if sql.update_keepalived_checker_settings(email, telegram_id, slack_id, pd_id, service_alert, backend_alert, + setting_id): + print('ok') + else: + print('error: Cannot update Checker settings') + + +def update_service_settings() -> None: + setting_id = int(form.getvalue('updateServiceCheckerSettings')) + email = int(form.getvalue('email')) + service_alert = int(form.getvalue('server')) + telegram_id = int(form.getvalue('telegram_id')) + slack_id = int(form.getvalue('slack_id')) + pd_id = int(form.getvalue('pd_id')) + + if sql.update_service_checker_settings(email, telegram_id, slack_id, pd_id, service_alert, setting_id): + print('ok') + else: + print('error: Cannot update Checker settings')