From 8df853711a3c776d77fed52b6393b09e6289963a Mon Sep 17 00:00:00 2001 From: oetiker Date: Sat, 8 Nov 2008 22:57:18 +0000 Subject: [PATCH] rrdcached: examine the current queue with the "QUEUE" command -- kevin git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1660 a5681a0c-68f1-0310-ab6d-d61299d08faa --- doc/rrdcached.pod | 8 ++++++++ src/rrd_daemon.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/doc/rrdcached.pod b/doc/rrdcached.pod index a346d60..274be6f 100644 --- a/doc/rrdcached.pod +++ b/doc/rrdcached.pod @@ -384,6 +384,14 @@ not yet been written to the underlying RRD file. Removes I from the cache. Any pending updates B. +=item B + +Shows the files that are on the output queue. Returns zero or more lines +in the following format, where Enum_valsE is the number of values +to be written for the EfileE: + + + =item B [I] Returns a short usage message. If no command is given, or I is diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index 2b8ac58..d56cf06 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -1076,6 +1076,7 @@ static int handle_request_help (listen_socket_t *sock, /* {{{ */ "FLUSHALL\n" "PENDING \n" "FORGET \n" + "QUEUE\n" "UPDATE [ ...]\n" "BATCH\n" "STATS\n" @@ -1121,6 +1122,18 @@ static int handle_request_help (listen_socket_t *sock, /* {{{ */ "Any pending updates for the file will be lost.\n" }; + char *help_queue[2] = + { + "Help for QUEUE\n" + , + "Shows all files in the output queue.\n" + "The output is zero or more lines in the following format:\n" + "(where is the number of values to be written)\n" + "\n" + " \n" + "\n" + }; + char *help_update[2] = { "Help for UPDATE\n" @@ -1190,6 +1203,8 @@ static int handle_request_help (listen_socket_t *sock, /* {{{ */ help_text = help_pending; else if (strcasecmp (command, "forget") == 0) help_text = help_forget; + else if (strcasecmp (command, "queue") == 0) + help_text = help_queue; else if (strcasecmp (command, "stats") == 0) help_text = help_stats; else if (strcasecmp (command, "batch") == 0) @@ -1383,6 +1398,24 @@ static int handle_request_forget(listen_socket_t *sock, /* {{{ */ assert(1==0); } /* }}} static int handle_request_forget */ +static int handle_request_queue (listen_socket_t *sock) /* {{{ */ +{ + cache_item_t *ci; + + pthread_mutex_lock(&cache_lock); + + ci = cache_queue_head; + while (ci != NULL) + { + add_response_info(sock, "%d %s\n", ci->values_num, ci->file); + ci = ci->next; + } + + pthread_mutex_unlock(&cache_lock); + + return send_response(sock, RESP_OK, "in queue.\n"); +} /* }}} int handle_request_queue */ + static int handle_request_update (listen_socket_t *sock, /* {{{ */ time_t now, char *buffer, size_t buffer_size) @@ -1642,6 +1675,8 @@ static int handle_request (listen_socket_t *sock, /* {{{ */ return (handle_request_pending(sock, buffer_ptr, buffer_size)); else if (strcasecmp (command, "forget") == 0) return (handle_request_forget(sock, buffer_ptr, buffer_size)); + else if (strcasecmp (command, "queue") == 0) + return (handle_request_queue(sock)); else if (strcasecmp (command, "stats") == 0) return (handle_request_stats (sock)); else if (strcasecmp (command, "help") == 0) -- 2.30.2