From 341108eca138f26a8a3cc3b728fa783858d98f7b Mon Sep 17 00:00:00 2001 From: Vivek Reddy Karri Date: Fri, 21 Apr 2023 01:31:18 +0000 Subject: [PATCH 1/3] [health] Start system-health after interfaces-config Signed-off-by: Vivek Reddy Karri --- files/image_config/system-health/system-health.service | 1 + 1 file changed, 1 insertion(+) diff --git a/files/image_config/system-health/system-health.service b/files/image_config/system-health/system-health.service index 3de6a51584cb..0d1a40e2ba98 100644 --- a/files/image_config/system-health/system-health.service +++ b/files/image_config/system-health/system-health.service @@ -2,6 +2,7 @@ Description=SONiC system health monitor Requires=database.service updategraph.service After=database.service updategraph.service +After=interfaces-config.service [Service] ExecStart=/usr/local/bin/healthd From 4a8a3e4e7e77acef8c3c751f03da54bbf2affc7f Mon Sep 17 00:00:00 2001 From: Vivek Reddy Karri Date: Wed, 10 May 2023 02:32:35 +0000 Subject: [PATCH 2/3] Revert "[health] Start system-health after interfaces-config" This reverts commit 341108eca138f26a8a3cc3b728fa783858d98f7b. --- files/image_config/system-health/system-health.service | 1 - 1 file changed, 1 deletion(-) diff --git a/files/image_config/system-health/system-health.service b/files/image_config/system-health/system-health.service index 0d1a40e2ba98..3de6a51584cb 100644 --- a/files/image_config/system-health/system-health.service +++ b/files/image_config/system-health/system-health.service @@ -2,7 +2,6 @@ Description=SONiC system health monitor Requires=database.service updategraph.service After=database.service updategraph.service -After=interfaces-config.service [Service] ExecStart=/usr/local/bin/healthd From a7f6bf9d50679a43e6f1c599bab5b36200938f56 Mon Sep 17 00:00:00 2001 From: Vivek Reddy Karri Date: Wed, 10 May 2023 03:03:27 +0000 Subject: [PATCH 3/3] Use unix_socket_path in system-health Signed-off-by: Vivek Reddy Karri --- .../health_checker/hardware_checker.py | 2 +- .../health_checker/service_checker.py | 2 +- src/system-health/health_checker/sysmonitor.py | 16 ++++++++-------- src/system-health/scripts/healthd | 2 +- src/system-health/tests/mock_connector.py | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/system-health/health_checker/hardware_checker.py b/src/system-health/health_checker/hardware_checker.py index 59e47fa26733..115e64d2ef55 100644 --- a/src/system-health/health_checker/hardware_checker.py +++ b/src/system-health/health_checker/hardware_checker.py @@ -15,7 +15,7 @@ class HardwareChecker(HealthChecker): def __init__(self): HealthChecker.__init__(self) - self._db = SonicV2Connector(host="127.0.0.1") + self._db = SonicV2Connector(use_unix_socket_path=True) self._db.connect(self._db.STATE_DB) def get_category(self): diff --git a/src/system-health/health_checker/service_checker.py b/src/system-health/health_checker/service_checker.py index 9a88a0851bc8..cfcb79b48216 100644 --- a/src/system-health/health_checker/service_checker.py +++ b/src/system-health/health_checker/service_checker.py @@ -269,7 +269,7 @@ def check_services(self, config): config (config.Config): Health checker configuration. """ if not self.config_db: - self.config_db = swsscommon.ConfigDBConnector() + self.config_db = swsscommon.ConfigDBConnector(use_unix_socket_path=True) self.config_db.connect() feature_table = self.config_db.get_table("FEATURE") expected_running_containers, self.container_feature_dict = self.get_expected_running_containers(feature_table) diff --git a/src/system-health/health_checker/sysmonitor.py b/src/system-health/health_checker/sysmonitor.py index b3f43e447f7b..6f7d4b12042b 100755 --- a/src/system-health/health_checker/sysmonitor.py +++ b/src/system-health/health_checker/sysmonitor.py @@ -31,7 +31,7 @@ def __init__(self,myQ): self.task_queue = myQ def subscribe_statedb(self): - state_db = swsscommon.DBConnector("STATE_DB", REDIS_TIMEOUT_MS, True) + state_db = swsscommon.DBConnector("STATE_DB", REDIS_TIMEOUT_MS, False) sel = swsscommon.Select() cst = swsscommon.SubscriberStateTable(state_db, "FEATURE") sel.addSelectable(cst) @@ -122,7 +122,7 @@ def __init__(self): def post_system_status(self, state): try: if not self.state_db: - self.state_db = swsscommon.SonicV2Connector(host='127.0.0.1') + self.state_db = swsscommon.SonicV2Connector(use_unix_socket_path=True) self.state_db.connect(self.state_db.STATE_DB) self.state_db.set(self.state_db.STATE_DB, "SYSTEM_READY|SYSTEM_STATE", "Status", state) @@ -135,7 +135,7 @@ def post_system_status(self, state): def get_all_service_list(self): if not self.config_db: - self.config_db = swsscommon.ConfigDBConnector() + self.config_db = swsscommon.ConfigDBConnector(use_unix_socket_path=True) self.config_db.connect() dir_list = [] @@ -197,10 +197,10 @@ def get_service_from_feature_table(self, dir_list): #else, just return Up def get_app_ready_status(self, service): if not self.state_db: - self.state_db = swsscommon.SonicV2Connector(host='127.0.0.1') + self.state_db = swsscommon.SonicV2Connector(use_unix_socket_path=True) self.state_db.connect(self.state_db.STATE_DB) if not self.config_db: - self.config_db = swsscommon.ConfigDBConnector() + self.config_db = swsscommon.ConfigDBConnector(use_unix_socket_path=True) self.config_db.connect() fail_reason = "" @@ -248,7 +248,7 @@ def run_systemctl_show(self, service): #Sets the service status to state db def post_unit_status(self, srv_name, srv_status, app_status, fail_reason, update_time): if not self.state_db: - self.state_db = swsscommon.SonicV2Connector(host='127.0.0.1') + self.state_db = swsscommon.SonicV2Connector(use_unix_socket_path=True) self.state_db.connect(self.state_db.STATE_DB) key = 'ALL_SERVICE_STATUS|{}'.format(srv_name) @@ -378,7 +378,7 @@ def update_system_status(self): def check_unit_status(self, event): #global dnsrvs_name if not self.state_db: - self.state_db = swsscommon.SonicV2Connector(host='127.0.0.1') + self.state_db = swsscommon.SonicV2Connector(use_unix_socket_path=True) self.state_db.connect(self.state_db.STATE_DB) astate = "DOWN" @@ -416,7 +416,7 @@ def check_unit_status(self, event): def system_service(self): if not self.state_db: - self.state_db = swsscommon.SonicV2Connector(host='127.0.0.1') + self.state_db = swsscommon.SonicV2Connector(use_unix_socket_path=True) self.state_db.connect(self.state_db.STATE_DB) mpmgr = multiprocessing.Manager() diff --git a/src/system-health/scripts/healthd b/src/system-health/scripts/healthd index cb404de29ee1..28bffeb7129b 100644 --- a/src/system-health/scripts/healthd +++ b/src/system-health/scripts/healthd @@ -31,7 +31,7 @@ class HealthDaemon(DaemonBase): Constructor of HealthDaemon. """ DaemonBase.__init__(self, SYSLOG_IDENTIFIER) - self._db = SonicV2Connector(host="127.0.0.1") + self._db = SonicV2Connector(use_unix_socket_path=True) self._db.connect(self._db.STATE_DB) self.stop_event = threading.Event() diff --git a/src/system-health/tests/mock_connector.py b/src/system-health/tests/mock_connector.py index d602c8eaf165..76ed01d2b9b8 100644 --- a/src/system-health/tests/mock_connector.py +++ b/src/system-health/tests/mock_connector.py @@ -2,7 +2,7 @@ class MockConnector(object): STATE_DB = None data = {} - def __init__(self, host): + def __init__(self, use_unix_socket_path): pass def connect(self, db_id):