Update per-trunk global packet/byte counters in real-time
We used to update only the per-connection rx/tx packet/byte counters on-the-fly, but not the per-trunk global counters. The latter would only be updated at the end of a connection. As MGCP connections can last quite long (think of a long phone call) this is maybe not the best of ideas. Note: The all_rtp:err_tstmp_in and all_rt:err_tstmp_out are still only updated at the end of a connection. Change-Id: Ib3866cb8149d3257fcf39733846c97c33881c4ee Related: OS#4437
This commit is contained in:
parent
6c92f9d83e
commit
a48ff4a738
|
@ -259,7 +259,6 @@ aggregate_rtp_conn_stats(struct mgcp_trunk_config *trunk, struct mgcp_conn_rtp *
|
||||||
{
|
{
|
||||||
struct rate_ctr_group *all_stats = trunk->all_rtp_conn_stats;
|
struct rate_ctr_group *all_stats = trunk->all_rtp_conn_stats;
|
||||||
struct rate_ctr_group *conn_stats = conn_rtp->rate_ctr_group;
|
struct rate_ctr_group *conn_stats = conn_rtp->rate_ctr_group;
|
||||||
int i;
|
|
||||||
|
|
||||||
if (all_stats == NULL || conn_stats == NULL)
|
if (all_stats == NULL || conn_stats == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -269,8 +268,11 @@ aggregate_rtp_conn_stats(struct mgcp_trunk_config *trunk, struct mgcp_conn_rtp *
|
||||||
* All other counters in both counter groups correspond to each other. */
|
* All other counters in both counter groups correspond to each other. */
|
||||||
OSMO_ASSERT(conn_stats->desc->num_ctr + 1 == all_stats->desc->num_ctr);
|
OSMO_ASSERT(conn_stats->desc->num_ctr + 1 == all_stats->desc->num_ctr);
|
||||||
|
|
||||||
for (i = 0; i < conn_stats->desc->num_ctr; i++)
|
/* all other counters are [now] updated in real-time */
|
||||||
rate_ctr_add(&all_stats->ctr[i], conn_stats->ctr[i].current);
|
rate_ctr_add(&all_stats->ctr[IN_STREAM_ERR_TSTMP_CTR],
|
||||||
|
conn_stats->ctr[IN_STREAM_ERR_TSTMP_CTR].current);
|
||||||
|
rate_ctr_add(&all_stats->ctr[OUT_STREAM_ERR_TSTMP_CTR],
|
||||||
|
conn_stats->ctr[OUT_STREAM_ERR_TSTMP_CTR].current);
|
||||||
|
|
||||||
rate_ctr_inc(&all_stats->ctr[RTP_NUM_CONNECTIONS]);
|
rate_ctr_inc(&all_stats->ctr[RTP_NUM_CONNECTIONS]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,22 @@ enum {
|
||||||
MGCP_PROTO_RTCP,
|
MGCP_PROTO_RTCP,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void rtpconn_rate_ctr_add(struct mgcp_conn_rtp *conn_rtp, struct mgcp_endpoint *endp,
|
||||||
|
int id, int inc)
|
||||||
|
{
|
||||||
|
struct rate_ctr_group *conn_stats = conn_rtp->rate_ctr_group;
|
||||||
|
struct rate_ctr_group *trunk_stats = endp->tcfg->all_rtp_conn_stats;
|
||||||
|
|
||||||
|
/* add to both the per-connection and the per-trunk global stats */
|
||||||
|
rate_ctr_add(&conn_stats->ctr[id], inc);
|
||||||
|
rate_ctr_add(&trunk_stats->ctr[id], inc);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rtpconn_rate_ctr_inc(struct mgcp_conn_rtp *conn_rtp, struct mgcp_endpoint *endp, int id)
|
||||||
|
{
|
||||||
|
rtpconn_rate_ctr_add(conn_rtp, endp, id, 1);
|
||||||
|
}
|
||||||
|
|
||||||
/*! Determine the local rtp bind IP-address.
|
/*! Determine the local rtp bind IP-address.
|
||||||
* \param[out] addr caller provided memory to store the resulting IP-Address
|
* \param[out] addr caller provided memory to store the resulting IP-Address
|
||||||
* \param[in] endp mgcp endpoint, that holds a copy of the VTY parameters
|
* \param[in] endp mgcp endpoint, that holds a copy of the VTY parameters
|
||||||
|
@ -845,7 +861,7 @@ int mgcp_send(struct mgcp_endpoint *endp, int is_rtp, struct sockaddr_in *addr,
|
||||||
dest_name = conn_dst->conn->name;
|
dest_name = conn_dst->conn->name;
|
||||||
|
|
||||||
if (!rtp_end->output_enabled) {
|
if (!rtp_end->output_enabled) {
|
||||||
rate_ctr_inc(&conn_dst->rate_ctr_group->ctr[RTP_DROPPED_PACKETS_CTR]);
|
rtpconn_rate_ctr_inc(conn_dst, endp, RTP_DROPPED_PACKETS_CTR);
|
||||||
LOGPENDP(endp, DRTP, LOGL_DEBUG,
|
LOGPENDP(endp, DRTP, LOGL_DEBUG,
|
||||||
"output disabled, drop to %s %s "
|
"output disabled, drop to %s %s "
|
||||||
"rtp_port:%u rtcp_port:%u\n",
|
"rtp_port:%u rtcp_port:%u\n",
|
||||||
|
@ -924,8 +940,8 @@ int mgcp_send(struct mgcp_endpoint *endp, int is_rtp, struct sockaddr_in *addr,
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
return len;
|
return len;
|
||||||
|
|
||||||
rate_ctr_inc(&conn_dst->rate_ctr_group->ctr[RTP_PACKETS_TX_CTR]);
|
rtpconn_rate_ctr_inc(conn_dst, endp, RTP_PACKETS_TX_CTR);
|
||||||
rate_ctr_add(&conn_dst->rate_ctr_group->ctr[RTP_OCTETS_TX_CTR], len);
|
rtpconn_rate_ctr_add(conn_dst, endp, RTP_OCTETS_TX_CTR, len);
|
||||||
|
|
||||||
nbytes += len;
|
nbytes += len;
|
||||||
buflen = cont;
|
buflen = cont;
|
||||||
|
@ -942,8 +958,8 @@ int mgcp_send(struct mgcp_endpoint *endp, int is_rtp, struct sockaddr_in *addr,
|
||||||
&rtp_end->addr,
|
&rtp_end->addr,
|
||||||
rtp_end->rtcp_port, buf, len);
|
rtp_end->rtcp_port, buf, len);
|
||||||
|
|
||||||
rate_ctr_inc(&conn_dst->rate_ctr_group->ctr[RTP_PACKETS_TX_CTR]);
|
rtpconn_rate_ctr_inc(conn_dst, endp, RTP_PACKETS_TX_CTR);
|
||||||
rate_ctr_add(&conn_dst->rate_ctr_group->ctr[RTP_OCTETS_TX_CTR], len);
|
rtpconn_rate_ctr_add(conn_dst, endp, RTP_OCTETS_TX_CTR, len);
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
@ -1189,8 +1205,8 @@ static int mgcp_recv(int *proto, struct sockaddr_in *addr, char *buf,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Increment RX statistics */
|
/* Increment RX statistics */
|
||||||
rate_ctr_inc(&conn->rate_ctr_group->ctr[RTP_PACKETS_RX_CTR]);
|
rtpconn_rate_ctr_inc(conn, endp, RTP_PACKETS_RX_CTR);
|
||||||
rate_ctr_add(&conn->rate_ctr_group->ctr[RTP_OCTETS_RX_CTR], rc);
|
rtpconn_rate_ctr_add(conn, endp, RTP_OCTETS_RX_CTR, rc);
|
||||||
|
|
||||||
/* Forward a copy of the RTP data to a debug ip/port */
|
/* Forward a copy of the RTP data to a debug ip/port */
|
||||||
forward_data(fd->fd, &conn->tap_in, buf, rc);
|
forward_data(fd->fd, &conn->tap_in, buf, rc);
|
||||||
|
|
Loading…
Reference in New Issue