summaryrefslogtreecommitdiffstats
path: root/gui/muxconfig.py
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-03-15 19:23:39 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-06-19 10:26:02 +0200
commit752fa808e3f148f45b689a026f0e703c83b83d92 (patch)
tree3347c04c69e65a1945a3da1f9d61f9c441169611 /gui/muxconfig.py
parentc31a5cab786b79dc781f80fa3f9dae8376a2ed84 (diff)
downloaddabmux-752fa808e3f148f45b689a026f0e703c83b83d92.tar.gz
dabmux-752fa808e3f148f45b689a026f0e703c83b83d92.tar.bz2
dabmux-752fa808e3f148f45b689a026f0e703c83b83d92.zip
Add a statistics page to gui
Diffstat (limited to 'gui/muxconfig.py')
-rw-r--r--gui/muxconfig.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/gui/muxconfig.py b/gui/muxconfig.py
index 64321a2..f725462 100644
--- a/gui/muxconfig.py
+++ b/gui/muxconfig.py
@@ -95,6 +95,7 @@ class ConfigurationHandler(object):
# local copy of the configuration
self._server_version = None
self._config = None
+ self._statistics = None
def load(self):
"""Load the configuration from the multiplexer and
@@ -102,14 +103,30 @@ class ConfigurationHandler(object):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((self._host, self._port))
- s.sendall(b'getptree\n')
server_info = s.recv(32768)
+ s.sendall(b'getptree\n')
config_info = s.recv(32768)
s.close()
self._server_version = json.loads(server_info.decode())['service']
self._config = json.loads(config_info.decode())
+ def update_stats(self):
+ """Load the statistics from the multiplexer and
+ save them locally"""
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+
+ s.connect((self._host, self._port))
+ server_info = s.recv(32768)
+
+ s.sendall(b'values\n')
+
+ stats_info = s.recv(32768)
+ s.close()
+
+ print("STATS: {}".format(stats_info.decode()))
+ self._statistics = json.loads(stats_info.decode())['values']
+
def get_full_configuration(self):
return self._config
@@ -130,3 +147,8 @@ class ConfigurationHandler(object):
def get_general_options(self):
return General(self._config)
+
+ def get_stats_dict(self):
+ """Return a dictionary with all stats"""
+ self.update_stats()
+ return self._statistics