Commit 3ddf426c authored by Daniel Salzman's avatar Daniel Salzman

Merge branch 'ctl_status_augment' into 'master'

ctl: status: added options: version, workers, configure

Closes #507

See merge request !683
parents 245ae377 4fc34398
......@@ -9,6 +9,7 @@ m4_define([knot_VERSION_EXTRA],-dev)dnl
m4_define([knot_PKG_VERSION],[knot_VERSION_MAJOR.knot_VERSION_MINOR.knot_VERSION_PATCH]knot_VERSION_EXTRA)dnl
AC_INIT([knot], knot_PKG_VERSION, [knot-dns@labs.nic.cz])
configure_params="$*"
AM_INIT_AUTOMAKE([gnits subdir-objects no-dist-gzip dist-xz -Wall -Werror])
AM_SILENT_RULES([yes])
AC_CONFIG_SRCDIR([src/knot])
......@@ -26,6 +27,10 @@ AC_CONFIG_FILES([src/libknot/version.h
src/zscanner/version.h
src/dnssec/lib/dnssec/version.h])
# Store ./configure parameters into macro
AC_DEFINE_UNQUOTED([CONFIGURE_PARAMS],["$configure_params"],[Params passed to configure])
AC_DEFINE_UNQUOTED([CONFIGURE_CFLAGS],["$CFLAGS"],[Passed CFLAGS from environment])
# Updating version info
# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
AC_SUBST([libknot_VERSION_INFO],["-version-info 5:0:0"])
......@@ -531,23 +536,7 @@ AM_CONDITIONAL([HAVE_SPHINXBUILD], test "$SPHINXBUILD" != "false")
AM_CONDITIONAL([HAVE_PDFLATEX], test "$PDFLATEX" != "false")
AM_CONDITIONAL([HAVE_MAKEINFO], test "$MAKEINFO" != "false")
AC_CONFIG_FILES([Makefile
doc/Makefile
libtap/Makefile
tests/Makefile
tests-fuzz/Makefile
samples/Makefile
python/Makefile
src/Makefile
src/contrib/dnstap/Makefile
src/dnssec/Makefile
src/dnssec/tests/Makefile
src/zscanner/Makefile
])
AC_OUTPUT
AC_MSG_RESULT([
result_msg_base="
$PACKAGE $VERSION
Target: $host_os $host_cpu
......@@ -585,6 +574,29 @@ AC_MSG_RESULT([
Code coverage: ${enable_code_coverage}
Bash completions: ${bash_completions_output}
PKCS #11 support: ${enable_pkcs11}
"
result_msg_esc=$(echo -n "$result_msg_base" | sed 's/$/\\n/' | tr -d '\n')
result_msg_add="$result_msg_base
Continue with 'make' command
])
"
AC_DEFINE_UNQUOTED([CONFIGURE_SUMMARY],["$result_msg_esc"],[Configure summary])
AC_CONFIG_FILES([Makefile
doc/Makefile
libtap/Makefile
tests/Makefile
tests-fuzz/Makefile
samples/Makefile
python/Makefile
src/Makefile
src/contrib/dnstap/Makefile
src/dnssec/Makefile
src/dnssec/tests/Makefile
src/zscanner/Makefile
])
AC_OUTPUT
AC_MSG_RESULT([$result_msg_add])
......@@ -68,8 +68,10 @@ Print the program version.
.SS Actions
.INDENT 0.0
.TP
\fBstatus\fP
\fBstatus\fP [\fIdetail\fP]
Check if the server is running.
Moreover display either the running knotd version, numbers of worker threads,
or Knot DNS buid (configure) summary, if the parameter is specified.
.TP
\fBstop\fP
Stop the server if running.
......@@ -201,6 +203,8 @@ Use \fB@\fP \fIowner\fP to denote the zone name.
.sp
Type \fIitem\fP parameter in the form of \fIsection\fP[\fB[\fP\fIid\fP\fB]\fP][\fB\&.\fP\fIname\fP].
.sp
The \fIdetail\fP option for \fBstatus\fP can be one of words: version, workers, configure.
.sp
(*) indicates a local operation which requires a configuration.
.SS Interactive mode
.sp
......
......@@ -45,8 +45,10 @@ Parameters
Actions
.......
**status**
**status** [*detail*]
Check if the server is running.
Moreover display either the running knotd version, numbers of worker threads,
or Knot DNS buid (configure) summary, if the parameter is specified.
**stop**
Stop the server if running.
......@@ -179,6 +181,8 @@ Use **@** *owner* to denote the zone name.
Type *item* parameter in the form of *section*\ [**[**\ *id*\ **]**\ ][**.**\ *name*].
The *detail* option for **status** can be one of words: version, workers, configure.
(*) indicates a local operation which requires a configuration.
Interactive mode
......
......@@ -1150,10 +1150,24 @@ static int ctl_zone(ctl_args_t *args, ctl_cmd_t cmd)
static int ctl_server(ctl_args_t *args, ctl_cmd_t cmd)
{
int ret = KNOT_EOK;
char outbuf[2048] = { 0 };
switch (cmd) {
case CTL_STATUS:
ret = KNOT_EOK;
if (strcasecmp(args->data[KNOT_CTL_IDX_DATA], "version") == 0) {
snprintf(outbuf, sizeof(outbuf), "Version: %s", PACKAGE_VERSION);
} else if (strcasecmp(args->data[KNOT_CTL_IDX_DATA], "workers") == 0) {
snprintf(outbuf, sizeof(outbuf), "UDP workers: %zu, TCP workers %zu, "
"background workers: %zu", conf_udp_threads(conf()),
conf_tcp_threads(conf()), conf_bg_threads(conf()));
} else if (strcasecmp(args->data[KNOT_CTL_IDX_DATA], "configure") == 0) {
snprintf(outbuf, sizeof(outbuf), "%s", CONFIGURE_SUMMARY);
} else if (args->data[KNOT_CTL_IDX_DATA][0] != '\0') {
return KNOT_EINVAL;
}
args->data[KNOT_CTL_IDX_DATA] = outbuf;
ret = knot_ctl_send(args->ctl, KNOT_CTL_TYPE_DATA, &args->data);
break;
case CTL_STOP:
ret = KNOT_CTL_ESTOP;
......
......@@ -205,6 +205,11 @@ static void format_data(ctl_cmd_t cmd, knot_ctl_type_t data_type,
switch (cmd) {
case CTL_STATUS:
if (data_type == KNOT_CTL_TYPE_DATA &&
value != NULL && *value != '\0') {
printf("%s\n", value);
}
// FALLTHROUGH
case CTL_STOP:
case CTL_RELOAD:
case CTL_CONF_BEGIN:
......@@ -407,14 +412,15 @@ static int ctl_receive(cmd_args_t *args)
static int cmd_ctl(cmd_args_t *args)
{
int ret = check_args(args, 0, 0);
int ret = check_args(args, 0, (args->desc->cmd == CTL_STATUS ? 1 : 0));
if (ret != KNOT_EOK) {
return ret;
}
knot_ctl_data_t data = {
[KNOT_CTL_IDX_CMD] = ctl_cmd_to_str(args->desc->cmd),
[KNOT_CTL_IDX_FLAGS] = args->force ? CTL_FLAG_FORCE : NULL
[KNOT_CTL_IDX_FLAGS] = args->force ? CTL_FLAG_FORCE : NULL,
[KNOT_CTL_IDX_DATA] = (args->argc > 0 ? args->argv[0] : "")
};
// Send the command.
......@@ -961,7 +967,7 @@ static int cmd_conf_ctl(cmd_args_t *args)
const cmd_desc_t cmd_table[] = {
{ CMD_EXIT, NULL, CTL_NONE },
{ CMD_STATUS, cmd_ctl, CTL_STATUS },
{ CMD_STATUS, cmd_ctl, CTL_STATUS, CMD_FOPT_DATA},
{ CMD_STOP, cmd_ctl, CTL_STOP },
{ CMD_RELOAD, cmd_ctl, CTL_RELOAD },
{ CMD_STATS, cmd_stats_ctl, CTL_STATS },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment