Module: sip-router Branch: master Commit: a98476c55ffdce59bff96ac63d00fad0c337b70b URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a98476c5...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Tue Jun 23 12:44:39 2009 +0200
tm: small wrapper to get TM stats via API
- used for K style statistics
---
modules/tm/t_stats.c | 13 +++++++++++++ modules/tm/t_stats.h | 3 +++ modules/tm/tm_load.c | 1 + modules/tm/tm_load.h | 2 ++ 4 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/modules/tm/t_stats.c b/modules/tm/t_stats.c index 9e2d192..627b379 100644 --- a/modules/tm/t_stats.c +++ b/modules/tm/t_stats.c @@ -175,6 +175,19 @@ void tm_rpc_stats(rpc_t* rpc, void* c) /* rpc->fault(c, 100, "Trying"); */ }
+int tm_get_stats(struct t_proc_stats *all) +{ + int i, pno; + if(all==NULL) + return -1; + + pno = get_max_procs(); + memset(all, 0, sizeof(struct t_proc_stats)); + for(i = 0; i < pno; i++) { + tm_proc_stats_add(all, all, &tm_stats[i].s); + } + return 0; +}
/* hash statistics */ diff --git a/modules/tm/t_stats.h b/modules/tm/t_stats.h index d38c751..734b4ad 100644 --- a/modules/tm/t_stats.h +++ b/modules/tm/t_stats.h @@ -147,4 +147,7 @@ void tm_rpc_stats(rpc_t* rpc, void* c); extern const char* tm_rpc_hash_stats_doc[2]; void tm_rpc_hash_stats(rpc_t* rpc, void* c);
+typedef int (*tm_get_stats_f)(struct t_proc_stats *all); +int tm_get_stats(struct t_proc_stats *all); + #endif diff --git a/modules/tm/tm_load.c b/modules/tm/tm_load.c index 22e1782..5fa054a 100644 --- a/modules/tm/tm_load.c +++ b/modules/tm/tm_load.c @@ -235,6 +235,7 @@ int load_tm( struct tm_binds *tmb) tmb->t_check = t_check; tmb->unref_cell = unref_cell; tmb->which_cancel = which_cancel; + tmb->get_stats = tm_get_stats;
#ifdef WITH_TM_CTX tmb->tm_ctx_get = tm_ctx_get; diff --git a/modules/tm/tm_load.h b/modules/tm/tm_load.h index 54c0b9a..2d5bf46 100644 --- a/modules/tm/tm_load.h +++ b/modules/tm/tm_load.h @@ -49,6 +49,7 @@ #include "callid.h" #include "t_cancel.h" #include "t_suspend.h" +#include "t_stats.h"
/* export not usable from scripts */ #define NO_SCRIPT -1 @@ -142,6 +143,7 @@ struct tm_binds { tcheck_f t_check; unref_cell_f unref_cell; which_cancel_f which_cancel; + tm_get_stats_f get_stats; #ifdef WITH_TM_CTX tm_ctx_get_f tm_ctx_get; #else