Dump info about map converters. Without argument, the list of all available
maps is returned. If a <map> is specified, its contents are dumped.
+show pools
+ Dump the status of internal memory pools. This is useful to track memory
+ usage when suspecting a memory leak for example. It does exactly the same
+ as the SIGQUIT when running in foreground except that it does not flush
+ the pools.
+
show sess
Dump all known sessions. Avoid doing this on slow connections as this can
be huge. This command is restricted and can only be issued on sockets
/* Dump statistics on pools usage.
*/
+void dump_pools_to_trash();
void dump_pools(void);
/*
STAT_CLI_O_MAPS, /* list all maps */
STAT_CLI_O_MAP, /* list all map entries of a map */
STAT_CLI_O_MLOOK, /* lookup a map entry */
+ STAT_CLI_O_POOLS, /* dump memory pools */
};
static int stats_dump_info_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 session *sess);
static int stats_dump_sess_to_buffer(struct stream_interface *si);
static int stats_dump_errors_to_buffer(struct stream_interface *si);
" prompt : toggle interactive mode with prompt\n"
" quit : disconnect\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"
appctx->st2 = STAT_ST_INIT;
appctx->st0 = STAT_CLI_O_INFO; // stats_dump_info_to_buffer
}
+ 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 (s->listener->bind_conf->level < ACCESS_LVL_OPER) {
case STAT_CLI_O_MLOOK:
if (stats_map_lookup(si))
appctx->st0 = STAT_CLI_PROMPT;
+ case STAT_CLI_O_POOLS:
+ if (stats_dump_pools_to_buffer(si))
+ appctx->st0 = STAT_CLI_PROMPT;
+ break;
default: /* abnormal state */
appctx->st0 = STAT_CLI_PROMPT;
break;
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->ib, &trash) == -1)
+ return 0;
+ return 1;
+}
+
/* Dumps a frontend's line to the trash for the current proxy <px> and uses
* the state from stream interface <si>. The caller is responsible for clearing
* the trash if needed. Returns non-zero if it emits anything, zero otherwise.
*
*/
+#include <types/global.h>
#include <common/config.h>
#include <common/debug.h>
#include <common/memory.h>
return NULL;
}
-/* Dump statistics on pools usage.
- */
-void dump_pools(void)
+/* This function dumps memory usage information into the trash buffer. */
+void dump_pools_to_trash()
{
struct pool_head *entry;
unsigned long allocated, used;
int nbpools;
allocated = used = nbpools = 0;
- qfprintf(stderr, "Dumping pools usage.\n");
+ chunk_printf(&trash, "Dumping pools usage. Use SIGQUIT to flush them.\n");
list_for_each_entry(entry, &pools, list) {
- qfprintf(stderr, " - Pool %s (%d bytes) : %d allocated (%u bytes), %d used, %d users%s\n",
+ chunk_appendf(&trash, " - Pool %s (%d bytes) : %d allocated (%u bytes), %d used, %d users%s\n",
entry->name, entry->size, entry->allocated,
entry->size * entry->allocated, entry->used,
entry->users, (entry->flags & MEM_F_SHARED) ? " [SHARED]" : "");
used += entry->used * entry->size;
nbpools++;
}
- qfprintf(stderr, "Total: %d pools, %lu bytes allocated, %lu used.\n",
+ chunk_appendf(&trash, "Total: %d pools, %lu bytes allocated, %lu used.\n",
nbpools, allocated, used);
}
+/* Dump statistics on pools usage. */
+void dump_pools(void)
+{
+ dump_pools_to_trash();
+ qfprintf(stderr, "%s", trash.str);
+}
+
/*
* Local variables:
* c-indent-level: 8