/** do the stats command */
static void
-do_stats(SSL* ssl, struct daemon_remote* rc)
+do_stats(SSL* ssl, struct daemon_remote* rc, int reset)
{
struct daemon* daemon = rc->worker->daemon;
struct stats_info total;
int i;
/* gather all thread statistics in one place */
for(i=0; i<daemon->num; i++) {
- server_stats_obtain(rc->worker, daemon->workers[i], &s);
+ server_stats_obtain(rc->worker, daemon->workers[i], &s, reset);
if(!print_thread_stats(ssl, i, &s))
return;
if(i == 0)
} else if(strncmp(p, "reload", 6) == 0) {
do_reload(ssl, rc);
return;
+ } else if(strncmp(p, "stats_noreset", 13) == 0) {
+ do_stats(ssl, rc, 0);
+ return;
} else if(strncmp(p, "stats", 5) == 0) {
- do_stats(ssl, rc);
+ do_stats(ssl, rc, 1);
return;
} else if(strncmp(p, "status", 6) == 0) {
do_status(ssl, worker);
}
void
-server_stats_compile(struct worker* worker, struct stats_info* s)
+server_stats_compile(struct worker* worker, struct stats_info* s, int reset)
{
int i;
/* get and reset validator rrset bogus number */
s->svr.rrset_bogus = get_rrset_bogus(worker);
- if(!worker->env.cfg->stat_cumulative) {
+ if(reset && !worker->env.cfg->stat_cumulative) {
worker_stats_clear(worker);
}
}
void server_stats_obtain(struct worker* worker, struct worker* who,
- struct stats_info* s)
+ struct stats_info* s, int reset)
{
uint8_t *reply = NULL;
uint32_t len = 0;
if(worker == who) {
/* just fill it in */
- server_stats_compile(worker, s);
+ server_stats_compile(worker, s, reset);
return;
}
/* communicate over tube */
verbose(VERB_ALGO, "write stats cmd");
- worker_send_cmd(who, worker_cmd_stats);
+ if(reset)
+ worker_send_cmd(who, worker_cmd_stats);
+ else worker_send_cmd(who, worker_cmd_stats_noreset);
verbose(VERB_ALGO, "wait for stats reply");
if(!tube_read_msg(worker->cmd, &reply, &len, 0))
fatal_exit("failed to read stats over cmd channel");
free(reply);
}
-void server_stats_reply(struct worker* worker)
+void server_stats_reply(struct worker* worker, int reset)
{
struct stats_info s;
- server_stats_compile(worker, &s);
+ server_stats_compile(worker, &s, reset);
verbose(VERB_ALGO, "write stats replymsg");
if(!tube_write_msg(worker->daemon->workers[0]->cmd,
(uint8_t*)&s, sizeof(s), 0))
* @param worker: the worker that is executing (the first worker).
* @param who: on who to get the statistics info.
* @param s: the stats block to fill in.
+ * @param reset: if stats can be reset.
*/
void server_stats_obtain(struct worker* worker, struct worker* who,
- struct stats_info* s);
+ struct stats_info* s, int reset);
/**
* Compile stats into structure for this thread worker.
* Also clears the statistics counters (if that is set by config file).
* @param worker: the worker to compile stats for, also the executing worker.
* @param s: stats block.
+ * @param reset: if true, depending on config stats are reset.
+ * if false, statistics are not reset.
*/
-void server_stats_compile(struct worker* worker, struct stats_info* s);
+void server_stats_compile(struct worker* worker, struct stats_info* s,
+ int reset);
/**
* Send stats over comm tube in reply to query cmd
* @param worker: this worker.
+ * @param reset: if true, depending on config stats are reset.
+ * if false, statistics are not reset.
*/
-void server_stats_reply(struct worker* worker);
+void server_stats_reply(struct worker* worker, int reset);
/**
* Addup stat blocks.
break;
case worker_cmd_stats:
verbose(VERB_ALGO, "got control cmd stats");
- server_stats_reply(worker);
+ server_stats_reply(worker, 1);
+ break;
+ case worker_cmd_stats_noreset:
+ verbose(VERB_ALGO, "got control cmd stats_noreset");
+ server_stats_reply(worker, 0);
break;
case worker_cmd_remote:
verbose(VERB_ALGO, "got control cmd remote");
worker_cmd_quit,
/** obtain statistics */
worker_cmd_stats,
+ /** obtain statistics without statsclear */
+ worker_cmd_stats_noreset,
/** execute remote control command */
worker_cmd_remote
};
- call setusercontext if available (on BSD).
- small refactor of stats clearing.
- #227: flush_stats feature for unbound-control.
+ - stats_noreset feature for unbound-control.
10 February 2009: Wouter
- keys with rfc5011 REVOKE flag are skipped and not considered when
o remote control read ssl information while priviledged.
o infra and lame cache: easier size config (in Mb), show usage in graphs.
-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
a DS exists to higher trust anchor).
controlled using the \fBstatistics\-cumulative\fR config statement.
Statistics are printed with one [name]: [value] per line.
.TP
+.B stats_noreset
+Peek at statistics. Prints them like the \fBstats\fR command does, but does not
+reset the internal counters to zero.
+.TP
.B status
Display server status. Exit code 3 if not running (the connection to the
port is refused), 1 on error, 0 if running.
printf(" stop stops the server\n");
printf(" reload reloads the server\n");
printf(" stats print statistics\n");
+ printf(" stats_noreset peek at statistics\n");
printf(" status display status of server\n");
printf(" verbosity [number] change logging detail\n");
printf(" local_zone [name] [type] add new local zone\n");