From 16e8f4ca350e4be98c2df22ab29c2d20a6554251 Mon Sep 17 00:00:00 2001 From: Mark Spencer Date: Sun, 24 Oct 2004 06:04:48 +0000 Subject: Allow "dundi flush" to flush statistics too git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4077 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- pbx/pbx_dundi.c | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'pbx/pbx_dundi.c') diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c index 43f673dc5..407d96953 100755 --- a/pbx/pbx_dundi.c +++ b/pbx/pbx_dundi.c @@ -1972,10 +1972,36 @@ static int dundi_do_store_history(int fd, int argc, char *argv[]) static int dundi_flush(int fd, int argc, char *argv[]) { - if (argc != 2) + int stats=0; + if ((argc < 2) || (argc > 3)) return RESULT_SHOWUSAGE; - ast_db_deltree("dundi/cache", NULL); - ast_cli(fd, "DUNDi Cache Flushed\n"); + if (argc > 2) { + if (!strcasecmp(argv[2], "stats")) + stats = 1; + else + return RESULT_SHOWUSAGE; + } + if (stats) { + /* Flush statistics */ + struct dundi_peer *p; + int x; + ast_mutex_lock(&peerlock); + p = peers; + while(p) { + for (x=0;xlookups[x]) + free(p->lookups[x]); + p->lookups[x] = NULL; + p->lookuptimes[x] = 0; + } + p->avgms = 0; + p = p->next; + } + ast_mutex_unlock(&peerlock); + } else { + ast_db_deltree("dundi/cache", NULL); + ast_cli(fd, "DUNDi Cache Flushed\n"); + } return RESULT_SUCCESS; } @@ -2410,8 +2436,10 @@ static char query_usage[] = "e164 if none is specified).\n"; static char flush_usage[] = -"Usage: dundi flush\n" -" Flushes DUNDi answer cache, used primarily for debug.\n"; +"Usage: dundi flush [stats]\n" +" Flushes DUNDi answer cache, used primarily for debug. If\n" +"'stats' is present, clears timer statistics instead of normal\n" +"operation.\n"; static struct ast_cli_entry cli_debug = { { "dundi", "debug", NULL }, dundi_do_debug, "Enable DUNDi debugging", debug_usage }; -- cgit v1.2.3