diff --git a/include/types/cli.h b/include/types/cli.h index a7a85653f..a6fe57a0d 100644 --- a/include/types/cli.h +++ b/include/types/cli.h @@ -117,7 +117,6 @@ enum { STAT_CLI_O_CLR, /* clear tables */ STAT_CLI_O_SET, /* set entries in tables */ STAT_CLI_O_STAT, /* dump stats */ - STAT_CLI_O_POOLS, /* dump memory pools */ STAT_CLI_O_SERVERS_STATE, /* dump server state and changing information */ STAT_CLI_O_BACKEND, /* dump backend list */ STAT_CLI_O_ENV, /* dump environment */ diff --git a/src/cli.c b/src/cli.c index 7c8470810..e96c32381 100644 --- a/src/cli.c +++ b/src/cli.c @@ -137,7 +137,6 @@ static int stats_dump_backend_to_buffer(struct stream_interface *si); static int stats_dump_env_to_buffer(struct stream_interface *si); static int stats_dump_info_to_buffer(struct stream_interface *si); static int stats_dump_servers_state_to_buffer(struct stream_interface *si); -static int stats_dump_pools_to_buffer(struct stream_interface *si); static int stats_dump_full_sess_to_buffer(struct stream_interface *si, struct stream *sess); static int stats_dump_sess_to_buffer(struct stream_interface *si); static int stats_dump_errors_to_buffer(struct stream_interface *si); @@ -157,7 +156,6 @@ static const char stats_sock_usage_msg[] = " show backend : list backends in the current running config\n" " show env [var] : dump environment variables known to the process\n" " show info : report information about the running process\n" - " show pools : report information about the memory pools usage\n" " show stat : report counters for each proxy and server\n" " show errors : report last request and response errors for each proxy\n" " show sess [id] : report the list of current sessions or dump this session\n" @@ -1136,10 +1134,6 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line) appctx->st0 = STAT_CLI_O_SERVERS_STATE; // stats_dump_servers_state_to_buffer return 1; } - else if (strcmp(args[1], "pools") == 0) { - appctx->st2 = STAT_ST_INIT; - appctx->st0 = STAT_CLI_O_POOLS; // stats_dump_pools_to_buffer - } else if (strcmp(args[1], "sess") == 0) { appctx->st2 = STAT_ST_INIT; if (strm_li(s)->bind_conf->level < ACCESS_LVL_OPER) { @@ -1961,10 +1955,6 @@ static void cli_io_handler(struct appctx *appctx) if (stats_table_request(si, appctx->st0)) appctx->st0 = STAT_CLI_PROMPT; break; - case STAT_CLI_O_POOLS: - if (stats_dump_pools_to_buffer(si)) - appctx->st0 = STAT_CLI_PROMPT; - break; case STAT_CLI_O_ENV: /* environment dump */ if (stats_dump_env_to_buffer(si)) appctx->st0 = STAT_CLI_PROMPT; @@ -2344,20 +2334,6 @@ static int stats_dump_servers_state_to_buffer(struct stream_interface *si) return 1; } -/* This function dumps memory usage information onto the stream interface's - * read buffer. It returns 0 as long as it does not complete, non-zero upon - * completion. No state is used. - */ -static int stats_dump_pools_to_buffer(struct stream_interface *si) -{ - dump_pools_to_trash(); - if (bi_putchk(si_ic(si), &trash) == -1) { - si_applet_cant_put(si); - return 0; - } - return 1; -} - static inline const char *get_conn_ctrl_name(const struct connection *conn) { if (!conn_ctrl_ready(conn)) diff --git a/src/memory.c b/src/memory.c index 53ab4890a..4681d58f4 100644 --- a/src/memory.c +++ b/src/memory.c @@ -10,14 +10,23 @@ * */ +#include +#include #include +#include + #include #include #include #include #include +#include +#include +#include #include +#include +#include static struct list pools = LIST_HEAD_INIT(pools); int mem_poison_byte = -1; @@ -264,6 +273,39 @@ unsigned long pool_total_used() return used; } +/* This function dumps memory usage information onto the stream interface's + * read buffer. It returns 0 as long as it does not complete, non-zero upon + * completion. No state is used. + */ +static int cli_io_handler_dump_pools(struct appctx *appctx) +{ + struct stream_interface *si = appctx->owner; + + dump_pools_to_trash(); + if (bi_putchk(si_ic(si), &trash) == -1) { + si_applet_cant_put(si); + return 0; + } + return 1; +} + +static int cli_parse_show_pools(char **args, struct appctx *appctx, void *private) +{ + return 0; +} + +/* register cli keywords */ +static struct cli_kw_list cli_kws = {{ },{ + { { "show", "pools", NULL }, "show pools : report information about the memory pools usage", cli_parse_show_pools, cli_io_handler_dump_pools }, + {{},} +}}; + +__attribute__((constructor)) +static void __memory_init(void) +{ + cli_register_kw(&cli_kws); +} + /* * Local variables: * c-indent-level: 8