diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2009-06-20 21:17:43 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2009-06-20 21:17:43 +0200 |
commit | b524c764aba149018fa83dec742c21dc8116838e (patch) | |
tree | be9d180f154ecd55c0c48baaab82c5e119482c6d /src | |
parent | 4cfc8533743a766db0b2c8ae27b7bba312eb3ec0 (diff) | |
download | conntrack-tools-b524c764aba149018fa83dec742c21dc8116838e.tar.gz conntrack-tools-b524c764aba149018fa83dec742c21dc8116838e.zip |
conntrackd: add `-s queue' to display queue statistics
This patch re-introduces `-s queue' but now it displays generic
queue statistics.
# conntrackd -s queue
active queue objects: 0
queue txqueue:
current elements: 0
maximum elements: 2147483647
not enough space errors: 0
queue rsqueue:
current elements: 72
maximum elements: 128
not enough space errors: 0
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 6 | ||||
-rw-r--r-- | src/queue.c | 24 | ||||
-rw-r--r-- | src/sync-mode.c | 3 |
3 files changed, 32 insertions, 1 deletions
@@ -44,7 +44,7 @@ static const char usage_client_commands[] = " -i, display content of the internal cache\n" " -e, display the content of the external cache\n" " -k, kill conntrack daemon\n" - " -s [|network|cache|runtime|link|rsqueue], dump statistics\n" + " -s [|network|cache|runtime|link|rsqueue|queue], dump statistics\n" " -R, resync with kernel conntrack table\n" " -n, request resync with other node (only FT-FW and NOTRACK modes)\n" " -x, dump cache in XML format (requires -i or -e)\n" @@ -218,6 +218,10 @@ int main(int argc, char *argv[]) strlen(argv[i+1])) == 0) { action = STATS_PROCESS; i++; + } else if (strncmp(argv[i+1], "queue", + strlen(argv[i+1])) == 0) { + action = STATS_QUEUE; + i++; } else { fprintf(stderr, "ERROR: unknown " "parameter `%s' for " diff --git a/src/queue.c b/src/queue.c index e5dc307..6f5707f 100644 --- a/src/queue.c +++ b/src/queue.c @@ -20,8 +20,12 @@ #include "event.h" #include <errno.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/socket.h> + +static LIST_HEAD(queue_list); /* list of existing queues */ struct queue * queue_create(const char *name, int max_objects, unsigned int flags) @@ -45,17 +49,37 @@ queue_create(const char *name, int max_objects, unsigned int flags) } strncpy(b->name, name, QUEUE_NAMELEN); b->name[QUEUE_NAMELEN-1]='\0'; + list_add(&b->list, &queue_list); return b; } void queue_destroy(struct queue *b) { + list_del(&b->list); if (b->flags & QUEUE_F_EVFD) destroy_evfd(b->evfd); free(b); } +void queue_stats_show(int fd) +{ + struct queue *this; + int size = 0; + char buf[512]; + + list_for_each_entry(this, &queue_list, list) { + size += snprintf(buf+size, sizeof(buf), + "queue %s:\n" + "current elements:\t\t%12u\n" + "maximum elements:\t\t%12u\n\n", + this->name, + this->num_elems, + this->max_elems); + } + send(fd, buf, size, 0); +} + void queue_node_init(struct queue_node *n, int type) { INIT_LIST_HEAD(&n->head); diff --git a/src/sync-mode.c b/src/sync-mode.c index 308c08b..4d6956e 100644 --- a/src/sync-mode.c +++ b/src/sync-mode.c @@ -494,6 +494,9 @@ static int local_handler_sync(int fd, int type, void *data) multichannel_stats_extended(STATE_SYNC(channel), STATE_SYNC(interface), fd); break; + case STATS_QUEUE: + queue_stats_show(fd); + break; default: if (STATE_SYNC(sync)->local) ret = STATE_SYNC(sync)->local(fd, type, data); |