summaryrefslogtreecommitdiff
path: root/src/daq/flumotion-plug/sfive.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/daq/flumotion-plug/sfive.py')
-rw-r--r--src/daq/flumotion-plug/sfive.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/daq/flumotion-plug/sfive.py b/src/daq/flumotion-plug/sfive.py
index 9875393..a192f92 100644
--- a/src/daq/flumotion-plug/sfive.py
+++ b/src/daq/flumotion-plug/sfive.py
@@ -13,7 +13,7 @@
#
#
# Copyright (C) 2014 Christian Pointner <equinox@spreadspace.org>
-# Markus Grüneis <gimpf@gimpf.org>
+# Markus Grueneis <gimpf@gimpf.org>
#
# This file is part of sfive.
#
@@ -64,6 +64,9 @@ class ComponentSFivePlug(base.ComponentPlug):
self._duration = properties.get('duration', _DEFAULT_POLL_INTERVAL)
self._sfivepoller = Poller(self._updateSFive, self._duration, start=False)
+ self._old_bytes_received = -1
+ self._old_bytes_sent = -1
+
self._initSocket()
def stop(self, component):
@@ -71,21 +74,23 @@ class ComponentSFivePlug(base.ComponentPlug):
self._sfivepoller.stop()
## TODO: close unix socket
- def _initSocket(self)
+ def _initSocket(self):
self.debug('SFive: connecting to %s...', self._socket)
## TODO: init unix socket and call _socketReady when socket is ready
## TODO: how handle connection drop???
+ self._socketReady()
- def _socketError(self)
+ def _socketError(self):
self.warning('SFive: connection lost... trying reconnect')
## TODO: try reconnect...
- def _socketReady(self)
+ def _socketReady(self):
self.info('SFive: connection to sfive hub established')
if self._sfivepoller:
- self._sfivepoller(start)
+ self._sfivepoller.start()
- def _sendInit(self)
+ def _sendInit(self):
+ self.debug('SFive: sending init message')
# TODO: create json and send it out
# {
# "hostname": "myhostname",
@@ -93,13 +98,17 @@ class ComponentSFivePlug(base.ComponentPlug):
# "tags": [ "elevate", "2014", "discourse" ]
# }
-
def _updateSFive(self):
- """send data update"""
-
client_count = self._component.getClients()
bytes_received = self._component.getBytesReceived()
bytes_sent = self._component.getBytesSent()
+
+ bytes_received_diff = bytes_received - self._old_bytes_received if self._old_bytes_received > 0 else 0;
+ self._old_bytes_received = bytes_received
+ bytes_sent_diff = bytes_sent - self._old_bytes_sent if self._old_bytes_sent > 0 else 0;
+ self._old_bytes_sent = bytes_sent
+
+ self.debug('SFive: sending data (client-count: %d, bytes_received: %d, bytes_sent: %d)', client_count, bytes_received_diff, bytes_sent_diff)
# TODO: create json and send it out
# {
# "start-time": "2014-08-03Z12:34:56.123",