From: Wouter Wijngaards Date: Fri, 1 Aug 2014 13:24:46 +0000 (+0000) Subject: - Patch add msg, rrset, infra and key cache sizes to stats command X-Git-Tag: release-1.5.0rc1~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a9c3771049241c3283e709f3c33ba5b3ff029c0;p=thirdparty%2Funbound.git - Patch add msg, rrset, infra and key cache sizes to stats command from Maciej Soltysiak. git-svn-id: file:///svn/unbound/trunk@3203 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/Makefile.in b/Makefile.in index 7bd899723..091449db7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -961,7 +961,9 @@ stats.lo stats.o: $(srcdir)/daemon/stats.c config.h $(srcdir)/daemon/stats.h $(s $(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h $(srcdir)/util/module.h $(srcdir)/daemon/daemon.h \ $(srcdir)/services/modstack.h $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h \ $(srcdir)/services/outside_network.h $(srcdir)/util/config_file.h $(srcdir)/util/tube.h \ - $(srcdir)/util/net_help.h $(srcdir)/validator/validator.h $(srcdir)/validator/val_utils.h + $(srcdir)/util/net_help.h $(srcdir)/validator/validator.h $(srcdir)/validator/val_utils.h \ + $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h $(srcdir)/services/cache/infra.h \ + $(srcdir)/util/rtt.h $(srcdir)/validator/val_kcache.h unbound.lo unbound.o: $(srcdir)/daemon/unbound.c config.h $(srcdir)/util/log.h $(srcdir)/daemon/daemon.h \ $(srcdir)/util/locks.h $(srcdir)/util/alloc.h $(srcdir)/services/modstack.h $(srcdir)/daemon/remote.h \ $(srcdir)/util/config_file.h $(srcdir)/util/storage/slabhash.h $(srcdir)/util/storage/lruhash.h \ @@ -1035,7 +1037,9 @@ stats.lo stats.o: $(srcdir)/daemon/stats.c config.h $(srcdir)/daemon/stats.h $(s $(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h $(srcdir)/util/module.h $(srcdir)/daemon/daemon.h \ $(srcdir)/services/modstack.h $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h \ $(srcdir)/services/outside_network.h $(srcdir)/util/config_file.h $(srcdir)/util/tube.h \ - $(srcdir)/util/net_help.h $(srcdir)/validator/validator.h $(srcdir)/validator/val_utils.h + $(srcdir)/util/net_help.h $(srcdir)/validator/validator.h $(srcdir)/validator/val_utils.h \ + $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h $(srcdir)/services/cache/infra.h \ + $(srcdir)/util/rtt.h $(srcdir)/validator/val_kcache.h replay.lo replay.o: $(srcdir)/testcode/replay.c config.h $(srcdir)/util/log.h $(srcdir)/util/net_help.h \ $(srcdir)/util/config_file.h $(srcdir)/testcode/replay.h $(srcdir)/util/netevent.h $(srcdir)/testcode/testpkts.h \ $(srcdir)/util/rbtree.h $(srcdir)/testcode/fake_event.h $(srcdir)/ldns/str2wire.h $(srcdir)/ldns/rrdef.h diff --git a/contrib/unbound_munin_ b/contrib/unbound_munin_ index 6ca4902b9..1f9f39a3e 100755 --- a/contrib/unbound_munin_ +++ b/contrib/unbound_munin_ @@ -267,6 +267,10 @@ if test "$1" = "config" ; then p_config "mem.cache.message" "Message cache memory" p_config "mem.mod.iterator" "Iterator module memory" p_config "mem.mod.validator" "Validator module and key cache memory" + p_config "msg.cache.count" "msg cache count" + p_config "rrset.cache.count" "rrset cache count" + p_config "infra.cache.count" "infra cache count" + p_config "key.cache.count" "key cache count" echo "graph_info The memory used by unbound." ;; by_type) @@ -454,8 +458,9 @@ memory) fi fi echo "$mn.value" $value - for x in mem.cache.rrset mem.cache.message \ - mem.mod.iterator mem.mod.validator; do + for x in mem.cache.rrset mem.cache.message mem.mod.iterator \ + mem.mod.validator msg.cache.count rrset.cache.count \ + infra.cache.count key.cache.count; do print_value $x done ;; diff --git a/daemon/remote.c b/daemon/remote.c index 8ccc169d3..100aa8be1 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -876,6 +876,15 @@ print_ext(SSL* ssl, struct stats_info* s) (unsigned long)s->svr.unwanted_queries)) return 0; if(!ssl_printf(ssl, "unwanted.replies"SQ"%lu\n", (unsigned long)s->svr.unwanted_replies)) return 0; + /* cache counts */ + if(!ssl_printf(ssl, "msg.cache.count"SQ"%u\n", + (unsigned)s->svr.msg_cache_count)) return 0; + if(!ssl_printf(ssl, "rrset.cache.count"SQ"%u\n", + (unsigned)s->svr.rrset_cache_count)) return 0; + if(!ssl_printf(ssl, "infra.cache.count"SQ"%u\n", + (unsigned)s->svr.infra_cache_count)) return 0; + if(!ssl_printf(ssl, "key.cache.count"SQ"%u\n", + (unsigned)s->svr.key_cache_count)) return 0; return 1; } diff --git a/daemon/stats.c b/daemon/stats.c index 6abbfefca..d3f41de03 100644 --- a/daemon/stats.c +++ b/daemon/stats.c @@ -56,6 +56,9 @@ #include "util/net_help.h" #include "validator/validator.h" #include "ldns/sbuffer.h" +#include "services/cache/rrset.h" +#include "services/cache/infra.h" +#include "validator/val_kcache.h" /** add timers and the values do not overflow or become negative */ static void @@ -163,6 +166,14 @@ server_stats_compile(struct worker* worker, struct stats_info* s, int reset) /* get and reset validator rrset bogus number */ s->svr.rrset_bogus = get_rrset_bogus(worker); + /* get cache sizes */ + s->svr.msg_cache_count = count_slabhash_entries(worker->env.msg_cache); + s->svr.rrset_cache_count = count_slabhash_entries(&worker->env.rrset_cache->table); + s->svr.infra_cache_count = count_slabhash_entries(worker->env.infra_cache->hosts); + if(worker->env.key_cache) + s->svr.key_cache_count = count_slabhash_entries(worker->env.key_cache->slab); + else s->svr.key_cache_count = 0; + if(reset && !worker->env.cfg->stat_cumulative) { worker_stats_clear(worker); } diff --git a/daemon/stats.h b/daemon/stats.h index 92487b8b6..5ea00a0da 100644 --- a/daemon/stats.h +++ b/daemon/stats.h @@ -135,6 +135,15 @@ struct server_stats { * if all histograms are same size (is so by default) then * adding up works well. */ size_t hist[NUM_BUCKETS_HIST]; + + /** number of message cache entries */ + size_t msg_cache_count; + /** number of rrset cache entries */ + size_t rrset_cache_count; + /** number of infra cache entries */ + size_t infra_cache_count; + /** number of key cache entries */ + size_t key_cache_count; }; /** diff --git a/doc/Changelog b/doc/Changelog index 867bb23a3..15e9093ce 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,7 @@ +1 August 2014: Wouter + - Patch add msg, rrset, infra and key cache sizes to stats command + from Maciej Soltysiak. + 31 July 2014: Wouter - DNS64 from Viagenie (BSD Licensed), written by Simon Perrault. Initial commit of the patch from the FreeBSD base (with its fixes). diff --git a/doc/unbound-control.8.in b/doc/unbound-control.8.in index 88297e9f9..6478af010 100644 --- a/doc/unbound-control.8.in +++ b/doc/unbound-control.8.in @@ -463,6 +463,21 @@ Replies that were unwanted or unsolicited. Could have been random traffic, delayed duplicates, very late answers, or could be spoofing attempts. Some low level of late answers and delayed duplicates are to be expected with the UDP protocol. Very high values could indicate a threat (spoofing). +.TP +.I msg.cache.count +The number of items (DNS replies) in the message cache. +.TP +.I rrset.cache.count +The number of RRsets in the rrset cache. This includes rrsets used by +the messages in the message cache, but also delegation information. +.TP +.I infra.cache.count +The number of items in the infra cache. These are IP addresses with their +timing and protocol support information. +.TP +.I key.cache.count +The number of items in the key cache. These are DNSSEC keys, one item +per delegation point, and their validation status. .SH "FILES" .TP .I @ub_conf_file@ diff --git a/util/storage/slabhash.c b/util/storage/slabhash.c index 128edd84a..1a1255e52 100644 --- a/util/storage/slabhash.c +++ b/util/storage/slabhash.c @@ -217,3 +217,15 @@ void slabhash_traverse(struct slabhash* sh, int wr, for(i=0; isize; i++) lruhash_traverse(sh->array[i], wr, func, arg); } + +size_t count_slabhash_entries(struct slabhash* sh) +{ + size_t slab, cnt = 0; + + for(slab=0; slabsize; slab++) { + lock_quick_lock(&sh->array[slab]->lock); + cnt += sh->array[slab]->num; + lock_quick_unlock(&sh->array[slab]->lock); + } + return cnt; +} diff --git a/util/storage/slabhash.h b/util/storage/slabhash.h index cf968f965..031a9da0f 100644 --- a/util/storage/slabhash.h +++ b/util/storage/slabhash.h @@ -184,6 +184,13 @@ void slabhash_setmarkdel(struct slabhash* table, lruhash_markdelfunc_t md); void slabhash_traverse(struct slabhash* table, int wr, void (*func)(struct lruhash_entry*, void*), void* arg); +/* + * Count entries in slabhash. + * @param table: slabbed hash table; + * @return the number of items + */ +size_t count_slabhash_entries(struct slabhash* table); + /* --- test representation --- */ /** test structure contains test key */ struct slabhash_testkey {