From ea7aaf2eca47c3d28b369dfcfc7f95537e46b682 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Thu, 22 Sep 2022 21:07:54 +0200 Subject: [PATCH] vty: show per-connection Osmux VTY stats Related: SYS#5987 Change-Id: Ieab6dcbd195c8e01a73a2a832bce78ee015ae1c3 --- include/osmocom/mgcp/osmux.h | 4 ++++ src/libosmo-mgcp/mgcp_osmux.c | 7 +++++++ src/libosmo-mgcp/mgcp_vty.c | 24 ++++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/include/osmocom/mgcp/osmux.h b/include/osmocom/mgcp/osmux.h index 1a99e6d8f..58d9095d0 100644 --- a/include/osmocom/mgcp/osmux.h +++ b/include/osmocom/mgcp/osmux.h @@ -34,6 +34,10 @@ enum osmux_state { OSMUX_STATE_ENABLED, /* Osmux was initialized by \ref osmux_enable_endpoint and can process frames */ }; +extern const struct value_string osmux_state_strs[]; +static inline const char *osmux_state_str(enum osmux_state val) +{ return get_value_string(osmux_state_strs, val); } + enum osmux_usage { OSMUX_USAGE_OFF = 0, OSMUX_USAGE_ON = 1, diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c index 6ae0d8e43..65783f370 100644 --- a/src/libosmo-mgcp/mgcp_osmux.c +++ b/src/libosmo-mgcp/mgcp_osmux.c @@ -41,6 +41,13 @@ struct osmux_handle { int refcnt; }; +const struct value_string osmux_state_strs[] = { + { OSMUX_STATE_DISABLED, "disabled" }, + { OSMUX_STATE_ACTIVATING, "activating" }, + { OSMUX_STATE_ENABLED, "enabled" }, + { 0, NULL } +}; + static const struct rate_ctr_group_desc rate_ctr_group_osmux_desc = { .group_name_prefix = "conn_osmux", .group_description = "Osmux connection statistics", diff --git a/src/libosmo-mgcp/mgcp_vty.c b/src/libosmo-mgcp/mgcp_vty.c index 34c2d4b4b..1bf87897b 100644 --- a/src/libosmo-mgcp/mgcp_vty.c +++ b/src/libosmo-mgcp/mgcp_vty.c @@ -197,6 +197,30 @@ static void dump_rtp_end(struct vty *vty, struct mgcp_conn_rtp *conn) VTY_NEWLINE, end->fmtp_extra, codec->audio_name, codec->subtype_name, VTY_NEWLINE, end->output_enabled, end->force_output_ptime, VTY_NEWLINE); + if (mgcp_conn_rtp_is_osmux(conn)) { + struct rate_ctr *rx_chunks, *rx_octets, *rtp_tx, *rtp_tx_dropped, *octets_tx; + rx_chunks = rate_ctr_group_get_ctr(conn->osmux.ctrg, OSMUX_CHUNKS_RX_CTR); + rx_octets = rate_ctr_group_get_ctr(conn->osmux.ctrg, OSMUX_OCTETS_RX_CTR); + rtp_tx = rate_ctr_group_get_ctr(conn->osmux.ctrg, OSMUX_RTP_PACKETS_TX_CTR); + rtp_tx_dropped = rate_ctr_group_get_ctr(conn->osmux.ctrg, OSMUX_RTP_PACKETS_TX_DROPPED_CTR); + octets_tx = rate_ctr_group_get_ctr(conn->osmux.ctrg, OSMUX_AMR_OCTETS_TX_CTR); + vty_out(vty, + " Osmux:%s" + " State: %s%s" + " Local CID: %d%s" + " Remote CID: %d%s" + " Chunks received: %" PRIu64 " (%" PRIu64 " bytes total)%s" + " RTP Packets encoded (Tx): %" PRIu64 " (%" PRIu64 " AMR octets total)%s" + " AMR payloads Dropped (Tx): %" PRIu64 "%s", + VTY_NEWLINE, osmux_state_str(conn->osmux.state), VTY_NEWLINE, + conn->osmux.local_cid_allocated ? conn->osmux.local_cid : -1, VTY_NEWLINE, + conn->osmux.remote_cid_present ? conn->osmux.remote_cid : -1, VTY_NEWLINE, + rx_chunks->current, rx_octets->current, VTY_NEWLINE, + rtp_tx->current, octets_tx->current, VTY_NEWLINE, + rtp_tx_dropped->current, VTY_NEWLINE + ); + + } } static void dump_endpoint(struct vty *vty, struct mgcp_endpoint *endp,