Default-server instances are kept in memory after parsing as they may be
reused for dynamic servers added at runtime. Similarly, named defaults
proxies sections are preserved as dynamic backends rely on them. The command
- "show default-server" may be used to list them.
+ "show default-server" and "show defaults" may be used to list them.
This may consume a noticeable amount of memory if the number of default
instances is important. It's possible to reclaim this memory after the
By default, named defaults sections are preserved after configuration parsing.
This allows to reuse them for dynamic backends creation. This behavior can be
-changed globally via "tune.defaults.purge" keyword.
+changed globally via "tune.defaults.purge" keyword. It is possible to list the
+preserved instances via the command "show defaults".
All proxy names must be formed from upper and lower case letters, digits,
'-' (dash), '_' (underscore) , '.' (dot) and ':' (colon). ACL names are
All named default proxies can be used, given that they validate the same
inheritance rules applied during configuration parsing. There is some
- exceptions though, for example when the mode is neither TCP nor HTTP.
+ exceptions though, for example when the mode is neither TCP nor HTTP. The
+ available default proxy instances can be listed via the "show defaults"
+ additional command.
This command is restricted and can only be issued on sockets configured for
level "admin".
configuration parsing. These instances can be referenced via the server
keyword from during "add server".
+show defaults
+ Dump the list of named defaults proxies instances still present after
+ configuration parsing. These instances can be reused with "add backend"
+ command to serve as configuration for the newly created proxy.
+
show dev
This command is meant to centralize some information that HAProxy developers
might need to better understand the causes of a given problem. It generally
unsigned int dynpx_next_id = 0; /* lowest ID assigned to dynamic proxies */
-/* CLI context used during "show backend" and "show default-server" */
+/* CLI context used during "show backend" and "show default-server/defaults" */
struct show_be_ctx {
struct proxy *px;
struct watcher px_watch; /* watcher to automatically update px pointer on backend deletion */
return 1;
}
+/* Handler for "show defaults" command. */
+static int cli_io_handler_show_defaults(struct appctx *appctx)
+{
+ struct show_be_ctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx));
+
+ if (!ctx->px) {
+ /* No need to use ctx <px_watch> as defaults proxies cannot be removed at runtime. */
+ ctx->px = !LIST_ISEMPTY(&defaults_list) ?
+ LIST_ELEM(defaults_list.n, struct proxy *, el) : NULL;
+ }
+
+ while (ctx->px) {
+ chunk_reset(&trash);
+ chunk_appendf(&trash, "%s\n", ctx->px->id);
+
+ if (STRESS_RUN1(applet_putchk_stress(appctx, &trash) == -1,
+ applet_putchk(appctx, &trash) == -1)) {
+ return 0;
+ }
+
+ if (ctx->px->el.n == &defaults_list)
+ break;
+ ctx->px = LIST_ELEM(ctx->px->el.n, struct proxy *, el);
+ }
+
+ return 1;
+}
+
/* parse a "show servers [state|conn]" CLI line, returns 0 if it wants to start
* the dump or 1 if it stops immediately. If an argument is specified, it will
* reserve a show_srv_ctx context and set the proxy pointer into ->px, its ID
{ { "publish", "backend", NULL }, "publish backend <backend> : mark backend as ready for traffic", cli_parse_publish_backend, NULL, NULL },
{ { "set", "maxconn", "frontend", NULL }, "set maxconn frontend <frontend> <value> : change a frontend's maxconn setting", cli_parse_set_maxconn_frontend, NULL },
{ { "show", "default-server", NULL }, "show default-server [<backend>] : list default-server instances in all or a single backend", cli_parse_show_default_server, cli_io_handler_show_default_server, },
+ { { "show", "defaults", NULL }, "show defaults : list all proxies defaults sections", NULL, cli_io_handler_show_defaults },
{ { "show","servers", "conn", NULL }, "show servers conn [<backend>] : dump server connections status (all or for a single backend)", cli_parse_show_servers, cli_io_handler_servers_state },
{ { "show","servers", "state", NULL }, "show servers state [<backend>] : dump volatile server information (all or for a single backend)", cli_parse_show_servers, cli_io_handler_servers_state },
{ { "show", "backend", NULL }, "show backend : list backends in the current running config", NULL, cli_io_handler_show_backend },