]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- stats reports tcp usage, of incoming-num-tcp buffers.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 5 Mar 2015 15:23:14 +0000 (15:23 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 5 Mar 2015 15:23:14 +0000 (15:23 +0000)
git-svn-id: file:///svn/unbound/trunk@3353 be551aaa-1e26-0410-a405-d3ace91eadb9

Makefile.in
daemon/remote.c
daemon/stats.c
daemon/stats.h
doc/Changelog
doc/unbound-control.8.in
util/netevent.c
util/netevent.h

index 0c7e0c638b9cc93f004e662abea4e840a270b366..bd3580701c73e508a0b4e6ab4bf70af7fff825e5 100644 (file)
@@ -1070,7 +1070,7 @@ stats.lo stats.o: $(srcdir)/daemon/stats.c config.h $(srcdir)/daemon/stats.h $(s
  $(srcdir)/util/netevent.h $(srcdir)/util/alloc.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h \
  $(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h $(srcdir)/util/module.h $(srcdir)/dnstap/dnstap.h \
   $(srcdir)/daemon/daemon.h $(srcdir)/services/modstack.h \
- $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h $(srcdir)/services/outside_network.h \
+ $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h $(srcdir)/services/outside_network.h $(srcdir)/services/listen_dnsport.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)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h \
  $(srcdir)/services/cache/infra.h $(srcdir)/util/rtt.h $(srcdir)/validator/val_kcache.h
index 65749568fddf07547a934e3a90d99e3753dcb2b6..6e8afeabb3cd2704c30c0c36995033c9327236d0 100644 (file)
@@ -724,6 +724,8 @@ print_stats(SSL* ssl, const char* nm, struct stats_info* s)
                (long long)avg.tv_sec, (int)avg.tv_usec)) return 0;
        if(!ssl_printf(ssl, "%s.recursion.time.median"SQ"%g\n", nm, 
                s->mesh_time_median)) return 0;
+       if(!ssl_printf(ssl, "%s.tcpusage"SQ"%lu\n", nm,
+               (unsigned long)s->svr.tcp_accept_usage)) return 0;
        return 1;
 }
 
index d3f41de037b4b768fba0c2b770f7b0f384ab9d40..7670590661b470e774acf70c99e250f3c4583114 100644 (file)
@@ -50,6 +50,7 @@
 #include "daemon/daemon.h"
 #include "services/mesh.h"
 #include "services/outside_network.h"
+#include "services/listen_dnsport.h"
 #include "util/config_file.h"
 #include "util/tube.h"
 #include "util/timehist.h"
@@ -140,6 +141,7 @@ void
 server_stats_compile(struct worker* worker, struct stats_info* s, int reset)
 {
        int i;
+       struct listen_list* lp;
 
        s->svr = worker->stats;
        s->mesh_num_states = worker->env.mesh->all.count;
@@ -174,6 +176,13 @@ server_stats_compile(struct worker* worker, struct stats_info* s, int reset)
                s->svr.key_cache_count = count_slabhash_entries(worker->env.key_cache->slab);
        else    s->svr.key_cache_count = 0;
 
+       /* get tcp accept usage */
+       s->svr.tcp_accept_usage = 0;
+       for(lp = worker->front->cps; lp; lp = lp->next) {
+               if(lp->com->type == comm_tcp_accept)
+                       s->svr.tcp_accept_usage += lp->com->cur_tcp_count;
+       }
+
        if(reset && !worker->env.cfg->stat_cumulative) {
                worker_stats_clear(worker);
        }
@@ -247,6 +256,7 @@ void server_stats_add(struct stats_info* total, struct stats_info* a)
                total->svr.rrset_bogus += a->svr.rrset_bogus;
                total->svr.unwanted_replies += a->svr.unwanted_replies;
                total->svr.unwanted_queries += a->svr.unwanted_queries;
+               total->svr.tcp_accept_usage += a->svr.tcp_accept_usage;
                for(i=0; i<STATS_QTYPE_NUM; i++)
                        total->svr.qtype[i] += a->svr.qtype[i];
                for(i=0; i<STATS_QCLASS_NUM; i++)
index 5ea00a0da5b7111720fa6b036266aa236407c530..6985446ce299a26ec1eadbbde63bf3148b43d5b7 100644 (file)
@@ -129,6 +129,8 @@ struct server_stats {
        size_t unwanted_replies;
        /** unwanted traffic received on client-facing ports */
        size_t unwanted_queries;
+       /** usage of tcp accept list */
+       size_t tcp_accept_usage;
 
        /** histogram data exported to array 
         * if the array is the same size, no data is lost, and
index 45f321ca1e03820acaf27f55b18935af56241204..4cb9fd38b18251d1aaae0db6b14268996c14f1d1 100644 (file)
@@ -2,6 +2,7 @@
        - contrib/unbound_smf22.tar.gz: Solaris SMF installation/removal
          scripts.  Contributed by Yuri Voinov.
        - Document that incoming-num-tcp increase is good for large servers.
+       - stats reports tcp usage, of incoming-num-tcp buffers.
 
 4 March 2015: Wouter
        - Patch from Brad Smith that syncs compat/getentropy_linux with
index b050ac7b46f1f2fefa7ec92b1ddf428eae28414a..259eee1d09604b19d2f0647d636554100b22e4fd 100644 (file)
@@ -322,6 +322,11 @@ less than this time.  Because of big outliers (usually queries to non
 responsive servers), the average can be bigger than the median.  This median
 has been calculated by interpolation from a histogram.
 .TP
+.I threadX.tcpusage
+The currently held tcp buffers for incoming connections.  A spot value on
+the time of the request.  This helps you spot if the incoming\-num\-tcp
+buffers are full.
+.TP
 .I total.num.queries
 summed over threads.
 .TP
@@ -355,6 +360,9 @@ summed over threads.
 .I total.recursion.time.median
 averaged over threads.
 .TP
+.I total.tcpusage
+summed over threads.
+.TP
 .I time.now
 current time in seconds since 1970.
 .TP
index c7ed30e6cd45967766d4b54743e692f5793069c9..b3729b8784a83ae9712bfde93f56f125502a4931 100644 (file)
@@ -879,12 +879,12 @@ comm_point_tcp_accept_callback(int fd, short event, void* arg)
        }
 
        /* grab the tcp handler buffers */
+       c->cur_tcp_count++;
        c->tcp_free = c_hdl->tcp_free;
        if(!c->tcp_free) {
                /* stop accepting incoming queries for now. */
                comm_point_stop_listening(c);
        }
-       /* addr is dropped. Not needed for tcp reply. */
        setup_tcp_handler(c_hdl, new_fd);
 }
 
@@ -902,6 +902,7 @@ reclaim_tcp_handler(struct comm_point* c)
        }
        comm_point_close(c);
        if(c->tcp_parent) {
+               c->tcp_parent->cur_tcp_count--;
                c->tcp_free = c->tcp_parent->tcp_free;
                c->tcp_parent->tcp_free = c;
                if(!c->tcp_free) {
@@ -1528,6 +1529,7 @@ comm_point_create_udp(struct comm_base *base, int fd, sldns_buffer* buffer,
        c->tcp_byte_count = 0;
        c->tcp_parent = NULL;
        c->max_tcp_count = 0;
+       c->cur_tcp_count = 0;
        c->tcp_handlers = NULL;
        c->tcp_free = NULL;
        c->type = comm_udp;
@@ -1578,6 +1580,7 @@ comm_point_create_udp_ancil(struct comm_base *base, int fd,
        c->tcp_byte_count = 0;
        c->tcp_parent = NULL;
        c->max_tcp_count = 0;
+       c->cur_tcp_count = 0;
        c->tcp_handlers = NULL;
        c->tcp_free = NULL;
        c->type = comm_udp;
@@ -1639,6 +1642,7 @@ comm_point_create_tcp_handler(struct comm_base *base,
        c->tcp_byte_count = 0;
        c->tcp_parent = parent;
        c->max_tcp_count = 0;
+       c->cur_tcp_count = 0;
        c->tcp_handlers = NULL;
        c->tcp_free = NULL;
        c->type = comm_tcp;
@@ -1691,6 +1695,7 @@ comm_point_create_tcp(struct comm_base *base, int fd, int num, size_t bufsize,
        c->tcp_byte_count = 0;
        c->tcp_parent = NULL;
        c->max_tcp_count = num;
+       c->cur_tcp_count = 0;
        c->tcp_handlers = (struct comm_point**)calloc((size_t)num,
                sizeof(struct comm_point*));
        if(!c->tcp_handlers) {
@@ -1758,6 +1763,7 @@ comm_point_create_tcp_out(struct comm_base *base, size_t bufsize,
        c->tcp_byte_count = 0;
        c->tcp_parent = NULL;
        c->max_tcp_count = 0;
+       c->cur_tcp_count = 0;
        c->tcp_handlers = NULL;
        c->tcp_free = NULL;
        c->type = comm_tcp;
@@ -1810,6 +1816,7 @@ comm_point_create_local(struct comm_base *base, int fd, size_t bufsize,
        c->tcp_byte_count = 0;
        c->tcp_parent = NULL;
        c->max_tcp_count = 0;
+       c->cur_tcp_count = 0;
        c->tcp_handlers = NULL;
        c->tcp_free = NULL;
        c->type = comm_local;
@@ -1857,6 +1864,7 @@ comm_point_create_raw(struct comm_base* base, int fd, int writing,
        c->tcp_byte_count = 0;
        c->tcp_parent = NULL;
        c->max_tcp_count = 0;
+       c->cur_tcp_count = 0;
        c->tcp_handlers = NULL;
        c->tcp_free = NULL;
        c->type = comm_raw;
index 37322ab933f044e82eca8f7ede509bb19dbea9e8..4b87cdba9e51b5a89b3e31fab575a5b621ba4f34 100644 (file)
@@ -164,6 +164,8 @@ struct comm_point {
        /* -------- TCP Accept -------- */
        /** the number of TCP handlers for this tcp-accept socket */
        int max_tcp_count;
+       /** current number of tcp handler in-use for this accept socket */
+       int cur_tcp_count;
        /** malloced array of tcp handlers for a tcp-accept, 
            of size max_tcp_count. */
        struct comm_point** tcp_handlers;