5 rrdcached - Data caching daemon for rrdtool
9 B<rrdcached> [B<-l> I<address>] [B<-w> I<timeout>] [B<-f> I<timeout>]
13 B<rrdcached> is a daemon that receives updates to existing RRD files,
14 accumulates them and, if enough have been received or a defined time has
15 passed, writes the updates to the RRD file. A I<flush> command may be used to
16 force writing of values to disk, so that graphing facilities and similar can
17 work with up-to-date data.
19 The daemon was written with big setups in mind. Those setups usually run into
20 IOE<nbsp>related problems sooner or later for reasons that are beyond the scope
21 of this document. Check the wiki at the RRDTool homepage for details. Also
22 check L<SECURITY CONSIDERATIONS> below before using this daemon! A detailed
23 description of how the daemon operates can be found in the L<HOW IT WORKS>
30 =item B<-l> I<address>
32 Tells the daemon to bind to I<address> and accept incoming connections on that
33 socket. If I<address> begins with C<unix:>, everything following that prefix is
34 interpreted as the path to a UNIX domain socket. Otherwise the address or node
35 name are resolved using L<getaddrinfo(3)>.
37 If the B<-l> option is not specified the default address,
38 C<unix:/tmp/rrdcached.sock>, will be used.
40 =item B<-w> I<timeout>
42 Data is written to disk every I<timeout> seconds. If this option is not
43 specified the default interval of 300E<nbsp>seconds will be used.
45 =item B<-f> I<timeout>
47 Every I<timeout> seconds the entire cache is searched for old values which are
48 written to disk. This only concerns files to which updates have stopped, so
49 setting this to a high value, such as 3600E<nbsp>seconds, is acceptable in most
50 cases. This timeout defaults to 3600E<nbsp>seconds.
54 Sets the name and location of the PID-file. If not specified, the default,
55 C<I<$localststedir>/run/rrdcached.pid> will be used.
59 The daemon will change into a specific directory at startup. All files passed
60 to the daemon, that are specified by a B<relative> path, will be interpreted
61 to be relative to this directory. If not given the default, C</tmp>, will be
64 +------------------------+------------------------+
65 ! Command line ! File updated !
66 +------------------------+------------------------+
67 ! foo.rrd ! /tmp/foo.rrd !
68 ! foo/bar.rrd ! /tmp/foo/bar.rrd !
69 ! /var/lib/rrd/foo.rrd ! /var/lib/rrd/foo.rrd !
70 +------------------------+------------------------+
71 Paths given on the command line and paths actually
72 updated by the daemon, assuming the base directory
79 When receiving an update, B<rrdcached> does not write to disk but looks for an
80 entry for that file in its internal tree. If not found, an entry is created
81 including the current time (called "First" in the diagram below). This time is
82 B<not> the time specified on the command line but the time the operating system
83 considers to be "now". The value and time of the value (called "Time" in the
84 diagram below) are appended to the tree node.
86 When appending a value to a tree node, it is checked whether it's time to write
87 the values to disk. Values are written to disk if
88 S<C<now() - First E<gt>= timeout>>, where C<timeout> is the timeout specified
89 using the B<-w> option, see L<OPTIONS>. If the values are "old enough" they
90 will be enqueued in the "update queue", i.E<nbsp>e. they will be appended to
91 the linked list shown below. Because the tree nodes and the elements of the
92 linked list are the same data structures in memory, any update to a file that
93 has already been enqueued will be written with the next write to the RRD file,
96 A separate "update thread" constantly dequeues the first element in the update
97 queue and writes all its values to the appropriate file. So as long as the
98 update queue is not empty files are written at the highest possible rate.
100 Since the timeout of files is checked only when new values are added to the
101 file, "dead" files, i.E<nbsp>e. files that are not updated anymore, would never
102 be written to disk. Therefore, every now and then, controlled by the B<-f>
103 option, the entire tree is walked and all "old" values are enqueued. Since this
104 only affects "dead" files and walking the tree is relatively expensive, you
105 should set the "flush interval" to a reasonably high value. The default is
106 3600E<nbsp>seconds (one hour).
108 The downside of caching values is that they won't show up in graphs generated
109 from the RRDE<nbsp>files. To get around this, the daemon provides the "flush
110 command" to flush specific files. This means that the file is inserted at the
111 B<head> of the update queue or moved there if it is already enqueued. The flush
112 command will return after the update thread has dequeued the file, so there is
113 a good chance that the file has been updated by the time the client receives
114 the response from the daemon, but there is no guarantee.
116 +------+ +------+ +------+
117 ! head ! ! root ! ! tail !
118 +---+--+ +---+--+ +---+--+
122 ! /\/\ \ `----------------- ... --------, !
124 +---+----+---+ +------+-----+ +---+----+---+
125 ! File: foo ! ! File: bar ! ! File: qux !
126 ! First: 101 ! ! First: 119 ! ! First: 180 !
127 ! Next: ---+--->! Next: ---+---> ... --->! Next: - !
128 +============+ +============+ +============+
129 ! Time: 100 ! ! Time: 120 ! ! Time: 180 !
130 ! Value: 10 ! ! Value: 0.1 ! ! Value: 2,2 !
131 +------------+ +------------+ +------------+
132 ! Time: 110 ! ! Time: 130 ! ! Time: 190 !
133 ! Value: 26 ! ! Value: 0.1 ! ! Value: 7,3 !
134 +------------+ +------------+ +------------+
136 +------------+ +------------+ +------------+
137 ! Time: 230 ! ! Time: 250 ! ! Time: 310 !
138 ! Value: 42 ! ! Value: 0.2 ! ! Value: 1,2 !
139 +------------+ +------------+ +------------+
141 The above diagram demonstrates:
147 Files/values are stored in a (balanced) tree.
151 Tree nodes and entries in the update queue are the same data structure.
155 The local time ("First") and the time specified in updates ("Time") may differ.
159 Timed out values are inserted at the "tail".
163 Explicitly flushed values are inserted at the "head".
171 =head1 SECURITY CONSIDERATIONS
173 This daemon is meant to improve IOE<nbsp>performance for setups with thousands
174 of RRDE<nbsp>file to be updated. So security measures built into the daemon can
175 be summarized easily: B<There is no security built in!>
177 There is no authentication and authorization, so B<you> will have to take care
178 that only authorized clients can talk to the daemon. Since we assume that graph
179 collection is done on a dedicated machine, i.E<nbsp>e. the box doesn't do
180 anything else and especially does not have any interactive logins other than
181 root, a UNIX domain socket should take care of that.
183 If you (want to) use the network capability, i.E<nbsp>e. let the daemon bind to
184 an IPv4 or IPv6 socket, it is B<your> job to install a packet filter or similar
185 mechanism to prevent unauthorized connections. Unless you have a dedicated VLAN
186 or VPN for this, using the network option is probably a bad idea!
188 The daemon will blindly write to any file it gets told, so you really should
189 create a separate user just for this daemon. Also it does not do any sanity
190 checks, so if it gets told to write values for a time far in the future, your
191 files will be messed up good!
193 You have been warned.
197 The daemon communicates with clients using a line based ASCII protocol which is
198 easy to read and easy to type. This makes it easy for scripts to implement the
199 protocol and possible for users to use L<telnet(1)> to connect to the daemon
200 and test stuff "by hand".
202 The protocol is line based, this means that each record consists of one or more
203 lines. A line is terminated by the line feed character C<0x0A>, commonly
204 written as C<\n>. In the examples below, this character will be written as
205 C<E<lt>LFE<gt>> ("line feed").
207 After the connection has been established, the client is expected to send a
208 "command". A command consists of the command keyword, possibly some arguments,
209 and a terminating newline character. For a list of commands, see
210 L<Valid Commands> below.
214 FLUSH /tmp/foo.rrd<LF>
216 The daemon answers with a line consisting of a status code and a short status
217 message, separated by one or more space characters. A negative status code
218 signals an error, a positive status code or zero signal success. If the status
219 code is greater than zero, it indicates the number of lines that follow the
226 2 Two lines follow<LF>
227 This is the first line<LF>
228 And this is the second line<LF>
230 =head2 Valid Commands
232 The following commands are understood by the daemon:
236 =item B<FLUSH> I<filename>
238 Causes the daemon to put I<filename> to the B<head> of the update queue
239 (possibly moving it there if the node is already enqueued). The answer will be
240 sent B<after> the node has been dequeued.
242 =item B<HELP> [I<command>]
244 Returns a short usage message. If no command is given, or I<command> is
245 B<HELP>, a list of commands supported by the daemon is returned. Otherwise a
246 short description, possibly containing a pointer to a manual page, is returned.
247 Obviously, this is meant for interactive usage and the format in which the
248 commands and usage summaries are returned is not well defined.
252 Returns a list of metrics which can be used to measure the daemons performance
253 and check its status. For a description of the values returned, see
254 L<Performance Values> below.
256 The format in which the values are returned is similar to many other line based
257 protocols: Each value is printed on a separate line, each consisting of the
258 name of the value, a colon, one or more spaces and the actual value.
269 =item B<UPDATE> I<filename> I<values> [I<values> ...]
271 Adds more data to a filename. This is B<the> operation the daemon was designed
272 for, so describing the mechanism again is unnecessary. Read L<HOW IT WORKS>
273 above for a detailed explanation.
277 =head2 Performance Values
279 The following counters are returned by the B<STATS> command:
283 =item B<QueueLength> I<(unsigned 64bit integer)>
285 Number of nodes currently enqueued in the update queue.
287 =item B<TreeDepth> I<(unsigned 64bit integer)>
289 Depth of the tree used for fast key lookup.
291 =item B<TreeNodesNumber> I<(unsigned 64bit integer)>
293 Number of nodes in the cache.
295 =item B<UpdatesWritten> I<(unsigned 64bit integer)>
297 Total number of updates, i.E<nbsp>e. calls to C<rrd_update_r>, since the daemon
300 =item B<DataSetsWritten> I<(unsigned 64bit integer)>
302 Total number of "data sets" written to disk since the daemon was started. A
303 data set is one or more values passed to the B<UPDATE> command. For example:
304 C<N:123:456> is one data set with two values. The term "data set" is used to
305 prevent confusion whether individual values or groups of values are counted.
311 No known bugs at the moment.
315 L<rrdtool(1)>, L<rrdgraph(1)>
319 B<rrdcached> and this manual page have been written by Florian Forster
320 E<lt>octoE<nbsp>atE<nbsp>verplant.orgE<gt>.