summaryrefslogtreecommitdiff
path: root/src/daq/flumotion-rrd
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2014-10-12 20:02:37 +0200
committerChristian Pointner <equinox@spreadspace.org>2014-10-12 20:02:37 +0200
commit4c972605ac0b264f18b44b158edd111a211aa1a6 (patch)
treed68ec7236c807a34755e7d56881ee9d6b423cbd8 /src/daq/flumotion-rrd
parentfixed lost messages for batch importer (diff)
cleanups
Diffstat (limited to 'src/daq/flumotion-rrd')
-rwxr-xr-xsrc/daq/flumotion-rrd/sfive-flumotion-rrd.py49
1 files changed, 25 insertions, 24 deletions
diff --git a/src/daq/flumotion-rrd/sfive-flumotion-rrd.py b/src/daq/flumotion-rrd/sfive-flumotion-rrd.py
index 86422fa..0ce7287 100755
--- a/src/daq/flumotion-rrd/sfive-flumotion-rrd.py
+++ b/src/daq/flumotion-rrd/sfive-flumotion-rrd.py
@@ -107,9 +107,32 @@ class FlumotionRRD():
self._bytes_rrdfile = properties['bytes-rrdfile']
self._clients_rrdfile = properties['clients-rrdfile']
+ self._initRRD()
+
self._proto = None
self._conn = None
+ def _initRRD(self):
+ info_bytes = rrdtool.info(self._bytes_rrdfile)
+ step_bytes = info_bytes['step']
+ lastupdate_bytes = info_bytes['last_update']
+ info_clients = rrdtool.info(self._clients_rrdfile)
+ step_clients = info_clients['step']
+ lastupdate_clients = info_clients['last_update']
+
+ self._duration = step_bytes
+ if step_bytes != step_clients:
+ print 'SFive: ERROR step size of the RRD Files don\'t match'
+ reactor.stop()
+
+ self._end = lastupdate_bytes if lastupdate_bytes < lastupdate_clients else lastupdate_clients
+ if lastupdate_bytes != lastupdate_clients:
+ print 'SFive: WARNING the last update timestamp of the RRD Files don\'t match - will use smaller timestamp'
+ reactor.stop()
+
+ print 'SFive: will use 7 days of data ending with %s using a step size of %d seconds' % (
+ datetime.datetime.utcfromtimestamp(self._end).isoformat('T'), self._duration)
+
def run(self):
reactor.callWhenRunning(self._initSocket)
reactor.run()
@@ -127,41 +150,19 @@ class FlumotionRRD():
def _socketReady(self):
print 'SFive: connection to sfive hub established'
- self._checkRRD()
self._sendInit()
- cnt = self._sendRRD()
+ cnt = self._sendRRDData()
print 'SFive: sent %d datasets' % (cnt)
reactor.stop()
- def _checkRRD(self):
- info_bytes = rrdtool.info(self._bytes_rrdfile)
- step_bytes = info_bytes['step']
- lastupdate_bytes = info_bytes['last_update']
- info_clients = rrdtool.info(self._clients_rrdfile)
- step_clients = info_clients['step']
- lastupdate_clients = info_clients['last_update']
-
- self._duration = step_bytes
- if step_bytes != step_clients:
- print 'SFive: ERROR step size of the RRD Files don\'t match'
- reactor.stop()
-
- self._end = lastupdate_bytes if lastupdate_bytes < lastupdate_clients else lastupdate_clients
- if lastupdate_bytes != lastupdate_clients:
- print 'SFive: WARNING the last update timestamp of the RRD Files don\'t match - will use smaller timestamp'
- reactor.stop()
-
- print 'SFive: will use 7 days of data ending with %s using a step size of %d seconds' % (
- datetime.datetime.utcfromtimestamp(self._end).isoformat('T'), self._duration)
-
def _sendInit(self):
initdata = { "hostname": self._hostname,
"streamer-id": { "content-id": self._content_id, "format": self._format, "quality": self._quality },
"tags": self._tags }
self._proto.sendDatagram('%s\n' % (json.dumps(initdata)));
- def _sendRRD(self):
+ def _sendRRDData(self):
data_bytes = rrdtool.fetch(self._bytes_rrdfile, 'AVERAGE', '-s', 'end-7d', '-e', '%d' % self._end)
data_clients = rrdtool.fetch(self._clients_rrdfile, 'AVERAGE', '-s', 'end-7d', '-e', '%d' % self._end)