From: oetiker Date: Sat, 8 Nov 2008 22:57:18 +0000 (+0000) Subject: rrdcached: examine the current queue with the "QUEUE" command X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3ee1758173aa1ee577d7ca86bc3bead201300543;p=rrdtool-all.git rrdcached: examine the current queue with the "QUEUE" command -- kevin git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1660 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/doc/rrdcached.pod b/program/doc/rrdcached.pod index a346d601..274be6fa 100644 --- a/program/doc/rrdcached.pod +++ b/program/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/program/src/rrd_daemon.c b/program/src/rrd_daemon.c index 2b8ac581..d56cf06d 100644 --- a/program/src/rrd_daemon.c +++ b/program/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)