[sr-dev] git:andrei/counters: core: counters / statistics support

Andrei Pelinescu-Onciul andrei at iptel.org
Sun Aug 8 18:53:18 CEST 2010


Module: sip-router
Branch: andrei/counters
Commit: 4208dc00cf245559ed3152beace6084c7c6c4571
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=4208dc00cf245559ed3152beace6084c7c6c4571

Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Sun Aug  8 18:41:30 2010 +0200

core: counters / statistics support

Efficient counters support (api).
Incrementing or adding a value to a defined counter is extremely
fast at the cost of slower reading (each process has its own
set of counters => no cacheline ping-pong and no expensive atomic
operations).
All counters must be defined before forking (in a module this
means from mod_init() or init_child(rank==PROC_INIT)).
A counter is uniquely identified by its group and its name
(and not only by its name like in kamailio stats).

Example (error checking skipped):
	/* before forking, e.g. mod_init() */
	counter_handle_t h;
	/* declare the counter my_grp.foo */
	counter_register(&h, "my_grp", "foo", 0, 0, 0, 0);

	/* after forking */
	counter_inc(h);

	/* getting a counter value, knowing its group and name*/
	counter_lookup(&h, "my_grp", "foo");
	val = counter_get(h);

---

 counters.c |  696 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 counters.h |  124 +++++++++++
 main.c     |   10 +-
 3 files changed, 828 insertions(+), 2 deletions(-)

Diff:   http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commitdiff;h=4208dc00cf245559ed3152beace6084c7c6c4571



More information about the sr-dev mailing list