]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
flush_stats feature for unbound-control.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 12 Feb 2009 10:37:00 +0000 (10:37 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 12 Feb 2009 10:37:00 +0000 (10:37 +0000)
git-svn-id: file:///svn/unbound/trunk@1477 be551aaa-1e26-0410-a405-d3ace91eadb9

daemon/remote.c
daemon/stats.c
daemon/worker.c
daemon/worker.h
doc/Changelog
doc/TODO
doc/unbound-control.8.in
smallapp/unbound-control.c

index b7de708fcad562fd73746138fe5292640a2152cc..a54644c66d97b0318f3db18b46f02c8d633bfdd0 100644 (file)
@@ -1048,6 +1048,14 @@ do_flush_type(SSL* ssl, struct worker* worker, char* arg)
        send_ok(ssl);
 }
 
+/** flush statistics */
+static void
+do_flush_stats(SSL* ssl, struct worker* worker)
+{
+       worker_stats_clear(worker);
+       send_ok(ssl);
+}
+
 /**
  * Local info for deletion functions
  */
@@ -1391,6 +1399,12 @@ execute_cmd(struct daemon_remote* rc, SSL* ssl, char* cmd,
        } else if(strncmp(p, "load_cache", 10) == 0) {
                if(load_cache(ssl, worker)) send_ok(ssl);
                return;
+       } else if(strncmp(p, "flush_stats", 11) == 0) {
+               /* must always distribute this cmd */
+               if(rc) 
+                       distribute_cmd(rc, ssl, cmd);
+               do_flush_stats(ssl, worker);
+               return;
        } else if(strncmp(p, "lookup", 6) == 0) {
                do_lookup(ssl, worker, skipwhite(p+6));
                return;
index 5d88ec9fc6479b8bab7cdb4ee0796b495a9cf1b4..465a57acfa101204efad48415c378e5220a911ec 100644 (file)
@@ -144,9 +144,7 @@ server_stats_compile(struct worker* worker, struct stats_info* s)
        s->svr.rrset_bogus = get_rrset_bogus(worker);
 
        if(!worker->env.cfg->stat_cumulative) {
-               server_stats_init(&worker->stats, worker->env.cfg);
-               mesh_stats_clear(worker->env.mesh);
-               worker->back->unwanted_replies = 0;
+               worker_stats_clear(worker);
        }
 }
 
index 553809c04f3d8ce056e0734cbe6f3a8a0d60563c..e87943f49652dd40fd2325055c1f4757d0054c56 100644 (file)
@@ -344,12 +344,10 @@ worker_handle_control_cmd(struct tube* ATTR_UNUSED(tube), uint8_t* msg,
                verbose(VERB_ALGO, "got control cmd stats");
                server_stats_reply(worker);
                break;
-#ifdef THREADS_DISABLED
        case worker_cmd_remote:
                verbose(VERB_ALGO, "got control cmd remote");
                daemon_remote_exec(worker);
                break;
-#endif
        default:
                log_err("bad command %d", (int)cmd);
                break;
@@ -964,9 +962,7 @@ void worker_stat_timer_cb(void* arg)
        mesh_stats(worker->env.mesh, "mesh has");
        worker_mem_report(worker, NULL);
        if(!worker->daemon->cfg->stat_cumulative) {
-               server_stats_init(&worker->stats, worker->env.cfg);
-               mesh_stats_clear(worker->env.mesh);
-               worker->back->unwanted_replies = 0;
+               worker_stats_clear(worker);
        }
        /* start next timer */
        worker_restart_timer(worker);
@@ -1221,6 +1217,13 @@ worker_alloc_cleanup(void* arg)
        slabhash_clear(worker->env.msg_cache);
 }
 
+void worker_stats_clear(struct worker* worker)
+{
+       server_stats_init(&worker->stats, worker->env.cfg);
+       mesh_stats_clear(worker->env.mesh);
+       worker->back->unwanted_replies = 0;
+}
+
 /* --- fake callbacks for fptr_wlist to work --- */
 int libworker_send_packet(ldns_buffer* ATTR_UNUSED(pkt), 
        struct sockaddr_storage* ATTR_UNUSED(addr), 
index 84b43980bcb9750e5d7831cc79fa31dff181bf63..14c2abcb7e71148aaaaf9ea39a874da346a648c0 100644 (file)
@@ -228,6 +228,12 @@ int worker_handle_service_reply(struct comm_point* c, void* arg, int error,
 /** cleanup the cache to remove all rrset IDs from it, arg is worker */
 void worker_alloc_cleanup(void* arg);
 
+/**
+ * Init worker stats - includes server_stats_init, outside network and mesh.
+ * @param worker: the worker to init
+ */
+void worker_stats_clear(struct worker* worker);
+
 /** statistics timer callback handler */
 void worker_stat_timer_cb(void* arg);
 
index 849551f0ee39cf9dca410bb99f3fd2d0985890c4..16dd3d0fe5163b4f66b314496f6109c415e9a028 100644 (file)
@@ -1,5 +1,7 @@
 12 February 2009: Wouter
        - call setusercontext if available (on BSD).
+       - small refactor of stats clearing.
+       - #227: flush_stats feature for unbound-control.
 
 10 February 2009: Wouter
        - keys with rfc5011 REVOKE flag are skipped and not considered when
index 2729d7298e01c4108e1d59ec68532e28b4b8c7f9..adb4c722f1f339e80fa9d998388c9ac1b2e5cfc0 100644 (file)
--- a/doc/TODO
+++ b/doc/TODO
@@ -59,8 +59,6 @@ o local-zone directive with authority service, full authority server
 o remote control read ssl information while priviledged.
  
 o infra and lame cache: easier size config (in Mb), show usage in graphs.
-o #226: unbound_control dump_requestlist
-o #227: unbound_control flush_stats
 o unbound_control get_stats_noreset
 o unbound_control forward [addr {addr}] | [off]
 o config entry to denote that a zone is to be treated as unsigned (even if 
index 578312b4e31723d6ef09f27694ee3c2469f43d2d..6c69a14f73e49881007b2345634a43d756a9d56d 100644 (file)
@@ -116,6 +116,9 @@ Remove all information at or below the name from the cache.
 The rrsets and key entries are removed so that new lookups will be performed.
 This needs to walk and inspect the entire cache, and is a slow operation.
 .TP
+.B flush_stats
+Reset statistics to zero.
+.TP
 .B dump_requestlist
 Show what is worked on.  Prints all queries that the server is currently
 working on.  Prints the time that users have been waiting.  For internal
index ea18903e1e77271c7b061ec6214c78b4f51e3024..fe11743bcfbe8d12d0f2382a3d42ab922e8f4699 100644 (file)
@@ -78,6 +78,7 @@ usage()
        printf("  flush_type [name] [type]      flush name, type from cache\n");
        printf("  flush_zone [name]             flush everything at or under name\n");
        printf("                                from rr and dnssec caches\n");
+       printf("  flush_stats                   flush statistics, make zero\n");
        printf("  dump_requestlist              show what is worked on\n");
        printf("Version %s\n", PACKAGE_VERSION);
        printf("BSD licensed, see LICENSE in source package for details.\n");