rrdcached(1): Documented the protocol used by the daemon.
authorFlorian Forster <octo@leeloo.home.verplant.org>
Thu, 3 Jul 2008 15:14:04 +0000 (17:14 +0200)
committerFlorian Forster <octo@leeloo.home.verplant.org>
Thu, 3 Jul 2008 15:14:04 +0000 (17:14 +0200)
Some statistic values have been renamed. This has been changed in
src/rrd_daemon.c, too.

doc/rrdcached.pod
src/rrd_daemon.c

index 48ab188..f40f065 100644 (file)
@@ -192,6 +192,120 @@ files will be messed up good!
 
 You have been warned.
 
+=head1 PROTOCOL
+
+The daemon communicates with clients using a line based ASCII protocol which is
+easy to read and easy to type. This makes it easy for scripts to implement the
+protocol and possible for users to use L<telnet(1)> to connect to the daemon
+and test stuff "by hand".
+
+The protocol is line based, this means that each record consists of one or more
+lines. A line is terminated by the line feed character C<0x0A>, commonly
+written as C<\n>. In the examples below, this character will be written as
+C<E<lt>LFE<gt>> ("line feed").
+
+After the connection has been established, the client is expected to send a
+"command". A command consists of the command keyword, possibly some arguments,
+and a terminating newline character. For a list of commands, see
+L<Valid Commands> below.
+
+Example:
+
+  FLUSH /tmp/foo.rrd<LF>
+
+The daemon answers with a line consisting of a status code and a short status
+message, seperated by one or more space characters. A negative status code
+signals an error, a positive status code or zero signal success. If the status
+code is greater than zero, it indicates the number of lines that follow the
+status line.
+
+Examples:
+
+ 0 Success<LF>
+
+ 2 Two lines follow<LF>
+ This is the first line<LF>
+ And this is the second line<LF>
+
+=head2 Valid Commands
+
+The following commands are understood by the daemon:
+
+=over 4
+
+=item B<FLUSH> I<filename>
+
+Causes the daemon to put I<filename> to the B<head> of the update queue
+(possibly moving it there if the node is already enqueued). The answer will be
+sent B<after> the node has been dequeued.
+
+=item B<HELP> [I<command>]
+
+Returns a short usage message. If no command is given, or I<command> is
+B<HELP>, a list of commands supported by the daemon is returned. Otherwise a
+short description, possibly containing a pointer to a manpage, is returned.
+Obviously, this is meant for interactive usage and the format in which the
+commands and usage summaries are returned is not well defined.
+
+=item B<STATS>
+
+Returns a list of metrics which can be used to measure the daemons performance
+and check its status. For a description of the values returned, see
+L<Performance Values> below.
+
+The format in which the values are returned is similar to many other line based
+protocols: Each value is printed on a separate line, each consisting of the
+name of the value, a colon, one or more spaces and the actual value.
+
+Example:
+
+ 5 Statistics follow
+ QueueLength: 0
+ UpdatesWritten: 13
+ DataSetsWritten: 390
+ TreeNodesNumber: 13
+ TreeDepth: 4
+
+=item B<UPDATE> I<filename> I<values> [I<values> ...]
+
+Adds more data to a filename. This is B<the> operation the daemon was designed
+for, so describing the mechanism again is inappropriate. Read L<HOW IT WORKS>
+above for a detailed description.
+
+=back
+
+=head2 Performance Values
+
+The following counters are returned by the B<STATS> command:
+
+=over 4
+
+=item B<QueueLength> I<(unsigned 64bit integer)>
+
+Number of nodes currently enqueued in the update queue.
+
+=item B<TreeDepth> I<(unsigned 64bit integer)>
+
+Depth of the tree used for fast key lookup.
+
+=item B<TreeNodesNumber> I<(unsigned 64bit integer)>
+
+Number of nodes in the cache.
+
+=item B<UpdatesWritten> I<(unsigned 64bit integer)>
+
+Total number of updates, i.E<nbsp>e. calls to C<rrd_update_r>, since the daemon
+was started.
+
+=item B<DataSetsWritten> I<(unsigned 64bit integer)>
+
+Total number of "data sets" written to disk since the daemon was started. A
+data set is one or more values passed to the B<UPDATE> command. For example:
+C<N:123:456> is one data set with two values. The term "data set" is used to
+prevent confusion whether individual values or groups of values are counted.
+
+=back
+
 =head1 BUGS
 
 No known bugs at the moment.
index f912add..3295c7e 100644 (file)
@@ -166,8 +166,8 @@ static char **config_listen_address_list = NULL;
 static int config_listen_address_list_len = 0;
 
 static uint64_t stats_queue_length = 0;
-static uint64_t stats_updates_total = 0;
-static uint64_t stats_values_total = 0;
+static uint64_t stats_updates_written = 0;
+static uint64_t stats_data_sets_written = 0;
 static pthread_mutex_t stats_lock = PTHREAD_MUTEX_INITIALIZER;
 
 /* 
@@ -565,8 +565,8 @@ static void *queue_thread_main (void *args __attribute__((unused))) /* {{{ */
       free (values[i]);
 
     pthread_mutex_lock (&stats_lock);
-    stats_updates_total++;
-    stats_values_total += values_num;
+    stats_updates_written++;
+    stats_data_sets_written += values_num;
     pthread_mutex_unlock (&stats_lock);
 
     pthread_mutex_lock (&cache_lock);
@@ -785,21 +785,21 @@ static int handle_request_stats (int fd, /* {{{ */
   char outbuf[4096];
 
   uint64_t copy_queue_length;
-  uint64_t copy_updates_total;
-  uint64_t copy_values_total;
+  uint64_t copy_updates_written;
+  uint64_t copy_data_sets_written;
 
-  uint64_t tree_nodes;
+  uint64_t tree_nodes_number;
   uint64_t tree_depth;
 
   pthread_mutex_lock (&stats_lock);
-  copy_queue_length  = stats_queue_length;
-  copy_updates_total = stats_updates_total;
-  copy_values_total  = stats_values_total;
+  copy_queue_length       = stats_queue_length;
+  copy_updates_written    = stats_updates_written;
+  copy_data_sets_written  = stats_data_sets_written;
   pthread_mutex_unlock (&stats_lock);
 
   pthread_mutex_lock (&cache_lock);
-  tree_nodes = (uint64_t) g_tree_nnodes (cache_tree);
-  tree_depth = (uint64_t) g_tree_height (cache_tree);
+  tree_nodes_number = (uint64_t) g_tree_nnodes (cache_tree);
+  tree_depth        = (uint64_t) g_tree_height (cache_tree);
   pthread_mutex_unlock (&cache_lock);
 
 #define RRDD_STATS_SEND \
@@ -820,15 +820,15 @@ static int handle_request_stats (int fd, /* {{{ */
   RRDD_STATS_SEND;
 
   snprintf (outbuf, sizeof (outbuf),
-      "UpdatesWritten: %"PRIu64"\n", copy_updates_total);
+      "UpdatesWritten: %"PRIu64"\n", copy_updates_written);
   RRDD_STATS_SEND;
 
   snprintf (outbuf, sizeof (outbuf),
-      "ValuesWritten: %"PRIu64"\n", copy_values_total);
+      "DataSetsWritten: %"PRIu64"\n", copy_data_sets_written);
   RRDD_STATS_SEND;
 
   snprintf (outbuf, sizeof (outbuf),
-      "TreeNodesNumber: %"PRIu64"\n", tree_nodes);
+      "TreeNodesNumber: %"PRIu64"\n", tree_nodes_number);
   RRDD_STATS_SEND;
 
   snprintf (outbuf, sizeof (outbuf),