From 77df1a9545339d6f87c7968d044e2808bb0c283c Mon Sep 17 00:00:00 2001 From: Idan Hefetz Date: Tue, 20 Feb 2018 14:50:22 +0000 Subject: [PATCH] add process names Process name to appear in 'ps -aux' Change-Id: I2ea69b23337d850f579ad2daf0b8b93f611a90d9 --- requirements.txt | 1 + vitrage/datasources/services.py | 22 ++++++++++++++++++++++ vitrage/entity_graph/graph_clone/base.py | 11 +++++++++++ vitrage/evaluator/evaluator_service.py | 3 +++ 4 files changed, 37 insertions(+) diff --git a/requirements.txt b/requirements.txt index 46fc38e64..88d252b01 100644 --- a/requirements.txt +++ b/requirements.txt @@ -45,4 +45,5 @@ WebOb>=1.7.1 # MIT eventlet!=0.18.3,!=0.20.1,<0.21.0,>=0.18.2 # MIT six>=1.10.0 # MIT debtcollector>=1.2.0 # Apache-2.0 +cotyledon>=1.3.0 # Apache-2.0 diff --git a/vitrage/datasources/services.py b/vitrage/datasources/services.py index 737ffd769..6ceed7f8e 100644 --- a/vitrage/datasources/services.py +++ b/vitrage/datasources/services.py @@ -11,6 +11,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +import setproctitle import time from oslo_log import log @@ -27,6 +28,19 @@ class DatasourceService(os_service.Service): self.registered_datasources = registered_datasources self.send_to_queue = send_to_queue_func + def name(self): + return '' + + def start(self): + super(DatasourceService, self).start() + try: + setproctitle.setproctitle('{} {} {}'.format( + 'vitrage-collector', + self.__class__.__name__, + self.name())) + except Exception: + LOG.warning('failed to set process name') + class SnapshotsService(DatasourceService): def __init__(self, conf, registered_datasources, callback_function): @@ -34,6 +48,10 @@ class SnapshotsService(DatasourceService): registered_datasources, callback_function) + def name(self): + names = [name for name in self.registered_datasources] + return ','.join(names) + def start(self): LOG.info("Vitrage datasources Snapshot Service - Starting...") super(SnapshotsService, self).start() @@ -94,6 +112,10 @@ class ChangesService(DatasourceService): callback_function) self.changes_interval = changes_interval + def name(self): + names = [d.__class__.__name__ for d in self.registered_datasources] + return ','.join(names) + def start(self): LOG.info("Vitrage Datasource Changes Service For: %s - Starting...", self.registered_datasources[0].__class__.__name__) diff --git a/vitrage/entity_graph/graph_clone/base.py b/vitrage/entity_graph/graph_clone/base.py index 50584258e..cff6a9f66 100644 --- a/vitrage/entity_graph/graph_clone/base.py +++ b/vitrage/entity_graph/graph_clone/base.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. import abc +import setproctitle import time from oslo_log import log @@ -83,8 +84,18 @@ class GraphCloneWorkerBase(os_service.Service): self._task_queue = task_queue self._entity_graph = entity_graph + def name(self): + return '' + def start(self): super(GraphCloneWorkerBase, self).start() + try: + setproctitle.setproctitle('{} {} {}'.format( + 'vitrage-graph', + self.__class__.__name__, + self.name())) + except Exception: + LOG.warning('failed to set process name') self._entity_graph.notifier._subscriptions = [] # Quick n dirty self.tg.add_thread(self._read_queue) LOG.info("%s - Started!", self.__class__.__name__) diff --git a/vitrage/evaluator/evaluator_service.py b/vitrage/evaluator/evaluator_service.py index e017b6333..632471dad 100644 --- a/vitrage/evaluator/evaluator_service.py +++ b/vitrage/evaluator/evaluator_service.py @@ -74,6 +74,9 @@ class EvaluatorWorker(base.GraphCloneWorkerBase): self._workers_num = workers_num self._evaluator = None + def name(self): + return "(%s)" % str(self._worker_index) + def start(self): super(EvaluatorWorker, self).start() scenario_repo = ScenarioRepository(self._conf, self._worker_index,