From a0c2c8b900cd2bab2ef8041722036036efd2cb0f Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Tue, 30 Jan 2018 15:45:40 +0100 Subject: [PATCH 1/2] mgr/influx: Catch ConnectionError if raised The InfluxDBClient can also re-raise a ConnectionError from the python requests module if that was caught. The Exception might be: ConnectionError: ('Connection aborted.', error(104, 'Connection reset by peer')) Catch and log this error instead of having it raised which might cause problems further down. Signed-off-by: Wido den Hollander --- src/pybind/mgr/influx/module.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/pybind/mgr/influx/module.py b/src/pybind/mgr/influx/module.py index dd288dc718f..09d99e44bd8 100644 --- a/src/pybind/mgr/influx/module.py +++ b/src/pybind/mgr/influx/module.py @@ -9,6 +9,7 @@ from mgr_module import MgrModule try: from influxdb import InfluxDBClient from influxdb.exceptions import InfluxDBClientError + from requests.exceptions import ConnectionError except ImportError: InfluxDBClient = None @@ -177,6 +178,13 @@ class Module(MgrModule): if not self.config['hostname']: self.log.error("No Influx server configured, please set one using: " "ceph influx config-set hostname ") + self.set_health_checks({ + 'MGR_INFLUX_NO_SERVER': { + 'severity': 'warning', + 'summary': 'No InfluxDB server configured', + 'detail': ['Configuration option hostname not set'] + } + }) return # If influx server has authentication turned off then @@ -196,6 +204,19 @@ class Module(MgrModule): try: client.write_points(self.get_df_stats(), 'ms') client.write_points(self.get_daemon_stats(), 'ms') + self.set_health_checks(dict()) + except ConnectionError as e: + self.log.exception("Failed to connect to Influx host %s:%d", + self.config['hostname'], self.config['port']) + self.set_health_checks({ + 'MGR_INFLUX_SEND_FAILED': { + 'severity': 'warning', + 'summary': 'Failed to send data to InfluxDB server at %s:%d' + ' due to an connection error' + % (self.config['hostname'], self.config['port']), + 'detail': [str(e)] + } + }) except InfluxDBClientError as e: if e.code == 404: self.log.info("Database '%s' not found, trying to create " @@ -205,6 +226,13 @@ class Module(MgrModule): self.config['username']) client.create_database(self.config['database']) else: + self.set_health_checks({ + 'MGR_INFLUX_SEND_FAILED': { + 'severity': 'warning', + 'summary': 'Failed to send data to InfluxDB', + 'detail': [str(e)] + } + }) raise def shutdown(self): From c803f38a17af625edc1cee29f21e510a03396204 Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Wed, 31 Jan 2018 13:15:05 +0100 Subject: [PATCH 2/2] mgr/influx: Send more information about pools In addition to the existing statistics also send Read and Write IOps, but also quota information. Signed-off-by: Wido den Hollander --- src/pybind/mgr/influx/module.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/influx/module.py b/src/pybind/mgr/influx/module.py index 09d99e44bd8..a5d50a2d8d5 100644 --- a/src/pybind/mgr/influx/module.py +++ b/src/pybind/mgr/influx/module.py @@ -79,12 +79,17 @@ class Module(MgrModule): df_types = [ 'bytes_used', + 'kb_used', 'dirty', + 'rd', 'rd_bytes', 'raw_bytes_used', + 'wr', 'wr_bytes', 'objects', - 'max_avail' + 'max_avail', + 'quota_objects', + 'quota_bytes' ] for df_type in df_types: