return (0);
} /* }}} int flush_file */
+static int handle_request_help (int fd, /* {{{ */
+ char *buffer, size_t buffer_size)
+{
+ int status;
+ char **help_text;
+ size_t help_text_len;
+ char *command;
+ size_t i;
+
+ char *help_help[] =
+ {
+ "4 Command overview\n",
+ "FLUSH <filename>\n",
+ "HELP [<command>]\n",
+ "UPDATE <filename> <values> [<values> ...]\n",
+ "STATS\n"
+ };
+ size_t help_help_len = sizeof (help_help) / sizeof (help_help[0]);
+
+ char *help_flush[] =
+ {
+ "4 Help for FLUSH\n",
+ "Usage: FLUSH <filename>\n",
+ "\n",
+ "Adds the given filename to the head of the update queue and returns\n",
+ "after is has been dequeued.\n"
+ };
+ size_t help_flush_len = sizeof (help_flush) / sizeof (help_flush[0]);
+
+ char *help_update[] =
+ {
+ "9 Help for UPDATE\n",
+ "Usage: UPDATE <filename> <values> [<values> ...]\n"
+ "\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"
+ };
+ size_t help_update_len = sizeof (help_update) / sizeof (help_update[0]);
+
+ char *help_stats[] =
+ {
+ "4 Help for STATS\n",
+ "Usage: STATS\n",
+ "\n",
+ "Returns some performance counters, see the rrdcached(1) manpage for\n",
+ "a description of the values.\n"
+ };
+ size_t help_stats_len = sizeof (help_stats) / sizeof (help_stats[0]);
+
+ status = buffer_get_field (&buffer, &buffer_size, &command);
+ if (status != 0)
+ {
+ help_text = help_help;
+ help_text_len = help_help_len;
+ }
+ else
+ {
+ if (strcasecmp (command, "update") == 0)
+ {
+ help_text = help_update;
+ help_text_len = help_update_len;
+ }
+ else if (strcasecmp (command, "flush") == 0)
+ {
+ help_text = help_flush;
+ help_text_len = help_flush_len;
+ }
+ else if (strcasecmp (command, "stats") == 0)
+ {
+ help_text = help_stats;
+ help_text_len = help_stats_len;
+ }
+ else
+ {
+ help_text = help_help;
+ help_text_len = help_help_len;
+ }
+ }
+
+ for (i = 0; i < help_text_len; i++)
+ {
+ status = write (fd, help_text[i], strlen (help_text[i]));
+ if (status < 0)
+ {
+ status = errno;
+ RRDD_LOG (LOG_ERR, "handle_request_help: write(2) returned an error.");
+ return (status);
+ }
+ }
+
+ return (0);
+} /* }}} int handle_request_help */
+
static int handle_request_stats (int fd, /* {{{ */
char *buffer __attribute__((unused)),
size_t buffer_size __attribute__((unused)))
{
return (handle_request_stats (fd, buffer_ptr, buffer_size));
}
+ else if (strcasecmp (command, "help") == 0)
+ {
+ return (handle_request_help (fd, buffer_ptr, buffer_size));
+ }
else
{
char result[4096];