]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Patch add msg, rrset, infra and key cache sizes to stats command
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 1 Aug 2014 13:24:46 +0000 (13:24 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 1 Aug 2014 13:24:46 +0000 (13:24 +0000)
  from Maciej Soltysiak.

git-svn-id: file:///svn/unbound/trunk@3203 be551aaa-1e26-0410-a405-d3ace91eadb9

Makefile.in
contrib/unbound_munin_
daemon/remote.c
daemon/stats.c
daemon/stats.h
doc/Changelog
doc/unbound-control.8.in
util/storage/slabhash.c
util/storage/slabhash.h

index 7bd899723ccec67d8cf6f3be20f4ac5da1693636..091449db72890505cbc30e8615050e059decb882 100644 (file)
@@ -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
index 6ca4902b9cf16b749e64b362ed27cba0d1266101..1f9f39a3ebb223d9947cfb0a2d3558bdcdc647e0 100755 (executable)
@@ -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
        ;;
index 8ccc169d3835d96963bb1ddb3d411f50637a1060..100aa8be1c7355664965486fbf1ff36609294d93 100644 (file)
@@ -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;
 }
 
index 6abbfefca7fdf9e6cb83f353e791fbaffc92747e..d3f41de037b4b768fba0c2b770f7b0f384ab9d40 100644 (file)
@@ -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);
        }
index 92487b8b6273ff5f99e24a0ee00a385f60703add..5ea00a0da5b7111720fa6b036266aa236407c530 100644 (file)
@@ -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;
 };
 
 /** 
index 867bb23a3399292800695f30daa1af39dcd7a7c4..15e9093ceb4a9170adcf823a81447bfbdfe4372e 100644 (file)
@@ -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).
index 88297e9f934a3545644d071b2e6f7537018cb518..6478af0107be138153943a2a407680b8c1a90491 100644 (file)
@@ -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@
index 128edd84ad75a12e7086da6f83c40a86f23057a0..1a1255e52ae44f9422ff46e526064a7a71acfcc0 100644 (file)
@@ -217,3 +217,15 @@ void slabhash_traverse(struct slabhash* sh, int wr,
        for(i=0; i<sh->size; 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; slab<sh->size; slab++) {
+               lock_quick_lock(&sh->array[slab]->lock);
+                       cnt += sh->array[slab]->num;
+               lock_quick_unlock(&sh->array[slab]->lock);
+       }
+       return cnt;
+}
index cf968f9653d41aaeb2ef041046d8d3191d7bd0c6..031a9da0fac6aabd33979c810ed5b12c9229258b 100644 (file)
@@ -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 {