diff --git a/app/roxy-wi.cfg b/app/roxy-wi.cfg index bfba22c4..3cebad2b 100644 --- a/app/roxy-wi.cfg +++ b/app/roxy-wi.cfg @@ -1,13 +1,14 @@ [main] # Path to the files destination fullpath = /var/www/haproxy-wi -log_path = ${fullpath}/log/ +log_path = ${fullpath}/log/ [configs] # Folders for configs haproxy_save_configs_dir = ${main:fullpath}/configs/hap_config/ kp_save_configs_dir = ${main:fullpath}/configs/kp_config/ nginx_save_configs_dir = ${main:fullpath}/configs/nginx_config/ +apache_save_configs_dir = ${main:fullpath}/configs/apache_config/ [mysql] # By default Sqlite DB is used diff --git a/app/sql.py b/app/sql.py index 87f91f1e..ae3213b5 100644 --- a/app/sql.py +++ b/app/sql.py @@ -278,6 +278,9 @@ def update_hapwi_server(server_id, alert, metrics, active, service_name): elif service_name == 'keepalived': update_hapwi = Server.update(keepalived_alert=alert, keepalived_active=active).where( Server.server_id == server_id) + elif service_name == 'apache': + update_hapwi = Server.update(apache_alert=alert).where( + Server.server_id == server_id) else: update_hapwi = Server.update(alert=alert, metrics=metrics, active=active).where( Server.server_id == server_id) @@ -1888,6 +1891,22 @@ def select_nginx_alert(**kwargs): return query_res +def select_apache_alert(**kwargs): + if kwargs.get("group") is not None: + query = Server.select(Server.ip).where( + (Server.apache_alert == 1) & + (Server.enable == 1) & + (Server.groups == kwargs.get('group'))) + else: + query = Server.select(Server.ip).where((Server.apache_alert == 1) & (Server.enable == 1)) + try: + query_res = query.execute() + except Exception as e: + out_error(e) + else: + return query_res + + def select_keepalived_alert(**kwargs): if kwargs.get("group") is not None: query = Server.select(Server.ip).where(