diff options
author | Mark Spencer <markster@digium.com> | 2005-02-01 03:00:28 +0000 |
---|---|---|
committer | Mark Spencer <markster@digium.com> | 2005-02-01 03:00:28 +0000 |
commit | 9ae7f2430a1b31434f8b85027e20625e32bd1ea7 (patch) | |
tree | 60e87efa4ce73855a1cd170b1c57f1bf70c4caa0 /pbx/pbx_dundi.c | |
parent | 6ed8f1526056d508e29fa038b6460822be19b09b (diff) |
Add dundi show peers summary stats (bug #3474)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4939 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'pbx/pbx_dundi.c')
-rwxr-xr-x | pbx/pbx_dundi.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c index dc3ee80ed..9644eed1b 100755 --- a/pbx/pbx_dundi.c +++ b/pbx/pbx_dundi.c @@ -2462,6 +2462,11 @@ static int dundi_show_peers(int fd, int argc, char *argv[]) int registeredonly=0; char avgms[20]; char eid_str[20]; + int online_peers = 0; + int offline_peers = 0; + int unmonitored_peers = 0; + int total_peers = 0; + if ((argc != 3) && (argc != 4) && (argc != 5)) return RESULT_SHOWUSAGE; if ((argc == 4)) { @@ -2476,19 +2481,30 @@ static int dundi_show_peers(int fd, int argc, char *argv[]) char status[20] = ""; int print_line = -1; char srch[2000] = ""; + total_peers++; if (registeredonly && !peer->addr.sin_addr.s_addr) continue; 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++; + } if (peer->avgms) snprintf(avgms, sizeof(avgms), "%d ms", peer->avgms); else @@ -2515,6 +2531,7 @@ static int dundi_show_peers(int fd, int argc, char *argv[]) peer->dynamic ? "(D)" : "(S)", model2str(peer->model), avgms, status); } } + ast_cli(fd, "%d dundi peers [%d online, %d offline, %d unmonitored]\n", total_peers, online_peers, offline_peers, unmonitored_peers); ast_mutex_unlock(&peerlock); return RESULT_SUCCESS; #undef FORMAT |