summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/daq/accesslog/sfive-accesslog.py10
-rwxr-xr-xsrc/daq/flumotion-rrd/sfive-flumotion-rrd.py62
2 files changed, 41 insertions, 31 deletions
diff --git a/src/daq/accesslog/sfive-accesslog.py b/src/daq/accesslog/sfive-accesslog.py
index e07f22c..1337f1c 100755
--- a/src/daq/accesslog/sfive-accesslog.py
+++ b/src/daq/accesslog/sfive-accesslog.py
@@ -108,6 +108,11 @@ class AccessLog():
self._proto = None
self._conn = None
+ def run(self):
+ if self._initLog():
+ reactor.callWhenRunning(self._initSocket)
+ reactor.run()
+
def _initLog(self):
try:
self._fd = open(self._logfile, 'r')
@@ -117,11 +122,6 @@ class AccessLog():
return True
- def run(self):
- if self._initLog():
- reactor.callWhenRunning(self._initSocket)
- reactor.run()
-
def _initSocket(self):
print 'SFive: trying to connect to %s...' % (self._socket)
self._proto = SFiveProto(self)
diff --git a/src/daq/flumotion-rrd/sfive-flumotion-rrd.py b/src/daq/flumotion-rrd/sfive-flumotion-rrd.py
index 0ce7287..4b0a2d1 100755
--- a/src/daq/flumotion-rrd/sfive-flumotion-rrd.py
+++ b/src/daq/flumotion-rrd/sfive-flumotion-rrd.py
@@ -107,35 +107,41 @@ class FlumotionRRD():
self._bytes_rrdfile = properties['bytes-rrdfile']
self._clients_rrdfile = properties['clients-rrdfile']
- self._initRRD()
-
self._proto = None
self._conn = None
+ def run(self):
+ if self._initRRD():
+ reactor.callWhenRunning(self._initSocket)
+ reactor.run()
+
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)
+ try:
+ 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']
- def run(self):
- reactor.callWhenRunning(self._initSocket)
- reactor.run()
+ self._duration = step_bytes
+ if step_bytes != step_clients:
+ print 'SFive: ERROR step size of the RRD Files don\'t match'
+ return False
+
+ 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'
+ return False
+
+ 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)
+
+ except rrdtool.error as e:
+ print 'SFive: rrdtool-error: %s' % (e)
+ return False
+
+ return True
def _initSocket(self):
print 'SFive: trying to connect to %s...' % (self._socket)
@@ -163,8 +169,12 @@ class FlumotionRRD():
self._proto.sendDatagram('%s\n' % (json.dumps(initdata)));
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)
+ try:
+ 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)
+ except rrdtool.error as e:
+ print 'SFive: rrdtool-error: %s' % (e)
+ return 0
ts = data_bytes[0][0]
max = len(data_bytes[2])