Code

Imported upstream version 1.4.8
[pkg-rrdtool.git] / doc / rrdcached.1
1 .\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16)
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
6 .if t .sp .5v
7 .if n .sp
8 ..
9 .de Vb \" Begin verbatim text
10 .ft CW
11 .nf
12 .ne \\$1
13 ..
14 .de Ve \" End verbatim text
15 .ft R
16 .fi
17 ..
18 .\" Set up some character translations and predefined strings.  \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
21 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
24 .tr \(*W-
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
26 .ie n \{\
27 .    ds -- \(*W-
28 .    ds PI pi
29 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
31 .    ds L" ""
32 .    ds R" ""
33 .    ds C` ""
34 .    ds C' ""
35 'br\}
36 .el\{\
37 .    ds -- \|\(em\|
38 .    ds PI \(*p
39 .    ds L" ``
40 .    ds R" ''
41 'br\}
42 .\"
43 .\" Escape single quotes in literal strings from groff's Unicode transform.
44 .ie \n(.g .ds Aq \(aq
45 .el       .ds Aq '
46 .\"
47 .\" If the F register is turned on, we'll generate index entries on stderr for
48 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
49 .\" entries marked with X<> in POD.  Of course, you'll have to process the
50 .\" output yourself in some meaningful fashion.
51 .ie \nF \{\
52 .    de IX
53 .    tm Index:\\$1\t\\n%\t"\\$2"
54 ..
55 .    nr % 0
56 .    rr F
57 .\}
58 .el \{\
59 .    de IX
60 ..
61 .\}
62 .\"
63 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
64 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
65 .    \" fudge factors for nroff and troff
66 .if n \{\
67 .    ds #H 0
68 .    ds #V .8m
69 .    ds #F .3m
70 .    ds #[ \f1
71 .    ds #] \fP
72 .\}
73 .if t \{\
74 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
75 .    ds #V .6m
76 .    ds #F 0
77 .    ds #[ \&
78 .    ds #] \&
79 .\}
80 .    \" simple accents for nroff and troff
81 .if n \{\
82 .    ds ' \&
83 .    ds ` \&
84 .    ds ^ \&
85 .    ds , \&
86 .    ds ~ ~
87 .    ds /
88 .\}
89 .if t \{\
90 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
91 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
92 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
93 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
94 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
95 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
96 .\}
97 .    \" troff and (daisy-wheel) nroff accents
98 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
99 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
100 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
101 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
102 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
103 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
104 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
105 .ds ae a\h'-(\w'a'u*4/10)'e
106 .ds Ae A\h'-(\w'A'u*4/10)'E
107 .    \" corrections for vroff
108 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
109 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
110 .    \" for low resolution devices (crt and lpr)
111 .if \n(.H>23 .if \n(.V>19 \
112 \{\
113 .    ds : e
114 .    ds 8 ss
115 .    ds o a
116 .    ds d- d\h'-1'\(ga
117 .    ds D- D\h'-1'\(hy
118 .    ds th \o'bp'
119 .    ds Th \o'LP'
120 .    ds ae ae
121 .    ds Ae AE
122 .\}
123 .rm #[ #] #H #V #F C
124 .\" ========================================================================
125 .\"
126 .IX Title "RRDCACHED 1"
127 .TH RRDCACHED 1 "2013-05-23" "1.4.8" "rrdtool"
128 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
129 .\" way too many mistakes in technical documents.
130 .if n .ad l
131 .nh
132 .SH "NAME"
133 rrdcached \- Data caching daemon for rrdtool
134 .SH "SYNOPSIS"
135 .IX Header "SYNOPSIS"
136 \&\fBrrdcached\fR
137 [\fB\-P\fR\ \fIpermissions\fR]
138 [\fB\-l\fR\ \fIaddress\fR]
139 [\fB\-s\fR\ \fIgroup\fR]
140 [\fB\-w\fR\ \fItimeout\fR]
141 [\fB\-z\fR\ \fIdelay\fR]
142 [\fB\-f\fR\ \fItimeout\fR]
143 [\fB\-p\fR\ \fIpid_file\fR]
144 [\fB\-t\fR\ \fIwrite_threads\fR]
145 [\fB\-j\fR\ \fIjournal_dir\fR]
146 [\-F]
147 [\-g]
148 [\fB\-b\fR\ \fIbase_dir\fR\ [\fB\-B\fR]]
149 .SH "DESCRIPTION"
150 .IX Header "DESCRIPTION"
151 \&\fBrrdcached\fR is a daemon that receives updates to existing \s-1RRD\s0 files,
152 accumulates them and, if enough have been received or a defined time has
153 passed, writes the updates to the \s-1RRD\s0 file. A \fIflush\fR command may be used to
154 force writing of values to disk, so that graphing facilities and similar can
155 work with up-to-date data.
156 .PP
157 The daemon was written with big setups in mind. Those setups usually run into
158 \&\s-1IO\s0\ related problems sooner or later for reasons that are beyond the scope
159 of this document. Check the wiki at the RRDtool homepage for details. Also
160 check \*(L"\s-1SECURITY\s0 \s-1CONSIDERATIONS\s0\*(R" below before using this daemon! A detailed
161 description of how the daemon operates can be found in the \*(L"\s-1HOW\s0 \s-1IT\s0 \s-1WORKS\s0\*(R"
162 section below.
163 .SH "OPTIONS"
164 .IX Header "OPTIONS"
165 .IP "\fB\-l\fR \fIaddress\fR" 4
166 .IX Item "-l address"
167 Tells the daemon to bind to \fIaddress\fR and accept incoming connections on that
168 socket. If \fIaddress\fR begins with \f(CW\*(C`unix:\*(C'\fR, everything following that prefix is
169 interpreted as the path to a \s-1UNIX\s0 domain socket. Otherwise the address or node
170 name are resolved using \f(CW\*(C`getaddrinfo()\*(C'\fR.
171 .Sp
172 For network sockets, a port may be specified by using the form
173 \&\f(CW\*(C`\f(CB[\f(CW\f(CIaddress\f(CW\f(CB]:\f(CW\f(CIport\f(CW\*(C'\fR. If the address is an IPv4 address or a fully
174 qualified domain name (i.\ e. the address contains at least one dot
175 (\f(CW\*(C`.\*(C'\fR)), the square brackets can be omitted, resulting in the (simpler)
176 \&\f(CW\*(C`\f(CIaddress\f(CW\f(CB:\f(CW\f(CIport\f(CW\*(C'\fR pattern. The default port is \fB42217/tcp\fR. If you
177 specify a network socket, it is mandatory to read the
178 \&\*(L"\s-1SECURITY\s0 \s-1CONSIDERATIONS\s0\*(R" section.
179 .Sp
180 The following formats are accepted. Please note that the address of the \s-1UNIX\s0
181 domain socket \fBmust\fR start with a slash in the second case!
182 .Sp
183 .Vb 5
184 \&   unix:</path/to/unix.sock>
185 \&   /<path/to/unix.sock>
186 \&   <hostname\-or\-ip>
187 \&   [<hostname\-or\-ip>]:<port>
188 \&   <hostname\-or\-ipv4>:<port>
189 .Ve
190 .Sp
191 If the \fB\-l\fR option is not specified the default address,
192 \&\f(CW\*(C`unix:/tmp/rrdcached.sock\*(C'\fR, will be used.
193 .IP "\fB\-s\fR \fIgroup_name\fR|\fIgid\fR" 4
194 .IX Item "-s group_name|gid"
195 Set the group permissions of a \s-1UNIX\s0 domain socket. The option accepts either
196 a numeric group id or group name. That group will then have both read and write
197 permissions (the socket will have file permissions 0750) for the socket and,
198 therefore, is able to send commands to the daemon. This
199 may be useful in cases where you cannot easily run all \s-1RRD\s0 processes with the same
200 user privileges (e.g. graph generating \s-1CGI\s0 scripts that typically run in the
201 permission context of the web server).
202 .Sp
203 This option affects the \fIfollowing\fR \s-1UNIX\s0 socket addresses (the following
204 \&\fB\-l\fR options) or the default socket (if no \fB\-l\fR options have been
205 specified), i.e., you may specify different settings for different
206 sockets.
207 .Sp
208 The default is not to change ownership or permissions of the socket and, thus,
209 use the system default.
210 .IP "\fB\-m\fR \fImode\fR" 4
211 .IX Item "-m mode"
212 Set the file permissions of a \s-1UNIX\s0 domain socket. The option accepts an octal
213 number representing the bit pattern for the mode (see \fIchmod\fR\|(1) for
214 details).
215 .Sp
216 Please note that not all systems honor this setting. On Linux, read/write
217 permissions are required to connect to a \s-1UNIX\s0 socket. However, many
218 BSD-derived systems ignore permissions for \s-1UNIX\s0 sockets. See \fIunix\fR\|(7) for
219 details.
220 .Sp
221 This option affects the \fIfollowing\fR \s-1UNIX\s0 socket addresses (the following
222 \&\fB\-l\fR options) or the default socket (if no \fB\-l\fR options have been
223 specified), i.e., you may specify different settings for different
224 sockets.
225 .Sp
226 The default is not to change ownership or permissions of the socket and, thus,
227 use the system default.
228 .IP "\fB\-P\fR \fIcommand\fR[,\fIcommand\fR[,...]]" 4
229 .IX Item "-P command[,command[,...]]"
230 Specifies the commands accepted via a network socket. This allows
231 administrators of \fIRRDCacheD\fR to control the actions accepted from various
232 sources.
233 .Sp
234 The arguments given to the \fB\-P\fR option is a comma separated list of commands.
235 For example, to allow the \f(CW\*(C`FLUSH\*(C'\fR and \f(CW\*(C`PENDING\*(C'\fR commands one could specify:
236 .Sp
237 .Vb 1
238 \&  rrdcached \-P FLUSH,PENDING $MORE_ARGUMENTS
239 .Ve
240 .Sp
241 The \fB\-P\fR option affects the \fIfollowing\fR socket addresses (the following \fB\-l\fR
242 options) or the default socket (if no \fB\-l\fR options have been
243 specified). In the following example, only the IPv4 network socket (address
244 \&\f(CW10.0.0.1\fR) will be restricted to the \f(CW\*(C`FLUSH\*(C'\fR and \f(CW\*(C`PENDING\*(C'\fR commands:
245 .Sp
246 .Vb 1
247 \&  rrdcached \-l unix:/some/path \-P FLUSH,PENDING \-l 10.0.0.1
248 .Ve
249 .Sp
250 A complete list of available commands can be found in the section
251 \&\*(L"Valid Commands\*(R" below. There are two minor special exceptions:
252 .RS 4
253 .IP "\(bu" 4
254 The \f(CW\*(C`HELP\*(C'\fR and \f(CW\*(C`QUIT\*(C'\fR commands are always allowed.
255 .IP "\(bu" 4
256 If the \f(CW\*(C`BATCH\*(C'\fR command is accepted, the \fB.\fR\ command will automatically
257 be accepted, too.
258 .RE
259 .RS 4
260 .Sp
261 Please also read \*(L"\s-1SECURITY\s0 \s-1CONSIDERATIONS\s0\*(R" below.
262 .RE
263 .IP "\fB\-w\fR \fItimeout\fR" 4
264 .IX Item "-w timeout"
265 Data is written to disk every \fItimeout\fR seconds. If this option is not
266 specified the default interval of 300\ seconds will be used.
267 .IP "\fB\-z\fR \fIdelay\fR" 4
268 .IX Item "-z delay"
269 If specified, rrdcached will delay writing of each \s-1RRD\s0 for a random number
270 of seconds in the range\ [0,\fIdelay\fR).  This will avoid too many
271 writes being queued simultaneously.  This value should be no greater than
272 the value specified in \fB\-w\fR.  By default, there is no delay.
273 .IP "\fB\-f\fR \fItimeout\fR" 4
274 .IX Item "-f timeout"
275 Every \fItimeout\fR seconds the entire cache is searched for old values which are
276 written to disk. This only concerns files to which updates have stopped, so
277 setting this to a high value, such as 3600\ seconds, is acceptable in most
278 cases. This timeout defaults to 3600\ seconds.
279 .IP "\fB\-p\fR \fIfile\fR" 4
280 .IX Item "-p file"
281 Sets the name and location of the PID-file. If not specified, the default,
282 \&\f(CW\*(C`\f(CI$localststedir\f(CW/run/rrdcached.pid\*(C'\fR will be used.
283 .IP "\fB\-t\fR \fIwrite_threads\fR" 4
284 .IX Item "-t write_threads"
285 Specifies the number of threads used for writing \s-1RRD\s0 files.  The default
286 is\ 4.  Increasing this number will allow rrdcached to have more
287 simultaneous I/O requests into the kernel.  This may allow the kernel to
288 re-order disk writes, resulting in better disk throughput.
289 .IP "\fB\-j\fR \fIdir\fR" 4
290 .IX Item "-j dir"
291 Write updates to a journal in \fIdir\fR.  In the event of a program or system
292 crash, this will allow the daemon to write any updates that were pending
293 at the time of the crash.
294 .Sp
295 On startup, the daemon will check for journal files in this directory.  If
296 found, all updates therein will be read into memory before the daemon
297 starts accepting new connections.
298 .Sp
299 The journal will be rotated with the same frequency as the flush timer
300 given by \fB\-f\fR.
301 .Sp
302 When journaling is enabled, the daemon will use a fast shutdown procedure.
303 Rather than flushing all files to disk, it will make sure the journal is
304 properly written and exit immediately.  Although the \s-1RRD\s0 data files are
305 not fully up-to-date, no information is lost; all pending updates will be
306 replayed from the journal next time the daemon starts up.
307 .Sp
308 To disable fast shutdown, use the \fB\-F\fR option.
309 .IP "\fB\-F\fR" 4
310 .IX Item "-F"
311 \&\s-1ALWAYS\s0 flush all updates to the \s-1RRD\s0 data files when the daemon is shut
312 down, regardless of journal setting.
313 .IP "\fB\-g\fR" 4
314 .IX Item "-g"
315 Run in the foreground.  The daemon will not \fIfork()\fR.
316 .IP "\fB\-b\fR \fIdir\fR" 4
317 .IX Item "-b dir"
318 The daemon will change into a specific directory at startup. All files passed
319 to the daemon, that are specified by a \fBrelative\fR path, will be interpreted
320 to be relative to this directory. If not given the default, \f(CW\*(C`/tmp\*(C'\fR, will be
321 used.
322 .Sp
323 .Vb 10
324 \&  +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
325 \&  ! Command line           ! File updated           !
326 \&  +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
327 \&  ! foo.rrd                ! /tmp/foo.rrd           !
328 \&  ! foo/bar.rrd            ! /tmp/foo/bar.rrd       !
329 \&  ! /var/lib/rrd/foo.rrd   ! /var/lib/rrd/foo.rrd   !
330 \&  +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
331 \&  Paths given on the command  line and paths actually
332 \&  updated by the daemon,  assuming the base directory
333 \&  "/tmp".
334 .Ve
335 .Sp
336 \&\fB\s-1WARNING:\s0\fR The paths up to and including the base directory \fB\s-1MUST\s0 \s-1NOT\s0 \s-1BE\s0\fR
337 symbolic links.  In other words, if the base directory is
338 specified as:
339 .Sp
340 .Vb 1
341 \&    \-b /base/dir/somewhere
342 .Ve
343 .Sp
344 \&... then \fB\s-1NONE\s0\fR of the following should be symbolic links:
345 .Sp
346 .Vb 3
347 \&    /base
348 \&    /base/dir
349 \&    /base/dir/somewhere
350 .Ve
351 .IP "\fB\-B\fR" 4
352 .IX Item "-B"
353 Only permit writes into the base directory specified in \fB\-b\fR (and any
354 sub-directories).  This does \fB\s-1NOT\s0\fR detect symbolic links.  Paths
355 containing \f(CW\*(C`../\*(C'\fR will also be blocked.
356 .SH "AFFECTED RRDTOOL COMMANDS"
357 .IX Header "AFFECTED RRDTOOL COMMANDS"
358 The following commands may be made aware of the \fBrrdcached\fR using the command
359 line argument \fB\-\-daemon\fR or the environment variable \fB\s-1RRDCACHED_ADDRESS\s0\fR:
360 .IP "\(bu" 4
361 dump
362 .IP "\(bu" 4
363 fetch
364 .IP "\(bu" 4
365 flush
366 .IP "\(bu" 4
367 graph
368 .IP "\(bu" 4
369 graphv
370 .IP "\(bu" 4
371 info
372 .IP "\(bu" 4
373 last
374 .IP "\(bu" 4
375 lastupdate
376 .IP "\(bu" 4
377 update
378 .IP "\(bu" 4
379 xport
380 .PP
381 The \fBupdate\fR command can send values to the daemon instead of writing them to
382 the disk itself. All other commands can send a \fB\s-1FLUSH\s0\fR command (see below) to
383 the daemon before accessing the files, so they work with up-to-date data even
384 if the cache timeout is large.
385 .SH "ERROR REPORTING"
386 .IX Header "ERROR REPORTING"
387 The daemon reports errors in one of two ways: During startup, error messages
388 are printed to \f(CW\*(C`STDERR\*(C'\fR. One of the steps when starting up is to fork to the
389 background and closing \f(CW\*(C`STDERR\*(C'\fR \- after this writing directly to the user is
390 no longer possible. Once this has happened, the daemon will send log messages
391 to the system logging daemon using \fIsyslog\fR\|(3). The facility used is
392 \&\f(CW\*(C`LOG_DAEMON\*(C'\fR.
393 .SH "HOW IT WORKS"
394 .IX Header "HOW IT WORKS"
395 When receiving an update, \fBrrdcached\fR does not write to disk but looks for an
396 entry for that file in its internal tree. If not found, an entry is created
397 including the current time (called \*(L"First\*(R" in the diagram below). This time is
398 \&\fBnot\fR the time specified on the command line but the time the operating system
399 considers to be \*(L"now\*(R". The value and time of the value (called \*(L"Time\*(R" in the
400 diagram below) are appended to the tree node.
401 .PP
402 When appending a value to a tree node, it is checked whether it's time to write
403 the values to disk. Values are written to disk if
404 \&\f(CW\*(C`now()\ \-\ First\ >=\ timeout\*(C'\fR, where \f(CW\*(C`timeout\*(C'\fR is the timeout specified
405 using the \fB\-w\fR option, see \*(L"\s-1OPTIONS\s0\*(R". If the values are \*(L"old enough\*(R" they
406 will be enqueued in the \*(L"update queue\*(R", i.\ e. they will be appended to
407 the linked list shown below.  Because the tree nodes and the elements of the
408 linked list are the same data structures in memory, any update to a file that
409 has already been enqueued will be written with the next write to the \s-1RRD\s0 file,
410 too.
411 .PP
412 A separate \*(L"update thread\*(R" constantly dequeues the first element in the update
413 queue and writes all its values to the appropriate file. So as long as the
414 update queue is not empty files are written at the highest possible rate.
415 .PP
416 Since the timeout of files is checked only when new values are added to the
417 file, \*(L"dead\*(R" files, i.\ e. files that are not updated anymore, would never
418 be written to disk. Therefore, every now and then, controlled by the \fB\-f\fR
419 option, the entire tree is walked and all \*(L"old\*(R" values are enqueued. Since this
420 only affects \*(L"dead\*(R" files and walking the tree is relatively expensive, you
421 should set the \*(L"flush interval\*(R" to a reasonably high value. The default is
422 3600\ seconds (one hour).
423 .PP
424 The downside of caching values is that they won't show up in graphs generated
425 from the \s-1RRD\s0\ files. To get around this, the daemon provides the \*(L"flush
426 command\*(R" to flush specific files. This means that the file is inserted at the
427 \&\fBhead\fR of the update queue or moved there if it is already enqueued. The flush
428 command will return only after the file's pending updates have been written
429 to disk.
430 .PP
431 .Vb 10
432 \& +\-\-\-\-\-\-+   +\-\-\-\-\-\-+                               +\-\-\-\-\-\-+
433 \& ! head !   ! root !                               ! tail !
434 \& +\-\-\-+\-\-+   +\-\-\-+\-\-+                               +\-\-\-+\-\-+
435 \&     !         /\e                                      !
436 \&     !        /  \e                                     !
437 \&     !       /\e  /\e                                    !
438 \&     !      /\e/\e \e \`\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- ... \-\-\-\-\-\-\-\-,    !
439 \&     V     /      \`\-\-\-\-\-\-\-,                       !    V
440 \& +\-\-\-+\-\-\-\-+\-\-\-+    +\-\-\-\-\-\-+\-\-\-\-\-+             +\-\-\-+\-\-\-\-+\-\-\-+
441 \& ! File:  foo !    ! File:  bar !             ! File:  qux !
442 \& ! First: 101 !    ! First: 119 !             ! First: 180 !
443 \& ! Next:&bar \-+\-\-\->! Next:&... \-+\-\-\-> ... \-\-\->! Next:NULL  !
444 \& | Prev:NULL  !<\-\-\-+\-Prev:&foo  !<\-\-\- ... \-\-\-\-+\-Prev: &... !
445 \& +============+    +============+             +============+
446 \& ! Time:  100 !    ! Time:  120 !             ! Time:  180 !
447 \& ! Value:  10 !    ! Value: 0.1 !             ! Value: 2,2 !
448 \& +\-\-\-\-\-\-\-\-\-\-\-\-+    +\-\-\-\-\-\-\-\-\-\-\-\-+             +\-\-\-\-\-\-\-\-\-\-\-\-+
449 \& ! Time:  110 !    ! Time:  130 !             ! Time:  190 !
450 \& ! Value:  26 !    ! Value: 0.1 !             ! Value: 7,3 !
451 \& +\-\-\-\-\-\-\-\-\-\-\-\-+    +\-\-\-\-\-\-\-\-\-\-\-\-+             +\-\-\-\-\-\-\-\-\-\-\-\-+
452 \& :            :    :            :             :            :
453 \& +\-\-\-\-\-\-\-\-\-\-\-\-+    +\-\-\-\-\-\-\-\-\-\-\-\-+             +\-\-\-\-\-\-\-\-\-\-\-\-+
454 \& ! Time:  230 !    ! Time:  250 !             ! Time:  310 !
455 \& ! Value:  42 !    ! Value: 0.2 !             ! Value: 1,2 !
456 \& +\-\-\-\-\-\-\-\-\-\-\-\-+    +\-\-\-\-\-\-\-\-\-\-\-\-+             +\-\-\-\-\-\-\-\-\-\-\-\-+
457 .Ve
458 .PP
459 The above diagram demonstrates:
460 .IP "\(bu" 4
461 Files/values are stored in a (balanced) tree.
462 .IP "\(bu" 4
463 Tree nodes and entries in the update queue are the same data structure.
464 .IP "\(bu" 4
465 The local time (\*(L"First\*(R") and the time specified in updates (\*(L"Time\*(R") may differ.
466 .IP "\(bu" 4
467 Timed out values are inserted at the \*(L"tail\*(R".
468 .IP "\(bu" 4
469 Explicitly flushed values are inserted at the \*(L"head\*(R".
470 .IP "\(bu" 4
471 \&\s-1ASCII\s0 art rocks.
472 .SH "SECURITY CONSIDERATIONS"
473 .IX Header "SECURITY CONSIDERATIONS"
474 .SS "Authentication"
475 .IX Subsection "Authentication"
476 If your rrdtool installation was built without libwrap there is no form of 
477 authentication for clients connecting to the rrdcache daemon!
478 .PP
479 If your rrdtool installation was built with libwrap then you can use
480 hosts_access to restrict client access to the rrdcache daemon (rrdcached).  For more
481 information on how to use hosts_access to restrict access to the rrdcache
482 daemon you should read the \fIhosts_access\fR\|(5) man pages.
483 .PP
484 It is still highly recommended to install a packet filter or similar mechanism to
485 prevent unauthorized connections. Unless you have a dedicated \s-1VLAN\s0 or \s-1VPN\s0 for
486 this, using network sockets is probably a bad idea!
487 .SS "Authorization"
488 .IX Subsection "Authorization"
489 There is minimal per-socket authorization.
490 .PP
491 Authorization is currently done on a per-socket basis. That means each socket
492 has a list of commands it will accept and it will accept. It will accept only
493 those commands explicitly listed but it will (currently) accept these commands
494 from anyone reaching the socket.
495 .PP
496 If the networking sockets are to be used, it is necessary to restrict the
497 accepted commands to those needed by external clients. If, for example,
498 external clients want to draw graphs of the cached data, they should only be
499 allowed to use the \f(CW\*(C`FLUSH\*(C'\fR command.
500 .SS "Encryption"
501 .IX Subsection "Encryption"
502 There is no encryption.
503 .PP
504 Again, this may be added in the future, but for the time being it is your job
505 to keep your private data private. Install a \s-1VPN\s0 or an encrypted tunnel if you
506 statistics are confidential!
507 .SS "Sanity checking"
508 .IX Subsection "Sanity checking"
509 There is no sanity checking.
510 .PP
511 The daemon will blindly write to any file it gets told, so you really should
512 create a separate user just for this daemon. Also it does not do any sanity
513 checks, so if it gets told to write values for a time far in the future, your
514 files will be messed up good!
515 .SS "Conclusion"
516 .IX Subsection "Conclusion"
517 .IP "\(bu" 4
518 Security is the job of the administrator.
519 .IP "\(bu" 4
520 We recommend to allow write access via \s-1UNIX\s0 domain sockets only.
521 .IP "\(bu" 4
522 You have been warned.
523 .SH "PROTOCOL"
524 .IX Header "PROTOCOL"
525 The daemon communicates with clients using a line based \s-1ASCII\s0 protocol which is
526 easy to read and easy to type. This makes it easy for scripts to implement the
527 protocol and possible for users to use telnet to connect to the daemon
528 and test stuff \*(L"by hand\*(R".
529 .PP
530 The protocol is line based, this means that each record consists of one or more
531 lines. A line is terminated by the line feed character \f(CW0x0A\fR, commonly
532 written as \f(CW\*(C`\en\*(C'\fR. In the examples below, this character will be written as
533 \&\f(CW\*(C`<LF>\*(C'\fR (\*(L"line feed\*(R").
534 .PP
535 After the connection has been established, the client is expected to send a
536 \&\*(L"command\*(R". A command consists of the command keyword, possibly some arguments,
537 and a terminating newline character. For a list of commands, see
538 \&\*(L"Valid Commands\*(R" below.
539 .PP
540 Example:
541 .PP
542 .Vb 1
543 \&  FLUSH /tmp/foo.rrd<LF>
544 .Ve
545 .PP
546 The daemon answers with a line consisting of a status code and a short status
547 message, separated by one or more space characters. A negative status code
548 signals an error, a positive status code or zero signal success. If the status
549 code is greater than zero, it indicates the number of lines that follow the
550 status line.
551 .PP
552 Examples:
553 .PP
554 .Vb 1
555 \& 0 Success<LF>
556 \&
557 \& 2 Two lines follow<LF>
558 \& This is the first line<LF>
559 \& And this is the second line<LF>
560 .Ve
561 .SS "Valid Commands"
562 .IX Subsection "Valid Commands"
563 The following commands are understood by the daemon:
564 .IP "\fB\s-1FLUSH\s0\fR \fIfilename\fR" 4
565 .IX Item "FLUSH filename"
566 Causes the daemon to put \fIfilename\fR to the \fBhead\fR of the update queue
567 (possibly moving it there if the node is already enqueued). The answer will be
568 sent \fBafter\fR the node has been dequeued.
569 .IP "\fB\s-1FLUSHALL\s0\fR" 4
570 .IX Item "FLUSHALL"
571 Causes the daemon to start flushing \s-1ALL\s0 pending values to disk.  This
572 returns immediately, even though the writes may take a long time.
573 .IP "\fB\s-1PENDING\s0\fR \fIfilename\fR" 4
574 .IX Item "PENDING filename"
575 Shows any \*(L"pending\*(R" updates for a file, in order.  The updates shown have
576 not yet been written to the underlying \s-1RRD\s0 file.
577 .IP "\fB\s-1FORGET\s0\fR \fIfilename\fR" 4
578 .IX Item "FORGET filename"
579 Removes \fIfilename\fR from the cache.  Any pending updates \fB\s-1WILL\s0 \s-1BE\s0 \s-1LOST\s0\fR.
580 .IP "\fB\s-1QUEUE\s0\fR" 4
581 .IX Item "QUEUE"
582 Shows the files that are on the output queue.  Returns zero or more lines
583 in the following format, where <num_vals> is the number of values
584 to be written for the <file>:
585 .Sp
586 .Vb 1
587 \&    <num_vals> <file>
588 .Ve
589 .IP "\fB\s-1HELP\s0\fR [\fIcommand\fR]" 4
590 .IX Item "HELP [command]"
591 Returns a short usage message. If no command is given, or \fIcommand\fR is
592 \&\fB\s-1HELP\s0\fR, a list of commands supported by the daemon is returned. Otherwise a
593 short description, possibly containing a pointer to a manual page, is returned.
594 Obviously, this is meant for interactive usage and the format in which the
595 commands and usage summaries are returned is not well defined.
596 .IP "\fB\s-1STATS\s0\fR" 4
597 .IX Item "STATS"
598 Returns a list of metrics which can be used to measure the daemons performance
599 and check its status. For a description of the values returned, see
600 \&\*(L"Performance Values\*(R" below.
601 .Sp
602 The format in which the values are returned is similar to many other line based
603 protocols: Each value is printed on a separate line, each consisting of the
604 name of the value, a colon, one or more spaces and the actual value.
605 .Sp
606 Example:
607 .Sp
608 .Vb 10
609 \& 9 Statistics follow
610 \& QueueLength: 0
611 \& UpdatesReceived: 30
612 \& FlushesReceived: 2
613 \& UpdatesWritten: 13
614 \& DataSetsWritten: 390
615 \& TreeNodesNumber: 13
616 \& TreeDepth: 4
617 \& JournalBytes: 190
618 \& JournalRotate: 0
619 .Ve
620 .IP "\fB\s-1UPDATE\s0\fR \fIfilename\fR \fIvalues\fR [\fIvalues\fR ...]" 4
621 .IX Item "UPDATE filename values [values ...]"
622 Adds more data to a filename. This is \fBthe\fR operation the daemon was designed
623 for, so describing the mechanism again is unnecessary. Read \*(L"\s-1HOW\s0 \s-1IT\s0 \s-1WORKS\s0\*(R"
624 above for a detailed explanation.
625 .Sp
626 Note that rrdcached only accepts absolute timestamps in the update values.
627 Updates strings like \*(L"N:1:2:3\*(R" are automatically converted to absolute
628 time by the \s-1RRD\s0 client library before sending to rrdcached.
629 .IP "\fB\s-1WROTE\s0\fR \fIfilename\fR" 4
630 .IX Item "WROTE filename"
631 This command is written to the journal after a file is successfully
632 written out to disk.  It is used during journal replay to determine which
633 updates have already been applied.  It is \fIonly\fR valid in the journal; it
634 is not accepted from the other command channels.
635 .IP "\fB\s-1BATCH\s0\fR" 4
636 .IX Item "BATCH"
637 This command initiates the bulk load of multiple commands.  This is
638 designed for installations with extremely high update rates, since it
639 permits more than one command to be issued per \fIread()\fR and \fIwrite()\fR.
640 .Sp
641 All commands are executed just as they would be if given individually,
642 except for output to the user.  Messages indicating success are
643 suppressed, and error messages are delayed until the client is finished.
644 .Sp
645 Command processing is finished when the client sends a dot (\*(L".\*(R") on its
646 own line.  After the client has finished, the server responds with an
647 error count and the list of error messages (if any).  Each error messages
648 indicates the number of the command to which it corresponds, and the error
649 message itself.  The first user command after \fB\s-1BATCH\s0\fR is command number one.
650 .Sp
651 .Vb 9
652 \&    client:  BATCH
653 \&    server:  0 Go ahead.  End with dot \*(Aq.\*(Aq on its own line.
654 \&    client:  UPDATE x.rrd 1223661439:1:2:3            <\-\-\- command #1
655 \&    client:  UPDATE y.rrd 1223661440:3:4:5            <\-\-\- command #2
656 \&    client:  and so on...
657 \&    client:  .
658 \&    server:  2 Errors
659 \&    server:  1 message for command 1
660 \&    server:  12 message for command 12
661 .Ve
662 .IP "\fB\s-1QUIT\s0\fR" 4
663 .IX Item "QUIT"
664 Disconnect from rrdcached.
665 .SS "Performance Values"
666 .IX Subsection "Performance Values"
667 The following counters are returned by the \fB\s-1STATS\s0\fR command:
668 .IP "\fBQueueLength\fR \fI(unsigned 64bit integer)\fR" 4
669 .IX Item "QueueLength (unsigned 64bit integer)"
670 Number of nodes currently enqueued in the update queue.
671 .IP "\fBUpdatesReceived\fR \fI(unsigned 64bit integer)\fR" 4
672 .IX Item "UpdatesReceived (unsigned 64bit integer)"
673 Number of \s-1UPDATE\s0 commands received.
674 .IP "\fBFlushesReceived\fR \fI(unsigned 64bit integer)\fR" 4
675 .IX Item "FlushesReceived (unsigned 64bit integer)"
676 Number of \s-1FLUSH\s0 commands received.
677 .IP "\fBUpdatesWritten\fR \fI(unsigned 64bit integer)\fR" 4
678 .IX Item "UpdatesWritten (unsigned 64bit integer)"
679 Total number of updates, i.\ e. calls to \f(CW\*(C`rrd_update_r\*(C'\fR, since the
680 daemon was started.
681 .IP "\fBDataSetsWritten\fR \fI(unsigned 64bit integer)\fR" 4
682 .IX Item "DataSetsWritten (unsigned 64bit integer)"
683 Total number of \*(L"data sets\*(R" written to disk since the daemon was
684 started. A data set is one or more values passed to the \fB\s-1UPDATE\s0\fR
685 command. For example: \f(CW\*(C`1223661439:123:456\*(C'\fR is one data set with two
686 values. The term \*(L"data set\*(R" is used to prevent confusion whether
687 individual values or groups of values are counted.
688 .IP "\fBTreeNodesNumber\fR \fI(unsigned 64bit integer)\fR" 4
689 .IX Item "TreeNodesNumber (unsigned 64bit integer)"
690 Number of nodes in the cache.
691 .IP "\fBTreeDepth\fR \fI(unsigned 64bit integer)\fR" 4
692 .IX Item "TreeDepth (unsigned 64bit integer)"
693 Depth of the tree used for fast key lookup.
694 .IP "\fBJournalBytes\fR \fI(unsigned 64bit integer)\fR" 4
695 .IX Item "JournalBytes (unsigned 64bit integer)"
696 Total number of bytes written to the journal since startup.
697 .IP "\fBJournalRotate\fR \fI(unsigned 64bit integer)\fR" 4
698 .IX Item "JournalRotate (unsigned 64bit integer)"
699 Number of times the journal has been rotated since startup.
700 .SH "SIGNALS"
701 .IX Header "SIGNALS"
702 .IP "\s-1SIGINT\s0 and \s-1SIGTERM\s0" 4
703 .IX Item "SIGINT and SIGTERM"
704 The daemon exits normally on receipt of either of these signals.  Pending
705 updates are handled in accordance with the \fB\-j\fR and \fB\-F\fR options.
706 .IP "\s-1SIGUSR1\s0" 4
707 .IX Item "SIGUSR1"
708 The daemon exits \s-1AFTER\s0 flushing all updates out to disk.  This may take a
709 while.
710 .IP "\s-1SIGUSR2\s0" 4
711 .IX Item "SIGUSR2"
712 The daemon exits immediately, without flushing updates out to disk.
713 Pending updates will be replayed from the journal when the daemon starts
714 up again.  \fB\s-1WARNING:\s0 if journaling (\-j) is \s-1NOT\s0 enabled, any pending
715 updates \s-1WILL\s0 \s-1BE\s0 \s-1LOST\s0\fR.
716 .SH "BUGS"
717 .IX Header "BUGS"
718 No known bugs at the moment.
719 .SH "SEE ALSO"
720 .IX Header "SEE ALSO"
721 rrdtool, rrdgraph
722 .SH "AUTHOR"
723 .IX Header "AUTHOR"
724 Florian Forster <octo\ at\ verplant.org>
725 .PP
726 Both \fBrrdcached\fR and this manual page have been written by Florian.
727 .SH "CONTRIBUTORS"
728 .IX Header "CONTRIBUTORS"
729 kevin brintnall <kbrint@rufus.net>