From 7f5a53998abfc9b199b713244fe8baf0a7c2b2fe Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sat, 17 Jan 2009 18:03:53 +0100 Subject: cache: add objects statistics This patch adds the object counter to `conntrackd -s cache'. This is useful to detect object leaks in runtime. This patch also changes the layout of the output to fit the display in less than 24 lines (assuming 24x80 terminal). Signed-off-by: Pablo Neira Ayuso --- src/cache.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/cache.c') diff --git a/src/cache.c b/src/cache.c index 1e08a33..a5f37dd 100644 --- a/src/cache.c +++ b/src/cache.c @@ -194,12 +194,14 @@ struct cache_object *cache_object_new(struct cache *c, struct nf_conntrack *ct) } memcpy(obj->ct, ct, nfct_sizeof(ct)); obj->status = C_OBJ_NONE; + c->stats.objects++; return obj; } void cache_object_free(struct cache_object *obj) { + obj->cache->stats.objects--; nfct_destroy(obj->ct); free(obj); } @@ -387,18 +389,16 @@ void cache_stats_extended(const struct cache *c, int fd) int size; size = snprintf(buf, sizeof(buf), - "cache:%s\tactive/total entries:\t%12u/%12u\n" - "\tcreation OK:\t\t\t%12u\n" - "\tcreation failed:\t\t%12u\n" + "cache:%s\tactive objects:\t\t%12u\n" + "\tactive/total entries:\t\t%12u/%12u\n" + "\tcreation OK/failed:\t\t%12u/%12u\n" "\t\tno memory available:\t%12u\n" "\t\tno space left in cache:\t%12u\n" - "\tupdate OK:\t\t\t%12u\n" - "\tupdate failed:\t\t\t%12u\n" + "\tupdate OK/failed:\t\t%12u/%12u\n" "\t\tentry not found:\t%12u\n" - "\tdeletion created:\t\t%12u\n" - "\tdeletion failed:\t\t%12u\n" - "\t\tentry not found:\t%12u\n", - c->name, + "\tdeletion created/failed:\t%12u/%12u\n" + "\t\tentry not found:\t%12u\n\n", + c->name, c->stats.objects, c->stats.active, hashtable_counter(c->h), c->stats.add_ok, c->stats.add_fail, -- cgit v1.2.3