diff options
author | Viacheslav <v.gletenko@vyos.io> | 2025-07-07 17:23:03 +0000 |
---|---|---|
committer | Viacheslav <v.gletenko@vyos.io> | 2025-07-07 17:23:03 +0000 |
commit | c3d79b704b327c4605e6a3d65a56e48ade8c6b98 (patch) | |
tree | 0efc4c08e909d714ab59929a2312da4f0e284520 /src | |
parent | fd58e0914d5f16d5c635c808834b9e38f6f3ac38 (diff) | |
download | vyos-1x-c3d79b704b327c4605e6a3d65a56e48ade8c6b98.tar.gz vyos-1x-c3d79b704b327c4605e6a3d65a56e48ade8c6b98.zip |
T7528: Fix service monitoring prometheus stops services
Fix for service monitoring prometheus stops unconfigured services.
Check if the service is in active state before stop it.
Diffstat (limited to 'src')
-rwxr-xr-x | src/conf_mode/service_monitoring_prometheus.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/conf_mode/service_monitoring_prometheus.py b/src/conf_mode/service_monitoring_prometheus.py index f8442c392..b02f9f154 100755 --- a/src/conf_mode/service_monitoring_prometheus.py +++ b/src/conf_mode/service_monitoring_prometheus.py @@ -23,6 +23,7 @@ from vyos.configdict import is_node_changed from vyos.configverify import verify_vrf from vyos.template import render from vyos.utils.process import call +from vyos.utils.process import is_systemd_service_active from vyos import ConfigError from vyos import airbag @@ -173,11 +174,14 @@ def apply(monitoring): # Reload systemd manager configuration call('systemctl daemon-reload') if not monitoring or 'node_exporter' not in monitoring: - call(f'systemctl stop {node_exporter_systemd_service}') + if is_systemd_service_active(node_exporter_systemd_service): + call(f'systemctl stop {node_exporter_systemd_service}') if not monitoring or 'frr_exporter' not in monitoring: - call(f'systemctl stop {frr_exporter_systemd_service}') + if is_systemd_service_active(frr_exporter_systemd_service): + call(f'systemctl stop {frr_exporter_systemd_service}') if not monitoring or 'blackbox_exporter' not in monitoring: - call(f'systemctl stop {blackbox_exporter_systemd_service}') + if is_systemd_service_active(blackbox_exporter_systemd_service): + call(f'systemctl stop {blackbox_exporter_systemd_service}') if not monitoring: return |