collector.collect_forever()
except Exception as e:
log.error("Failed to start MON Collector")
- log.debug("Exception: %s", str(e))
+ log.exception("Exception: %s", str(e))
else:
log.error("Failed to start MON Collector")
dashboarder.dashboard_forever()
except Exception as e:
log.error("Failed to start MON Dashboarder")
- log.debug("Exception: %s", str(e))
+ log.exception("Exception: %s", str(e))
else:
log.error("Failed to start MON Dashboarder")
evaluator.evaluate_forever()
except Exception as e:
log.error("Failed to start MON Evaluator")
- log.debug("Exception: %s", str(e))
+ log.exception("Exception: %s", str(e))
else:
log.error("Failed to start MON Evaluator")
server.run()
except Exception as e:
log.error("Failed to start MON Server")
- log.debug("Exception: %s", str(e))
+ log.exception("Exception: %s", str(e))
else:
log.error("Failed to start MON Server")
import socket
import logging
import kafka
-
+from osm_mon.core.message_bus_client import MessageBusClient
def wait_till_commondb_is_ready(config, process_name="osm-mon", commondb_wait_time=5):
.get("port")])
topics = consumer.topics()
logging.debug("Number of topics found: %s", len(topics))
+
+ # Send dummy message in kafka topics. If kafka is not ready exception will be thrown.
+ msg_bus = MessageBusClient(config)
+ topics = ["alarm_request", "users", "project"]
+ for topic in topics:
+ msg_bus.aiowrite(topic, 'echo', 'dummy message')
+
+ # Kafka is ready now
kafka_ready = True
except Exception as e:
logging.info("Error when trying to get kafka status.")
async def start(self):
topics = ["users", "project"]
- await self.msg_bus.aioread(topics, self._user_msg)
+ try:
+ await self.msg_bus.aioread(topics, self._user_msg)
+ except Exception as e:
+ # Failed to subscribe to kafka topics
+ log.error("Error when subscribing to topics %s", str(topics))
+ log.exception("Exception %s", str(e))
async def _user_msg(self, topic, key, values):
log.debug("Message from kafka bus received: topic: %s and values: %s and key: %s", topic, values, key)
topics = [
"alarm_request"
]
- await self.msg_bus.aioread(topics, self._process_msg)
+ try:
+ await self.msg_bus.aioread(topics, self._process_msg)
+ except Exception as e:
+ # Failed to subscribe to kafka topic
+ log.exception("Error when subscribing to topics %s", str(topics))
+ raise e
async def _process_msg(self, topic, key, values):
log.info("Message arrived: %s", values)