From: lavado Date: Mon, 9 Dec 2019 21:02:18 +0000 (-0500) Subject: Validate Grafana is present for dashboarder service X-Git-Tag: v7.0.0rc1 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=7a118a4a92e9c2c342b550fc4b72f9ad6169f6d4;p=osm%2FMON.git Validate Grafana is present for dashboarder service Check if MON can resolve a grafana service. This is currently useful in the transition to K8s, or in OSM distros with absent Grafana. Fixes Bug 932 Change-Id: I3b5ebf3d8ee3397f16793cd730e7e1fa5f6676d4 Signed-off-by: lavado --- diff --git a/osm_mon/dashboarder/dashboarder.py b/osm_mon/dashboarder/dashboarder.py index dc21e33..bb2935a 100644 --- a/osm_mon/dashboarder/dashboarder.py +++ b/osm_mon/dashboarder/dashboarder.py @@ -22,7 +22,7 @@ ## import logging import time - +import socket import peewee from osm_mon.dashboarder.service import DashboarderService @@ -39,6 +39,13 @@ class Dashboarder: def dashboard_forever(self): log.debug('dashboard_forever') while True: + try: + socket.gethostbyname("grafana") + log.debug("Dashboard backend is running") + except socket.error: + log.debug("Dashboard backend is not available") + time.sleep(int(self.conf.get('dashboarder', 'interval'))) + continue try: self.create_dashboards() time.sleep(int(self.conf.get('dashboarder', 'interval')))