- RRDD_LOG (LOG_INFO, "handle_request: Unable parse command.");
- return (-1);
- }
-
- if (sock != NULL && sock->batch_start)
- sock->batch_cmd++;
-
- if (strcasecmp (command, "update") == 0)
- return (handle_request_update (sock, now, buffer_ptr, buffer_size));
- else if (strcasecmp (command, "wrote") == 0 && sock == NULL)
- {
- /* this is only valid in replay mode */
- return (handle_request_wrote (buffer_ptr, now));
- }
- else if (strcasecmp (command, "flush") == 0)
- return (handle_request_flush (sock, buffer_ptr, buffer_size));
- else if (strcasecmp (command, "flushall") == 0)
- return (handle_request_flushall(sock));
- else if (strcasecmp (command, "pending") == 0)
- 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)
- return (handle_request_help (sock, buffer_ptr, buffer_size));
- else if (strcasecmp (command, "batch") == 0 && sock != NULL)
- return batch_start(sock);
- else if (strcasecmp (command, ".") == 0 && sock != NULL && sock->batch_start)
- return batch_done(sock);
- else if (strcasecmp (command, "quit") == 0)
- return -1;
- else
- return send_response(sock, RESP_ERR, "Unknown command: %s\n", command);
-
- /* NOTREACHED */
- assert(1==0);
-} /* }}} int handle_request */
-
-/* MUST NOT hold journal_lock before calling this */
-static void journal_rotate(void) /* {{{ */
-{
- FILE *old_fh = NULL;
- int new_fd;
-
- if (journal_cur == NULL || journal_old == NULL)
- return;
-
- pthread_mutex_lock(&journal_lock);
-
- /* we rotate this way (rename before close) so that the we can release
- * the journal lock as fast as possible. Journal writes to the new
- * journal can proceed immediately after the new file is opened. The
- * fclose can then block without affecting new updates.
- */
- if (journal_fh != NULL)
+ "UPDATE",
+ handle_request_update,
+ CMD_CONTEXT_ANY,
+ "UPDATE <filename> <values> [<values> ...]\n"
+ ,
+ "Adds the given file to the internal cache if it is not yet known and\n"
+ "appends the given value(s) to the entry. See the rrdcached(1) manpage\n"
+ "for details.\n"
+ "\n"
+ "Each <values> has the following form:\n"
+ " <values> = <time>:<value>[:<value>[...]]\n"
+ "See the rrdupdate(1) manpage for details.\n"
+ },
+ {
+ "WROTE",
+ handle_request_wrote,
+ CMD_CONTEXT_JOURNAL,
+ NULL,
+ NULL
+ },
+ {
+ "FLUSH",
+ handle_request_flush,
+ CMD_CONTEXT_CLIENT | CMD_CONTEXT_BATCH,
+ "FLUSH <filename>\n"
+ ,
+ "Adds the given filename to the head of the update queue and returns\n"
+ "after it has been dequeued.\n"
+ },
+ {
+ "FLUSHALL",
+ handle_request_flushall,
+ CMD_CONTEXT_CLIENT,
+ "FLUSHALL\n"
+ ,
+ "Triggers writing of all pending updates. Returns immediately.\n"
+ },
+ {
+ "PENDING",
+ handle_request_pending,
+ CMD_CONTEXT_CLIENT,
+ "PENDING <filename>\n"
+ ,
+ "Shows any 'pending' updates for a file, in order.\n"
+ "The updates shown have not yet been written to the underlying RRD file.\n"
+ },