mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
unbound-control status command.
git-svn-id: file:///svn/unbound/trunk@1395 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
d090698555
commit
d00c045084
5 changed files with 47 additions and 3 deletions
|
|
@ -1186,6 +1186,34 @@ do_flush_name(SSL* ssl, struct worker* worker, char* arg)
|
||||||
send_ok(ssl);
|
send_ok(ssl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** do the status command */
|
||||||
|
static void
|
||||||
|
do_status(SSL* ssl, struct worker* worker)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
time_t uptime;
|
||||||
|
if(!ssl_printf(ssl, "version: %s\n", PACKAGE_VERSION))
|
||||||
|
return;
|
||||||
|
if(!ssl_printf(ssl, "verbosity: %d\n", verbosity))
|
||||||
|
return;
|
||||||
|
if(!ssl_printf(ssl, "threads: %d\n", worker->daemon->num))
|
||||||
|
return;
|
||||||
|
if(!ssl_printf(ssl, "modules: %d [", worker->daemon->mods.num))
|
||||||
|
return;
|
||||||
|
for(i=0; i<worker->daemon->mods.num; i++) {
|
||||||
|
if(!ssl_printf(ssl, " %s", worker->daemon->mods.mod[i]->name))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!ssl_printf(ssl, " ]\n"))
|
||||||
|
return;
|
||||||
|
uptime = (time_t)time(NULL) - (time_t)worker->daemon->time_boot.tv_sec;
|
||||||
|
if(!ssl_printf(ssl, "uptime: %u seconds\n", (unsigned)uptime))
|
||||||
|
return;
|
||||||
|
if(!ssl_printf(ssl, "unbound (pid %d) is running...\n",
|
||||||
|
(int)getpid()))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/** tell other processes to execute the command */
|
/** tell other processes to execute the command */
|
||||||
void
|
void
|
||||||
distribute_cmd(struct daemon_remote* rc, SSL* ssl, char* cmd)
|
distribute_cmd(struct daemon_remote* rc, SSL* ssl, char* cmd)
|
||||||
|
|
@ -1221,6 +1249,9 @@ execute_cmd(struct daemon_remote* rc, SSL* ssl, char* cmd,
|
||||||
} else if(strncmp(p, "stats", 5) == 0) {
|
} else if(strncmp(p, "stats", 5) == 0) {
|
||||||
do_stats(ssl, rc);
|
do_stats(ssl, rc);
|
||||||
return;
|
return;
|
||||||
|
} else if(strncmp(p, "status", 6) == 0) {
|
||||||
|
do_status(ssl, worker);
|
||||||
|
return;
|
||||||
} else if(strncmp(p, "dump_cache", 10) == 0) {
|
} else if(strncmp(p, "dump_cache", 10) == 0) {
|
||||||
(void)dump_cache(ssl, worker);
|
(void)dump_cache(ssl, worker);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
17 December 2008: Wouter
|
17 December 2008: Wouter
|
||||||
- follows ldns makedist.sh. -rc option. autom4te dir removed.
|
- follows ldns makedist.sh. -rc option. autom4te dir removed.
|
||||||
|
- unbound-control status command.
|
||||||
|
|
||||||
16 December 2008: Wouter
|
16 December 2008: Wouter
|
||||||
- follow makedist improvements from ldns, for maintainers prereleases.
|
- follow makedist improvements from ldns, for maintainers prereleases.
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,10 @@ Print statistics. Resets the internal counters to zero, this can be
|
||||||
controlled using the \fBstatistics\-cumulative\fR config statement.
|
controlled using the \fBstatistics\-cumulative\fR config statement.
|
||||||
Statistics are printed with one [name]: [value] per line.
|
Statistics are printed with one [name]: [value] per line.
|
||||||
.TP
|
.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.
|
||||||
|
.TP
|
||||||
.B local_zone \fIname\fR \fItype
|
.B local_zone \fIname\fR \fItype
|
||||||
Add new local zone with name and type. Like \fBlocal\-zone\fR config statement.
|
Add new local zone with name and type. Like \fBlocal\-zone\fR config statement.
|
||||||
If the zone already exists, the type is changed to the given argument.
|
If the zone already exists, the type is changed to the given argument.
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,6 @@ enum localzone_type {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Authoritative local zones storage, shared.
|
* Authoritative local zones storage, shared.
|
||||||
* This tree is fixed at startup, so, readonly, no locks or mutexes necessary.
|
|
||||||
*/
|
*/
|
||||||
struct local_zones {
|
struct local_zones {
|
||||||
/** lock on the localzone tree */
|
/** lock on the localzone tree */
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ usage()
|
||||||
printf(" stop stops the server\n");
|
printf(" stop stops the server\n");
|
||||||
printf(" reload reloads the server\n");
|
printf(" reload reloads the server\n");
|
||||||
printf(" stats print statistics\n");
|
printf(" stats print statistics\n");
|
||||||
|
printf(" status display status of server\n");
|
||||||
printf(" verbosity [number] change logging detail\n");
|
printf(" verbosity [number] change logging detail\n");
|
||||||
printf(" local_zone [name] [type] add new local zone\n");
|
printf(" local_zone [name] [type] add new local zone\n");
|
||||||
printf(" local_zone_remove [name] remove local zone and its contents\n");
|
printf(" local_zone_remove [name] remove local zone and its contents\n");
|
||||||
|
|
@ -124,7 +125,7 @@ setup_ctx(struct config_file* cfg)
|
||||||
|
|
||||||
/** contact the server with TCP connect */
|
/** contact the server with TCP connect */
|
||||||
static int
|
static int
|
||||||
contact_server(const char* svr, struct config_file* cfg)
|
contact_server(const char* svr, struct config_file* cfg, int statuscmd)
|
||||||
{
|
{
|
||||||
struct sockaddr_storage addr;
|
struct sockaddr_storage addr;
|
||||||
socklen_t addrlen;
|
socklen_t addrlen;
|
||||||
|
|
@ -163,8 +164,16 @@ contact_server(const char* svr, struct config_file* cfg)
|
||||||
log_addr(0, "address", &addr, addrlen);
|
log_addr(0, "address", &addr, addrlen);
|
||||||
#ifndef USE_WINSOCK
|
#ifndef USE_WINSOCK
|
||||||
log_err("connect: %s", strerror(errno));
|
log_err("connect: %s", strerror(errno));
|
||||||
|
if(errno == ECONNREFUSED && statuscmd) {
|
||||||
|
printf("unbound is stopped\n");
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
log_err("connect: %s", wsa_strerror(WSAGetLastError()));
|
log_err("connect: %s", wsa_strerror(WSAGetLastError()));
|
||||||
|
if(WSAGetLastError() == WSAECONNREFUSED && statuscmd) {
|
||||||
|
printf("unbound is stopped\n");
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
@ -278,7 +287,7 @@ go(const char* cfgfile, char* svr, int argc, char* argv[])
|
||||||
ctx = setup_ctx(cfg);
|
ctx = setup_ctx(cfg);
|
||||||
|
|
||||||
/* contact server */
|
/* contact server */
|
||||||
fd = contact_server(svr, cfg);
|
fd = contact_server(svr, cfg, argc>0&&strcmp(argv[0],"status")==0);
|
||||||
ssl = setup_ssl(ctx, fd);
|
ssl = setup_ssl(ctx, fd);
|
||||||
|
|
||||||
/* send command */
|
/* send command */
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue