Index: channels/chan_iax2.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v retrieving revision 1.278 diff -a -u -r1.278 chan_iax2.c --- channels/chan_iax2.c 4 May 2005 04:49:32 -0000 1.278 +++ channels/chan_iax2.c 4 May 2005 21:48:19 -0000 @@ -603,6 +603,7 @@ AST_MUTEX_DEFINE_STATIC(dpcache_lock); static void destroy_peer(struct iax2_peer *peer); +static int ast_cli_netstats(int fd, int limit_fmt); static void iax_debug_output(const char *data) { @@ -4145,6 +4146,13 @@ #undef FORMAT2 } +static int manager_iax2_show_netstats( struct mansession *s, struct message *m ) +{ + ast_cli_netstats(s->fd, 0); + ast_cli(s->fd, "\r\n"); + return RESULT_SUCCESS; +} + static int iax2_show_firmware(int fd, int argc, char *argv[]) { #define FORMAT2 "%-15.15s %-15.15s %-15.15s\n" @@ -4310,25 +4318,26 @@ #undef FORMATB } -static int iax2_show_netstats(int fd, int argc, char *argv[]) +static int ast_cli_netstats(int fd, int limit_fmt) { int x; int numchans = 0; - if (argc != 3) - return RESULT_SHOWUSAGE; - ast_cli(fd, " -------- LOCAL --------------------- -------- REMOTE --------------------\n"); - ast_cli(fd, "Channel RTT Jit Del Lost %% Drop OOO Kpkts Jit Del Lost %% Drop OOO Kpkts\n"); for (x=0;xbridgecallno) - ast_cli(fd, "%-25.25s ", + if (iaxs[x]->bridgecallno) { + if (limit_fmt) + ast_cli(fd, "%-25.25s ", iaxs[x]->owner ? iaxs[x]->owner->name : "(None)"); - else + else + ast_cli(fd, "%s ", + iaxs[x]->owner ? iaxs[x]->owner->name : "(None)"); + } else #endif { int localjitter, localdelay, locallost, locallosspct, localdropped, localooo; + char *fmt; #ifdef NEWJB jb_info jbinfo; @@ -4359,7 +4368,11 @@ } locallost = locallosspct = localooo = -1; #endif - ast_cli(fd, "%-25.25s %4d %4d %4d %5d %3d %5d %4d %6d %4d %4d %5d %3d %5d %4d %6d\n", + if (limit_fmt) + fmt = "%-25.25s %4d %4d %4d %5d %3d %5d %4d %6d %4d %4d %5d %3d %5d %4d %6d\n"; + else + fmt = "%s %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n"; + ast_cli(fd, fmt, iaxs[x]->owner ? iaxs[x]->owner->name : "(None)", iaxs[x]->pingtime, localjitter, @@ -4382,6 +4395,17 @@ } ast_mutex_unlock(&iaxsl[x]); } + return numchans; +} + +static int iax2_show_netstats(int fd, int argc, char *argv[]) +{ + int numchans = 0; + if (argc != 3) + return RESULT_SHOWUSAGE; + ast_cli(fd, " -------- LOCAL --------------------- -------- REMOTE --------------------\n"); + ast_cli(fd, "Channel RTT Jit Del Lost %% Drop OOO Kpkts Jit Del Lost %% Drop OOO Kpkts\n"); + numchans = ast_cli_netstats(fd, 1); ast_cli(fd, "%d active IAX channel(s)\n", numchans); return RESULT_SUCCESS; } @@ -8932,6 +8956,7 @@ if (iaxs[x]) iax2_destroy(x); ast_manager_unregister( "IAXpeers" ); + ast_manager_unregister( "IAXnetstats" ); ast_unregister_application(papp); ast_cli_unregister(&cli_show_users); ast_cli_unregister(&cli_show_channels); @@ -9041,6 +9066,7 @@ ast_register_application(papp, iax2_prov_app, psyn, pdescrip); ast_manager_register( "IAXpeers", 0, manager_iax2_show_peers, "List IAX Peers" ); + ast_manager_register( "IAXnetstats", 0, manager_iax2_show_netstats, "Show IAX Netstats" ); set_config(config, 0);