diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-02-01 03:00:28 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-02-01 03:00:28 +0000 |
commit | 2fa663856ed4100bb70c749d594427e4dfe4463f (patch) | |
tree | 60e87efa4ce73855a1cd170b1c57f1bf70c4caa0 /pbx/pbx_dundi.c | |
parent | d2d81ca374445d48290038fb3e15c42689115ec9 (diff) |
Add dundi show peers summary stats (bug #3474)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4939 f38db490-d61c-443f-a65b-d21fe96a405b
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 |