From de110cf5e14cffd1aabc116e3184472171712a4b Mon Sep 17 00:00:00 2001 From: Yevhen Fastiuk Date: Sat, 15 Jul 2023 22:48:41 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20sysmonitor:=20Skip=20error=20log?= =?UTF-8?q?ging=20of=20inactive=20srvs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yevhen Fastiuk --- .../health_checker/sysmonitor.py | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/system-health/health_checker/sysmonitor.py b/src/system-health/health_checker/sysmonitor.py index d6f15c042437..3f310a1ac36d 100755 --- a/src/system-health/health_checker/sysmonitor.py +++ b/src/system-health/health_checker/sysmonitor.py @@ -455,13 +455,26 @@ def post_unit_status(self, srv_name, srv_status, app_status, fail_reason, update self.state_db = swsscommon.SonicV2Connector(use_unix_socket_path=True) self.state_db.connect(self.state_db.STATE_DB) - if srv_status == "OK": - logger.log_notice("{} service status: {}, app status: {}" - "".format(srv_name, srv_status, app_status)) - else: - logger.log_error("{} service status: {}, app status: {}, fail " - "reason: {}".format(srv_name, srv_status, - app_status, fail_reason)) + # Log message with proper level + logf = logger.log_notice + msg = f'{srv_name} service status: {srv_status}, ' + msg += f'app status: {app_status}' + + if srv_status != 'OK': + msg += f', fail reason: {fail_reason}' + + # So far good down reasons for each service status + good_dr = { + 'Down': ['Inactive'], + 'Starting': ['-'], + 'Stopping': ['-'] + } + + # Only allowed combinations + if fail_reason not in good_dr.get(srv_status, []): + logf = logger.log_error + + logf(msg) key = 'ALL_SERVICE_STATUS|{}'.format(srv_name) statusvalue = {}