[asterisk-commits] oej: trunk r239663 - /trunk/channels/chan_sip.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jan 13 04:24:27 CST 2010
Author: oej
Date: Wed Jan 13 04:24:23 2010
New Revision: 239663
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=239663
Log:
SIP Show channelstats fix - use float division to show proper stats
(closes issue #15819)
Reported by: klaus3000
Patches:
asterisk-sip-show-channelstats-trunk.txt uploaded by klaus3000 (license 65)
Tested by: klaus3000, oej
This patch is for trunk only and will be blocked in 1.6.2
Modified:
trunk/channels/chan_sip.c
Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=239663&r1=239662&r2=239663
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Wed Jan 13 04:24:23 2010
@@ -16508,8 +16508,8 @@
/*! \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;
struct ast_rtp_instance_stats stats;
char durbuf[10];
@@ -16548,12 +16548,12 @@
stats.rxcount > (unsigned int) 100000 ? (unsigned int) (stats.rxcount)/(unsigned int) 1000 : stats.rxcount,
stats.rxcount > (unsigned int) 100000 ? "K":" ",
stats.rxploss,
- stats.rxcount > stats.rxploss ? (stats.rxploss / stats.rxcount * 100) : 0,
+ (stats.rxcount + stats.rxploss) > 0 ? (double) stats.rxploss / (stats.rxcount + stats.rxploss) * 100 : 0,
stats.rxjitter,
stats.txcount > (unsigned int) 100000 ? (unsigned int) (stats.txcount)/(unsigned int) 1000 : stats.txcount,
stats.txcount > (unsigned int) 100000 ? "K":" ",
stats.txploss,
- stats.txcount > stats.txploss ? (stats.txploss / stats.txcount * 100) : 0,
+ stats.txcount > 0 ? (double) stats.txploss / stats.txcount * 100 : 0,
stats.txjitter
);
arg->numchans++;
@@ -16581,7 +16581,7 @@
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" : "");
More information about the asterisk-commits
mailing list