From 3f07636bc235ace8da3f2f07aefd56e53085ea0e Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Mon, 11 Dec 2017 15:44:05 +0100 Subject: [PATCH] mgr/influx: Print (in debug) time it takes to send data to Influx On large clusters it might take a very long time to send data to Influx due to the gathering and parsing of statistics. By keeping a counter and printing it admins can adjust the interval if it becomes to heavy for their cluster. Signed-off-by: Wido den Hollander --- src/pybind/mgr/influx/module.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/influx/module.py b/src/pybind/mgr/influx/module.py index beabce72d24ad..e5d787c6d5ba7 100644 --- a/src/pybind/mgr/influx/module.py +++ b/src/pybind/mgr/influx/module.py @@ -2,6 +2,7 @@ from datetime import datetime from threading import Event import json import errno +import time from mgr_module import MgrModule @@ -163,6 +164,8 @@ class Module(MgrModule): # If influx server has authentication turned off then # missing username/password is valid. + self.log.debug("Sending data to Influx host: %s", + self.config['hostname']) client = InfluxDBClient(self.config['hostname'], self.config['port'], self.config['username'], self.config['password'], @@ -232,7 +235,10 @@ class Module(MgrModule): self.run = True while self.run: + start = time.time() self.send_to_influx() - self.log.debug("Running interval loop") - self.log.debug("sleeping for %d seconds", self.config['interval']) + runtime = time.time() - start + self.log.debug('Finished sending data in Influx in %.3f seconds', + runtime) + self.log.debug("Sleeping for %d seconds", self.config['interval']) self.event.wait(self.config['interval']) -- 2.39.5