aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_sip.c
diff options
context:
space:
mode:
authoroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2010-01-13 11:25:55 +0000
committeroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2010-01-13 11:25:55 +0000
commit678fa97145f41ab50a33d16d03f1350f2ae15581 (patch)
tree600f21ab9d05ee5d9275832c3867919f4a08cc91 /channels/chan_sip.c
parentd005a08746f9a50dc0b5b3bbe971639e6e5cb03b (diff)
Show proper stats in "sip show channelstats"
SIP show channelstats show current RTCP statistics for calls - if we have it. Calls bridged in RTP p2p bridge doesn't have any statistics. In calls where the remote end doesn't send RTCP or we can't receive it due to NAT, there's no reliable data as well. Thanks, Klaus, for the patch. Sorry for the delay. (closes issue #15819) Reported by: klaus3000 Patches: asterisk-sip-show-channelstats-1.6.2.txt uploaded by klaus3000 (license 65) Tested by: klaus3000, oej git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@239703 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r--channels/chan_sip.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 15890d500..6363e50b6 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -15804,11 +15804,10 @@ static char *sip_unregister(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
/*! \brief Callback for show_chanstats */
static int show_chanstats_cb(void *__cur, void *__arg, int flags)
{
-#define FORMAT2 "%-15.15s %-11.11s %-8.8s %-10.10s %-10.10s (%-2.2s) %-6.6s %-10.10s %-10.10s ( %%) %-6.6s\n"
-#define FORMAT "%-15.15s %-11.11s %-8.8s %-10.10u%-1.1s %-10.10u (%-2.2u%%) %-6.6u %-10.10u%-1.1s %-10.10u (%-2.2u%%) %-6.6u\n"
+#define FORMAT2 "%-15.15s %-11.11s %-8.8s %-10.10s %-10.10s ( %%) %-6.6s %-10.10s %-10.10s ( %%) %-6.6s\n"
+#define FORMAT "%-15.15s %-11.11s %-8.8s %-10.10u%-1.1s %-10.10u (%5.2f%%) %-6.6u %-10.10u%-1.1s %-10.10u (%5.2f%%) %-6.6u\n"
struct sip_pvt *cur = __cur;
- unsigned int rxcount;
- unsigned int txcount;
+ unsigned int rxcount, txcount, rxploss, txploss;
char durbuf[10];
int duration;
int durh, durm, durs;
@@ -15827,6 +15826,8 @@ static int show_chanstats_cb(void *__cur, void *__arg, int flags)
}
rxcount = ast_rtp_get_qosvalue(cur->rtp, AST_RTP_RXCOUNT);
txcount = ast_rtp_get_qosvalue(cur->rtp, AST_RTP_TXCOUNT);
+ rxploss = ast_rtp_get_qosvalue(cur->rtp, AST_RTP_RXPLOSS);
+ txploss = ast_rtp_get_qosvalue(cur->rtp, AST_RTP_TXPLOSS);
/* Find the duration of this channel */
if (c && c->cdr && !ast_tvzero(c->cdr->start)) {
@@ -15845,13 +15846,13 @@ static int show_chanstats_cb(void *__cur, void *__arg, int flags)
durbuf,
rxcount > (unsigned int) 100000 ? (unsigned int) (rxcount)/(unsigned int) 1000 : rxcount,
rxcount > (unsigned int) 100000 ? "K":" ",
- ast_rtp_get_qosvalue(cur->rtp, AST_RTP_RXPLOSS),
- rxcount > ast_rtp_get_qosvalue(cur->rtp, AST_RTP_RXPLOSS) ? (unsigned int) ((double) ast_rtp_get_qosvalue(cur->rtp, AST_RTP_RXPLOSS) / (ast_rtp_get_qosvalue(cur->rtp, AST_RTP_RXPLOSS) + rxcount) * 100) : 0,
+ rxploss,
+ (rxcount + rxploss) > 0 ? (double) rxploss / (rxcount + rxploss) * 100 : 0,
ast_rtp_get_qosvalue(cur->rtp, AST_RTP_RXJITTER),
txcount > (unsigned int) 100000 ? (unsigned int) (txcount)/(unsigned int) 1000 : txcount,
txcount > (unsigned int) 100000 ? "K":" ",
- ast_rtp_get_qosvalue(cur->rtp, AST_RTP_TXPLOSS),
- txcount > ast_rtp_get_qosvalue(cur->rtp, AST_RTP_TXPLOSS) ? (unsigned int) ((double) ast_rtp_get_qosvalue(cur->rtp, AST_RTP_TXPLOSS)/ txcount * 100) : 0,
+ txploss,
+ txcount > 0 ? (double) txploss / txcount * 100 : 0,
ast_rtp_get_qosvalue(cur->rtp, AST_RTP_TXJITTER)
);
arg->numchans++;
@@ -15879,7 +15880,7 @@ static char *sip_show_channelstats(struct ast_cli_entry *e, int cmd, struct ast_
if (a->argc != 3)
return CLI_SHOWUSAGE;
- ast_cli(a->fd, FORMAT2, "Peer", "Call ID", "Duration", "Recv: Pack", "Lost", "%", "Jitter", "Send: Pack", "Lost", "Jitter");
+ ast_cli(a->fd, FORMAT2, "Peer", "Call ID", "Duration", "Recv: Pack", "Lost", "Jitter", "Send: Pack", "Lost", "Jitter");
/* iterate on the container and invoke the callback on each item */
ao2_t_callback(dialogs, OBJ_NODATA, show_chanstats_cb, &arg, "callback to sip show chanstats");
ast_cli(a->fd, "%d active SIP channel%s\n", arg.numchans, (arg.numchans != 1) ? "s" : "");