Procházet zdrojové kódy

tm: small wrapper to get TM stats via API

- used for K style statistics
Daniel-Constantin Mierla před 16 roky
rodič
revize
a98476c55f
4 změnil soubory, kde provedl 19 přidání a 0 odebrání
  1. 13 0
      modules/tm/t_stats.c
  2. 3 0
      modules/tm/t_stats.h
  3. 1 0
      modules/tm/tm_load.c
  4. 2 0
      modules/tm/tm_load.h

+ 13 - 0
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 */

+ 3 - 0
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

+ 1 - 0
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;

+ 2 - 0
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