From 6517cc3078eba96ea96e085d033a4b8a96eb7151 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Tue, 11 Mar 2025 16:35:08 +0100 Subject: Add EDI/TCP number of active connections statistics --- doc/STATS.md | 7 ++++--- doc/show_dabmux_stats.py | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/doc/STATS.md b/doc/STATS.md index 385d41e..435a92e 100644 --- a/doc/STATS.md +++ b/doc/STATS.md @@ -4,12 +4,13 @@ Stats available through Management Server Interface --------- -The management server makes statistics about the inputs available through a ZMQ request/reply socket. +The management server makes statistics about the inputs and EDI/TCP outputs +available through a ZMQ request/reply socket. The `show_dabmux_stats.py` illustrates how to access this information. -Meaning of values ------------------ +Meaning of values for inputs +---------------------------- `max` and `min` indicate input buffer fullness in bytes. diff --git a/doc/show_dabmux_stats.py b/doc/show_dabmux_stats.py index 7ea60f7..3b6d869 100755 --- a/doc/show_dabmux_stats.py +++ b/doc/show_dabmux_stats.py @@ -46,6 +46,7 @@ if len(sys.argv) == 1: data = sock.recv().decode("utf-8") values = json.loads(data)['values'] + print("## INPUT STATS") tmpl = "{ident:20}{maxfill:>8}{minfill:>8}{under:>8}{over:>8}{audioleft:>8}{audioright:>8}{peakleft:>8}{peakright:>8}{state:>16}{version:>48}{uptime:>8}{offset:>8}" print(tmpl.format( ident="id", @@ -89,6 +90,27 @@ if len(sys.argv) == 1: uptime=v['uptime'], offset=v['last_tist_offset'])) + sock.send(b"output_values") + + poller = zmq.Poller() + poller.register(sock, zmq.POLLIN) + + socks = dict(poller.poll(1000)) + if socks: + if socks.get(sock) == zmq.POLLIN: + print() + print("## OUTPUT STATS") + data = sock.recv().decode("utf-8") + values = json.loads(data)['output_values'] + for identifier in values: + if identifier.startswith("edi_tcp_"): + listen_port = identifier.rsplit("_", 1)[-1] + num_connections = values[identifier]["num_connections"] + print(f"EDI TCP on port {listen_port}: {num_connections} connections") + else: + print(f"Unknown output type: {identifier}") + + elif len(sys.argv) == 2 and sys.argv[1] == "config": sock = connect() -- cgit v1.2.3