]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/influx: Only fetch the current time once when gathering data 22414/head
authorWido den Hollander <wido@42on.com>
Wed, 31 Jan 2018 13:43:54 +0000 (14:43 +0100)
committerWido den Hollander <wido@42on.com>
Wed, 6 Jun 2018 13:51:00 +0000 (15:51 +0200)
By fetching the current time once and storing it into a variable
we save a lot of system calls. On large clusters this can be a lot
of system calls.

In addition we also make sure that all points gathered in the same
loop/run have exactly the same timestamp.

Otherwise there will be a difference in time between the items in
InfluxDB which then causes problems when creating graphs with for
example Grafana.

Signed-off-by: Wido den Hollander <wido@42on.com>
(cherry picked from commit 0857d3bcd4175f39582376fb9980cf3f66fa09ce)

src/pybind/mgr/influx/module.py

index 6bee4ac294024b48599c86f5e04b14dc2f86cf44..b4039ac70806576dc1ea2b4997272a9ffa95eade 100644 (file)
@@ -70,6 +70,8 @@ class Module(MgrModule):
         df = self.get("df")
         data = []
 
+        now = datetime.utcnow().isoformat() + 'Z'
+
         df_types = [
             'bytes_used',
             'kb_used',
@@ -95,7 +97,7 @@ class Module(MgrModule):
                         "type_instance": df_type,
                         "fsid": self.get_fsid()
                     },
-                    "time": datetime.utcnow().isoformat() + 'Z',
+                    "time": now,
                     "fields": {
                         "value": pool['stats'][df_type],
                     }
@@ -106,6 +108,8 @@ class Module(MgrModule):
     def get_daemon_stats(self):
         data = []
 
+        now = datetime.utcnow().isoformat() + 'Z'
+
         for daemon, counters in self.get_all_perf_counters().iteritems():
             svc_type, svc_id = daemon.split(".", 1)
             metadata = self.get_metadata(svc_type, svc_id)
@@ -124,7 +128,7 @@ class Module(MgrModule):
                         "host": metadata['hostname'],
                         "fsid": self.get_fsid()
                     },
-                    "time": datetime.utcnow().isoformat() + 'Z',
+                    "time": now,
                     "fields": {
                         "value": value
                     }