From f57b418d747d3e2ceaa5fea17e05418707563718 Mon Sep 17 00:00:00 2001 From: Aidaho Date: Thu, 21 Mar 2024 09:04:37 +0300 Subject: [PATCH] v7.2.2.0 Fix tools status showing for Docker --- app/modules/tools/common.py | 2 +- app/templates/ajax/load_services.html | 53 ++++++++++++----------- app/templates/ajax/show_services_ovw.html | 19 ++++---- inc/metrics.js | 2 +- 4 files changed, 39 insertions(+), 37 deletions(-) diff --git a/app/modules/tools/common.py b/app/modules/tools/common.py index 112f24fa..36722ea7 100644 --- a/app/modules/tools/common.py +++ b/app/modules/tools/common.py @@ -61,7 +61,7 @@ def update_roxy_wi(service: str) -> str: def is_tool_active(tool_name: str) -> str: is_in_docker = roxywi_mod.is_docker() if is_in_docker: - cmd = f"supervisorctl status {tool_name}|awk '{{print $2}}'" + cmd = f"sudo supervisorctl status {tool_name}|awk '{{print $2}}'" else: cmd = f"systemctl is-active {tool_name}" status, stderr = server_mod.subprocess_execute(cmd) diff --git a/app/templates/ajax/load_services.html b/app/templates/ajax/load_services.html index 01a89754..3e73ac52 100644 --- a/app/templates/ajax/load_services.html +++ b/app/templates/ajax/load_services.html @@ -13,60 +13,61 @@ 'rabbitmq-server': { 'name': 'RabbitMQ', 'desc': 'RabbitMQ server' }, } %} -{% for s in services %} +{% for service in services %} {% set is_service_started_class = '' %} {% set is_service_stopped_class = '' %} -{% set onclick_start_action = "confirmAjaxServiceAction('start', '"+s.0+"')" %} -{% set onclick_stop_action = "confirmAjaxServiceAction('stop', '"+s.0+"')" %} -{% set is_service_started_title = lang.words.start|title()+" "+lang.words.and+" "+lang.words.enable+" "+services_name[s.0]['name']+" "+lang.words.service %} -{% set is_service_stopped_title = lang.words.stop|title()+" "+lang.words.and+" "+lang.words.disable+" "+services_name[s.0]['name']+" "+lang.words.service %} - +{% set onclick_start_action = "confirmAjaxServiceAction('start', '"+service.0+"')" %} +{% set onclick_stop_action = "confirmAjaxServiceAction('stop', '"+service.0+"')" %} +{% set is_service_started_title = lang.words.start|title()+" "+lang.words.and+" "+lang.words.enable+" "+services_name[service.0]['name']+" "+lang.words.service %} +{% set is_service_stopped_title = lang.words.stop|title()+" "+lang.words.and+" "+lang.words.disable+" "+services_name[service.0]['name']+" "+lang.words.service %} + - {% if s.1 == 'active' or s.1 == 'RUNNING' %} - + {{ service }} + {% if service.1 == 'active' or service.1 == 'RUNNING' %} + {% set is_service_started_class = 'disabled-button' %} {% set onclick_start_action = "" %} - {% set is_service_started_title = lang.words.service|title()+" "+services_name[s.0]['name']+" "+lang.words.already+" "+lang.words.started %} + {% set is_service_started_title = lang.words.service|title()+" "+services_name[service.0]['name']+" "+lang.words.already+" "+lang.words.started %} {% else %} - {% if (s.1 == 'inactive' or s.1 == 'failed' or s.1 == 'activating' or s.1 == 'STOPPED') and 'is not installed' not in s.2['current_version'] %} - + {% if (service.1 == 'inactive' or service.1 == 'failed' or service.1 == 'activating' or service.1 == 'STOPPED') and 'is not installed' not in service.2['current_version'] %} + {% set is_service_stopped_class = 'disabled-button' %} {% set onclick_stop_action = "" %} - {% set is_service_stopped_title = lang.words.service|title()+" "+services_name[s.0]['name']+" "+lang.words.already+" "+lang.words.stopped %} + {% set is_service_stopped_title = lang.words.service|title()+" "+services_name[service.0]['name']+" "+lang.words.already+" "+lang.words.stopped %} {% else %} - + {% endif %} {% endif %} - {{services_name[s.0]['name']}} + {{services_name[service.0]['name']}} - {% if 'is not installed' in s.2['current_version'] or not s.2['current_version'] or s.2['current_version'] == '0' %} - {% if s.0 in ('prometheus', 'grafana-server') %} + {% if 'is not installed' in service.2['current_version'] or not service.2['current_version'] or service.2['current_version'] == '0' %} + {% if service.0 in ('prometheus', 'grafana-server') %} {{lang.words.install|title()}} - {% elif s.0 in ('rabbitmq-server', 'fail2ban') %} - {{lang.words.install|title()}} + {% elif service.0 in ('rabbitmq-server', 'fail2ban') %} + {{lang.words.install|title()}} {% else %} - {{lang.words.install|title()}} + {{lang.words.install|title()}} {% endif %} {% else %} - + - - + + - + {% endif %} - {% if 'is not installed' not in s.2['current_version'] %} - {{s.2['current_version']}} + {% if 'is not installed' not in service.2['current_version'] %} + {{service.2['current_version']}} {% endif %} - {{ services_name[s.0]['desc'] | safe }} + {{ services_name[service.0]['desc'] | safe }} {% endfor %} diff --git a/app/templates/ajax/show_services_ovw.html b/app/templates/ajax/show_services_ovw.html index 0b38fcba..7a8d7117 100644 --- a/app/templates/ajax/show_services_ovw.html +++ b/app/templates/ajax/show_services_ovw.html @@ -1,7 +1,8 @@ {% import 'languages/'+lang|default('en')+'.html' as lang %} - {% if roxy_tools_status['roxy-wi-metrics'] == 'active' %} + {{ roxy_tools_status }} + {% if roxy_tools_status['roxy-wi-metrics'] == 'active' or roxy_tools_status['roxy-wi-metrics'] == 'RUNNING' %} {% if role <= 1 %} @@ -11,7 +12,7 @@ Metrics master {% endif %} {% else %} - {% if roxy_tools_status['roxy-wi-metrics'] == 'inactive' or roxy_tools_status['roxy-wi-metrics'] == 'failed' %} + {% if roxy_tools_status['roxy-wi-metrics'] == 'inactive' or roxy_tools_status['roxy-wi-metrics'] == 'failed' or roxy_tools_status['roxy-wi-metrics'] == 'ERROR' %} {% if role <= 1 %} @@ -29,7 +30,7 @@ {% endif %} - {% if roxy_tools_status['roxy-wi-checker'] == 'active' %} + {% if roxy_tools_status['roxy-wi-checker'] == 'active' or roxy_tools_status['roxy-wi-checker'] == 'RUNNING' %} {% if role <= 1 %} @@ -57,7 +58,7 @@ {% endif %} - {% if roxy_tools_status['roxy-wi-keep_alive'] == 'active' %} + {% if roxy_tools_status['roxy-wi-keep_alive'] == 'active' or roxy_tools_status['roxy-wi-keep_alive'] == 'RUNNING' %} {% if role <= 1 %} @@ -67,7 +68,7 @@ Auto star {% endif %} {% else %} - {% if roxy_tools_status['roxy-wi-keep_alive'] == 'inactive' or roxy_tools_status['roxy-wi-keep_alive'] == 'failed' %} + {% if roxy_tools_status['roxy-wi-keep_alive'] == 'inactive' or roxy_tools_status['roxy-wi-keep_alive'] == 'failed' or roxy_tools_status['roxy-wi-keep_alive'] == 'ERROR' %} {% if role <= 1 %} @@ -156,7 +157,7 @@ {% endif %} - {% if roxy_tools_status['roxy-wi-socket'] == 'active' %} + {% if roxy_tools_status['roxy-wi-socket'] == 'active' or roxy_tools_status['roxy-wi-socket'] == 'RUNNING' %} {% if role <= 1 %} @@ -166,7 +167,7 @@ Socket service {% endif %} {% else %} - {% if roxy_tools_status['roxy-wi-socket'] == 'inactive' or roxy_tools_status['roxy-wi-socket'] == 'failed' %} + {% if roxy_tools_status['roxy-wi-socket'] == 'inactive' or roxy_tools_status['roxy-wi-socket'] == 'failed' or roxy_tools_status['roxy-wi-socket'] == 'ERROR' %} Socket service @@ -180,13 +181,13 @@ {% endif %} - {% if roxy_tools_status['roxy-wi-portscanner'] == 'active' %} + {% if roxy_tools_status['roxy-wi-portscanner'] == 'active' or roxy_tools_status['roxy-wi-portscanner'] == 'RUNNING' %} Port scanner {% else %} - {% if roxy_tools_status['roxy-wi-portscanner'] == 'inactive' or roxy_tools_status['roxy-wi-portscanner'] == 'failed' %} + {% if roxy_tools_status['roxy-wi-portscanner'] == 'inactive' or roxy_tools_status['roxy-wi-portscanner'] == 'failed' or roxy_tools_status['roxy-wi-portscanner'] == 'ERROR' %} Port scanner diff --git a/inc/metrics.js b/inc/metrics.js index c79dc910..81fc7ab4 100644 --- a/inc/metrics.js +++ b/inc/metrics.js @@ -574,4 +574,4 @@ function updatingCpuRamCharts() { } else { removeData(); } -}Œ +}