changeset 1457:2ba144b7ede0

whitespace and doc Ignore-this: 51023da4821300d28020696e0b145db5 darcs-hash:716d578348ca7a56c55f0687741d19077829c5e8
author drewp <drewp@bigasterisk.com>
date Wed, 25 Sep 2019 17:56:03 -0700
parents a81def58ecfb
children be5fc8791c4d
files lib/export_to_influxdb/export_to_influxdb.py
diffstat 1 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/lib/export_to_influxdb/export_to_influxdb.py	Wed Sep 25 17:36:44 2019 -0700
+++ b/lib/export_to_influxdb/export_to_influxdb.py	Wed Sep 25 17:56:03 2019 -0700
@@ -19,7 +19,7 @@
                                                 replication='1')
             self.createdPolicies.add(days)
         return name
-        
+
 class InfluxExporter(object):
     def __init__(self, configGraph, influxHost='bang6'):
         self.graph = configGraph
@@ -68,13 +68,24 @@
                     log.info('writing stats to %r', points)
                 self.lastExport = now
                 #print('send %r' % points)
-            
+
         task.LoopingCall(send).start(period_secs, now=False)
-            
+
     def exportToInflux(self, currentStatements):
+        """
+        looks for
+
+        ?subj ?p ?value;
+         :influxMeasurement [
+           :measurement ?name;
+           :predicate ?p;
+           :tag [:key ?k; :value ?v], ...
+         ]
+
+        """
         graph = self.graph
         now = int(time.time())
-      
+
         points = []
         for stmt in currentStatements:
             if (stmt[0], stmt[1]) in self.measurements:
@@ -89,11 +100,11 @@
                 pale = 3600
                 if graph.value(meas, ROOM['pointsAtLeastEvery'], default=None):
                     pale = graph.value(meas, ROOM['pointsAtLeastEvery']).toPython()
-                    
+
                 if not self.shouldSendNewPoint(now, stmt[0], measurementName,
                                                tags, value, pointsAtLeastEvery=pale):
                     continue
-                    
+
                 points.append({
                     'measurement': measurementName,
                     "tags": tags,
@@ -114,7 +125,7 @@
             if not isinstance(value, (int, float)):
                 raise NotImplementedError('value=%r' % value)
         return value
-            
+
     def shouldSendNewPoint(self, now, subj, measurementName, tags, value, pointsAtLeastEvery):
         key = (subj, measurementName, tuple(sorted(tags.items())))
         if key in self.lastSent: