Skip to content

Commit

Permalink
🐞 sysmonitor: Skip error logging of inactive srvs
Browse files Browse the repository at this point in the history
Signed-off-by: Yevhen Fastiuk <[email protected]>
  • Loading branch information
fastiuk committed May 20, 2024
1 parent 39d1e8d commit de110cf
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/system-health/health_checker/sysmonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down

0 comments on commit de110cf

Please sign in to comment.