From 128ea565caec36a04fdc82f0eeb925e15aad2e5c Mon Sep 17 00:00:00 2001 From: matt <mcarey66@gmail.com> Date: Mon, 18 Feb 2019 13:47:45 -0500 Subject: [PATCH] Add extra log when InfluxDB fails to connected --- influxspeedtest/InfluxdbSpeedtest.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/influxspeedtest/InfluxdbSpeedtest.py b/influxspeedtest/InfluxdbSpeedtest.py index a32cf4b..3daa02b 100644 --- a/influxspeedtest/InfluxdbSpeedtest.py +++ b/influxspeedtest/InfluxdbSpeedtest.py @@ -4,7 +4,7 @@ import time import speedtest from influxdb import InfluxDBClient from influxdb.exceptions import InfluxDBClientError, InfluxDBServerError -from requests import ConnectTimeout +from requests import ConnectTimeout, ConnectionError from influxspeedtest.common import log from influxspeedtest.config import config @@ -40,11 +40,13 @@ class InfluxdbSpeedtest(): log.debug('Testing connection to InfluxDb using provided credentials') influx.get_list_users() # TODO - Find better way to test connection and permissions log.debug('Successful connection to InfluxDb') - except (ConnectTimeout, InfluxDBClientError) as e: + except (ConnectTimeout, InfluxDBClientError, ConnectionError) as e: if isinstance(e, ConnectTimeout): log.critical('Unable to connect to InfluxDB at the provided address (%s)', config.influx_address) elif e.code == 401: log.critical('Unable to connect to InfluxDB with provided credentials') + else: + log.critical('Failed to connect to InfluxDB for unknown reason') sys.exit(1) -- GitLab