diff options
author | Mark Spencer <markster@digium.com> | 2005-01-30 06:50:46 +0000 |
---|---|---|
committer | Mark Spencer <markster@digium.com> | 2005-01-30 06:50:46 +0000 |
commit | 2491d3b75d696a458069c2161d0880d1cf96f47c (patch) | |
tree | b7bc1248cdb6dfb5995aa2b4c9c03d168f28fbef /channels/chan_iax2.c | |
parent | 0b04b3dfb29f126699ea37b7e0a837bf4b4b792e (diff) |
Improve logging and add summaries (bug #3459)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4926 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_iax2.c')
-rwxr-xr-x | channels/chan_iax2.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index c1ad88335..41671fede 100755 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -3566,6 +3566,10 @@ static int iax2_show_peers(int fd, int argc, char *argv[]) { regex_t regexbuf; int havepattern = 0; + int total_peers = 0; + int online_peers = 0; + int offline_peers = 0; + int unmonitored_peers = 0; #define FORMAT2 "%-15.15s %-15.15s %s %-15.15s %-8s %s %-10s\n" #define FORMAT "%-15.15s %-15.15s %s %-15.15s %-5d%s %s %-10s\n" @@ -3612,6 +3616,7 @@ static int iax2_show_peers(int fd, int argc, char *argv[]) char nm[20]; char status[20] = ""; char srch[2000] = ""; + total_peers++; if (registeredonly && !peer->addr.sin_addr.s_addr) continue; @@ -3623,16 +3628,26 @@ static int iax2_show_peers(int fd, int argc, char *argv[]) else strncpy(name, peer->name, sizeof(name) - 1); if (peer->maxms) { - if (peer->lastms < 0) + if (peer->lastms < 0) { strncpy(status, "UNREACHABLE", sizeof(status) - 1); - else if (peer->lastms > peer->maxms) + offline_peers++; + } + else if (peer->lastms > peer->maxms) { snprintf(status, sizeof(status), "LAGGED (%d ms)", peer->lastms); - else if (peer->lastms) + offline_peers++; + } + else if (peer->lastms) { snprintf(status, sizeof(status), "OK (%d ms)", peer->lastms); - else + online_peers++; + } + else { strncpy(status, "UNKNOWN", sizeof(status) - 1); - } else + offline_peers++; + } + } else { strncpy(status, "Unmonitored", sizeof(status) - 1); + unmonitored_peers++; + } strncpy(nm, ast_inet_ntoa(iabuf, sizeof(iabuf), peer->mask), sizeof(nm)-1); snprintf(srch, sizeof(srch), FORMAT, name, @@ -3651,6 +3666,8 @@ static int iax2_show_peers(int fd, int argc, char *argv[]) } ast_mutex_unlock(&peerl.lock); + ast_cli(fd,"%d iax2 peers [%d online, %d offline, %d unmonitored]\n", total_peers, online_peers, offline_peers, unmonitored_peers); + if (havepattern) regfree(®exbuf); @@ -4719,7 +4736,7 @@ static int iax2_ack_registry(struct iax_ies *ies, struct sockaddr_in *sin, int c else if (reg->messages > -1) snprintf(msgstatus, sizeof(msgstatus), " with no messages waiting\n"); snprintf(ourip, sizeof(ourip), "%s:%d", ast_inet_ntoa(iabuf, sizeof(iabuf), reg->us.sin_addr), ntohs(reg->us.sin_port)); - ast_verbose(VERBOSE_PREFIX_3 "Registered to '%s', who sees us as %s%s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ourip, msgstatus); + ast_verbose(VERBOSE_PREFIX_3 "Registered IAX2 to '%s', who sees us as %s%s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ourip, msgstatus); manager_event(EVENT_FLAG_SYSTEM, "Registry", "Channel: IAX2\r\nDomain: %s\r\nStatus: Registered\r\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr)); } reg->regstate = REG_STATE_REGISTERED; @@ -4878,13 +4895,13 @@ static int update_registry(char *name, struct sockaddr_in *sin, int callno, char if (!ast_test_flag(p, IAX_TEMPONLY) && sin->sin_addr.s_addr) { ast_db_put("IAX/Registry", p->name, data); if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Registered '%s' (%s) at %s:%d\n", p->name, + ast_verbose(VERBOSE_PREFIX_3 "Registered IAX2 '%s' (%s) at %s:%d\n", p->name, iaxs[callno]->state & IAX_STATE_AUTHENTICATED ? "AUTHENTICATED" : "UNAUTHENTICATED", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port)); manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: IAX2/%s\r\nPeerStatus: Registered\r\n", p->name);+ manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: IAX2/%s\r\nPeerStatus: Registered\r\n", p->name); register_peer_exten(p, 1); } else if (!ast_test_flag(p, IAX_TEMPONLY)) { if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Unregistered '%s' (%s)\n", p->name, + ast_verbose(VERBOSE_PREFIX_3 "Unregistered IAX2 '%s' (%s)\n", p->name, iaxs[callno]->state & IAX_STATE_AUTHENTICATED ? "AUTHENTICATED" : "UNAUTHENTICATED"); manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: IAX2/%s\r\nPeerStatus: Unregistered\r\n", p->name); register_peer_exten(p, 0); |