aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-10-16 13:52:38 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-10-16 13:52:38 +0200
commit47744ff9a84f9cb0c7357ac3a56fa978688a6cc8 (patch)
tree9909f0d390daafa784f3d842a6d66467d0119726
parent5801e3c23b76e026762fc8a6088e90d975730ed4 (diff)
downloadmmbtools-aux-47744ff9a84f9cb0c7357ac3a56fa978688a6cc8.tar.gz
mmbtools-aux-47744ff9a84f9cb0c7357ac3a56fa978688a6cc8.tar.bz2
mmbtools-aux-47744ff9a84f9cb0c7357ac3a56fa978688a6cc8.zip
Add state to show_dabmux_stats.py
-rwxr-xr-xshow_dabmux_stats.py59
1 files changed, 37 insertions, 22 deletions
diff --git a/show_dabmux_stats.py b/show_dabmux_stats.py
index f91cfb5..f781839 100755
--- a/show_dabmux_stats.py
+++ b/show_dabmux_stats.py
@@ -33,28 +33,43 @@ def connect():
if len(sys.argv) == 1:
sock = connect()
sock.send("values")
- values = json.loads(sock.recv())['values']
-
- tmpl = "{ident:20}{maxfill:>8}{minfill:>8}{under:>8}{over:>8}{peakleft:>8}{peakright:>8}"
- print(tmpl.format(
- ident="id",
- maxfill="max",
- minfill="min",
- under="under",
- over="over",
- peakleft="peak L",
- peakright="peak R"))
-
- for ident in values:
- v = values[ident]['inputstat']
- print(tmpl.format(
- ident=ident,
- maxfill=v['max_fill'],
- minfill=v['min_fill'],
- under=v['num_underruns'],
- over=v['num_overruns'],
- peakleft=v['peak_left'],
- peakright=v['peak_right']))
+
+ poller = zmq.Poller()
+ poller.register(sock, zmq.POLLIN)
+
+ socks = dict(poller.poll(1000))
+ if socks:
+ if socks.get(sock) == zmq.POLLIN:
+
+ data = sock.recv()
+ values = json.loads(data)['values']
+
+ tmpl = "{ident:20}{maxfill:>8}{minfill:>8}{under:>8}{over:>8}{peakleft:>8}{peakright:>8}{state:>16}"
+ print(tmpl.format(
+ ident="id",
+ maxfill="max",
+ minfill="min",
+ under="under",
+ over="over",
+ peakleft="peak L",
+ peakright="peak R",
+ state="state"))
+
+ for ident in values:
+ v = values[ident]['inputstat']
+
+ if 'state' not in v:
+ v['state'] = None
+
+ print(tmpl.format(
+ ident=ident,
+ maxfill=v['max_fill'],
+ minfill=v['min_fill'],
+ under=v['num_underruns'],
+ over=v['num_overruns'],
+ peakleft=v['peak_left'],
+ peakright=v['peak_right'],
+ state=v['state']))
elif len(sys.argv) == 2 and sys.argv[1] == "config":