flush_stats feature for unbound-control.

git-svn-id: file:///svn/unbound/trunk@1477 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2009-02-12 10:37:00 +00:00
parent 95f5b577d4
commit e5a5749603
8 changed files with 35 additions and 10 deletions

View 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;

View 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);
}
}

View 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),

View 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);

View 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

View file

@ -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

View 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

View 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");