Code

Imported upstream version 1.4.2.
[pkg-rrdtool.git] / doc / rrdcached.1
1 .\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.05)
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 "2009-11-15" "1.4.2" "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\-w\fR\ \fItimeout\fR]
140 [\fB\-z\fR\ \fIdelay\fR]
141 [\fB\-f\fR\ \fItimeout\fR]
142 [\fB\-p\fR\ \fIpid_file\fR]
143 [\fB\-t\fR\ \fIwrite_threads\fR]
144 [\fB\-j\fR\ \fIjournal_dir\fR]
145 [\-F]
146 [\-g]
147 [\fB\-b\fR\ \fIbase_dir\fR\ [\fB\-B\fR]]
148 .SH "DESCRIPTION"
149 .IX Header "DESCRIPTION"
150 \&\fBrrdcached\fR is a daemon that receives updates to existing \s-1RRD\s0 files,
151 accumulates them and, if enough have been received or a defined time has
152 passed, writes the updates to the \s-1RRD\s0 file. A \fIflush\fR command may be used to
153 force writing of values to disk, so that graphing facilities and similar can
154 work with up-to-date data.
155 .PP
156 The daemon was written with big setups in mind. Those setups usually run into
157 \&\s-1IO\s0\ related problems sooner or later for reasons that are beyond the scope
158 of this document. Check the wiki at the RRDtool homepage for details. Also
159 check \*(L"\s-1SECURITY\s0 \s-1CONSIDERATIONS\s0\*(R" below before using this daemon! A detailed
160 description of how the daemon operates can be found in the \*(L"\s-1HOW\s0 \s-1IT\s0 \s-1WORKS\s0\*(R"
161 section below.
162 .SH "OPTIONS"
163 .IX Header "OPTIONS"
164 .IP "\fB\-l\fR \fIaddress\fR" 4
165 .IX Item "-l address"
166 Tells the daemon to bind to \fIaddress\fR and accept incoming connections on that
167 socket. If \fIaddress\fR begins with \f(CW\*(C`unix:\*(C'\fR, everything following that prefix is
168 interpreted as the path to a \s-1UNIX\s0 domain socket. Otherwise the address or node
169 name are resolved using getaddrinfo.
170 .Sp
171 For network sockets, a port may be specified by using the form
172 \&\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
173 qualified domain name (i.\ e. the address contains at least one dot
174 (\f(CW\*(C`.\*(C'\fR)), the square brackets can be omitted, resulting in the (simpler)
175 \&\f(CW\*(C`\f(CIaddress\f(CW\f(CB:\f(CW\f(CIport\f(CW\*(C'\fR pattern. The default port is \fB42217/udp\fR. If you
176 specify a network socket, it is mandatory to read the
177 \&\*(L"\s-1SECURITY\s0 \s-1CONSIDERATIONS\s0\*(R" section.
178 .Sp
179 The following formats are accepted. Please note that the address of the \s-1UNIX\s0
180 domain socket \fBmust\fR start with a slash in the second case!
181 .Sp
182 .Vb 5
183 \&   unix:</path/to/unix.sock>
184 \&   /<path/to/unix.sock>
185 \&   <hostname\-or\-ip>
186 \&   [<hostname\-or\-ip>]:<port>
187 \&   <hostname\-or\-ipv4>:<port>
188 .Ve
189 .Sp
190 If the \fB\-l\fR option is not specified the default address,
191 \&\f(CW\*(C`unix:/tmp/rrdcached.sock\*(C'\fR, will be used.
192 .IP "\fB\-P\fR \fIcommand\fR[,\fIcommand\fR[,...]]" 4
193 .IX Item "-P command[,command[,...]]"
194 Specifies the commands accepted via a network socket. This allows
195 administrators of \fIRRDCacheD\fR to control the actions accepted from various
196 sources.
197 .Sp
198 The arguments given to the \fB\-P\fR option is a comma separated list of commands.
199 For example, to allow the \f(CW\*(C`FLUSH\*(C'\fR and \f(CW\*(C`PENDING\*(C'\fR commands one could specify:
200 .Sp
201 .Vb 1
202 \&  rrdcached \-P FLUSH,PENDING $MORE_ARGUMENTS
203 .Ve
204 .Sp
205 The \fB\-P\fR option effects the \fIfollowing\fR socket addresses (the following \fB\-l\fR
206 options). In the following example, only the IPv4 network socket (address
207 \&\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:
208 .Sp
209 .Vb 1
210 \&  rrdcached \-l unix:/some/path \-P FLUSH,PENDING \-l 10.0.0.1
211 .Ve
212 .Sp
213 A complete list of available commands can be found in the section
214 \&\*(L"Valid Commands\*(R" below. There are two minor special exceptions:
215 .RS 4
216 .IP "\(bu" 4
217 The \f(CW\*(C`HELP\*(C'\fR and \f(CW\*(C`QUIT\*(C'\fR commands are always allowed.
218 .IP "\(bu" 4
219 If the \f(CW\*(C`BATCH\*(C'\fR command is accepted, the \fB.\fR\ command will automatically
220 be accepted, too.
221 .RE
222 .RS 4
223 .Sp
224 Please also read \*(L"\s-1SECURITY\s0 \s-1CONSIDERATIONS\s0\*(R" below.
225 .RE
226 .IP "\fB\-w\fR \fItimeout\fR" 4
227 .IX Item "-w timeout"
228 Data is written to disk every \fItimeout\fR seconds. If this option is not
229 specified the default interval of 300\ seconds will be used.
230 .IP "\fB\-z\fR \fIdelay\fR" 4
231 .IX Item "-z delay"
232 If specified, rrdcached will delay writing of each \s-1RRD\s0 for a random number
233 of seconds in the range\ [0,\fIdelay\fR).  This will avoid too many
234 writes being queued simultaneously.  This value should be no greater than
235 the value specified in \fB\-w\fR.  By default, there is no delay.
236 .IP "\fB\-f\fR \fItimeout\fR" 4
237 .IX Item "-f timeout"
238 Every \fItimeout\fR seconds the entire cache is searched for old values which are
239 written to disk. This only concerns files to which updates have stopped, so
240 setting this to a high value, such as 3600\ seconds, is acceptable in most
241 cases. This timeout defaults to 3600\ seconds.
242 .IP "\fB\-p\fR \fIfile\fR" 4
243 .IX Item "-p file"
244 Sets the name and location of the PID-file. If not specified, the default,
245 \&\f(CW\*(C`\f(CI$localststedir\f(CW/run/rrdcached.pid\*(C'\fR will be used.
246 .IP "\fB\-t\fR \fIwrite_threads\fR" 4
247 .IX Item "-t write_threads"
248 Specifies the number of threads used for writing \s-1RRD\s0 files.  The default
249 is\ 4.  Increasing this number will allow rrdcached to have more
250 simultaneous I/O requests into the kernel.  This may allow the kernel to
251 re-order disk writes, resulting in better disk throughput.
252 .IP "\fB\-j\fR \fIdir\fR" 4
253 .IX Item "-j dir"
254 Write updates to a journal in \fIdir\fR.  In the event of a program or system
255 crash, this will allow the daemon to write any updates that were pending
256 at the time of the crash.
257 .Sp
258 On startup, the daemon will check for journal files in this directory.  If
259 found, all updates therein will be read into memory before the daemon
260 starts accepting new connections.
261 .Sp
262 The journal will be rotated with the same frequency as the flush timer
263 given by \fB\-f\fR.
264 .Sp
265 When journaling is enabled, the daemon will use a fast shutdown procedure.
266 Rather than flushing all files to disk, it will make sure the journal is
267 properly written and exit immediately.  Although the \s-1RRD\s0 data files are
268 not fully up-to-date, no information is lost; all pending updates will be
269 replayed from the journal next time the daemon starts up.
270 .Sp
271 To disable fast shutdown, use the \fB\-F\fR option.
272 .IP "\fB\-F\fR" 4
273 .IX Item "-F"
274 \&\s-1ALWAYS\s0 flush all updates to the \s-1RRD\s0 data files when the daemon is shut
275 down, regardless of journal setting.
276 .IP "\fB\-g\fR" 4
277 .IX Item "-g"
278 Run in the foreground.  The daemon will not \fIfork()\fR.
279 .IP "\fB\-b\fR \fIdir\fR" 4
280 .IX Item "-b dir"
281 The daemon will change into a specific directory at startup. All files passed
282 to the daemon, that are specified by a \fBrelative\fR path, will be interpreted
283 to be relative to this directory. If not given the default, \f(CW\*(C`/tmp\*(C'\fR, will be
284 used.
285 .Sp
286 .Vb 10
287 \&  +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
288 \&  ! Command line           ! File updated           !
289 \&  +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
290 \&  ! foo.rrd                ! /tmp/foo.rrd           !
291 \&  ! foo/bar.rrd            ! /tmp/foo/bar.rrd       !
292 \&  ! /var/lib/rrd/foo.rrd   ! /var/lib/rrd/foo.rrd   !
293 \&  +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
294 \&  Paths given on the command  line and paths actually
295 \&  updated by the daemon,  assuming the base directory
296 \&  "/tmp".
297 .Ve
298 .Sp
299 \&\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
300 symbolic links.  In other words, if the base directory is
301 specified as:
302 .Sp
303 .Vb 1
304 \&    \-b /base/dir/somewhere
305 .Ve
306 .Sp
307 \&... then \fB\s-1NONE\s0\fR of the following should be symbolic links:
308 .Sp
309 .Vb 3
310 \&    /base
311 \&    /base/dir
312 \&    /base/dir/somewhere
313 .Ve
314 .IP "\fB\-B\fR" 4
315 .IX Item "-B"
316 Only permit writes into the base directory specified in \fB\-b\fR (and any
317 sub-directories).  This does \fB\s-1NOT\s0\fR detect symbolic links.  Paths
318 containing \f(CW\*(C`../\*(C'\fR will also be blocked.
319 .SH "AFFECTED RRDTOOL COMMANDS"
320 .IX Header "AFFECTED RRDTOOL COMMANDS"
321 The following commands may be made aware of the \fBrrdcached\fR using the command
322 line argument \fB\-\-daemon\fR or the environment variable \fB\s-1RRDCACHED_ADDRESS\s0\fR:
323 .IP "\(bu" 4
324 dump
325 .IP "\(bu" 4
326 fetch
327 .IP "\(bu" 4
328 flush
329 .IP "\(bu" 4
330 graph
331 .IP "\(bu" 4
332 graphv
333 .IP "\(bu" 4
334 info
335 .IP "\(bu" 4
336 last
337 .IP "\(bu" 4
338 lastupdate
339 .IP "\(bu" 4
340 update
341 .IP "\(bu" 4
342 xport
343 .PP
344 The \fBupdate\fR command can send values to the daemon instead of writing them to
345 the disk itself. All other commands can send a \fB\s-1FLUSH\s0\fR command (see below) to
346 the daemon before accessing the files, so they work with up-to-date data even
347 if the cache timeout is large.
348 .SH "ERROR REPORTING"
349 .IX Header "ERROR REPORTING"
350 The daemon reports errors in one of two ways: During startup, error messages
351 are printed to \f(CW\*(C`STDERR\*(C'\fR. One of the steps when starting up is to fork to the
352 background and closing \f(CW\*(C`STDERR\*(C'\fR \- after this writing directly to the user is
353 no longer possible. Once this has happened, the daemon will send log messages
354 to the system logging daemon using \fIsyslog\fR\|(3). The facility used is
355 \&\f(CW\*(C`LOG_DAEMON\*(C'\fR.
356 .SH "HOW IT WORKS"
357 .IX Header "HOW IT WORKS"
358 When receiving an update, \fBrrdcached\fR does not write to disk but looks for an
359 entry for that file in its internal tree. If not found, an entry is created
360 including the current time (called \*(L"First\*(R" in the diagram below). This time is
361 \&\fBnot\fR the time specified on the command line but the time the operating system
362 considers to be \*(L"now\*(R". The value and time of the value (called \*(L"Time\*(R" in the
363 diagram below) are appended to the tree node.
364 .PP
365 When appending a value to a tree node, it is checked whether it's time to write
366 the values to disk. Values are written to disk if
367 \&\f(CW\*(C`now()\ \-\ First\ >=\ timeout\*(C'\fR, where \f(CW\*(C`timeout\*(C'\fR is the timeout specified
368 using the \fB\-w\fR option, see \*(L"\s-1OPTIONS\s0\*(R". If the values are \*(L"old enough\*(R" they
369 will be enqueued in the \*(L"update queue\*(R", i.\ e. they will be appended to
370 the linked list shown below.  Because the tree nodes and the elements of the
371 linked list are the same data structures in memory, any update to a file that
372 has already been enqueued will be written with the next write to the \s-1RRD\s0 file,
373 too.
374 .PP
375 A separate \*(L"update thread\*(R" constantly dequeues the first element in the update
376 queue and writes all its values to the appropriate file. So as long as the
377 update queue is not empty files are written at the highest possible rate.
378 .PP
379 Since the timeout of files is checked only when new values are added to the
380 file, \*(L"dead\*(R" files, i.\ e. files that are not updated anymore, would never
381 be written to disk. Therefore, every now and then, controlled by the \fB\-f\fR
382 option, the entire tree is walked and all \*(L"old\*(R" values are enqueued. Since this
383 only affects \*(L"dead\*(R" files and walking the tree is relatively expensive, you
384 should set the \*(L"flush interval\*(R" to a reasonably high value. The default is
385 3600\ seconds (one hour).
386 .PP
387 The downside of caching values is that they won't show up in graphs generated
388 from the \s-1RRD\s0\ files. To get around this, the daemon provides the \*(L"flush
389 command\*(R" to flush specific files. This means that the file is inserted at the
390 \&\fBhead\fR of the update queue or moved there if it is already enqueued. The flush
391 command will return only after the file's pending updates have been written
392 to disk.
393 .PP
394 .Vb 10
395 \& +\-\-\-\-\-\-+   +\-\-\-\-\-\-+                               +\-\-\-\-\-\-+
396 \& ! head !   ! root !                               ! tail !
397 \& +\-\-\-+\-\-+   +\-\-\-+\-\-+                               +\-\-\-+\-\-+
398 \&     !         /\e                                      !
399 \&     !        /  \e                                     !
400 \&     !       /\e  /\e                                    !
401 \&     !      /\e/\e \e \`\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- ... \-\-\-\-\-\-\-\-,    !
402 \&     V     /      \`\-\-\-\-\-\-\-,                       !    V
403 \& +\-\-\-+\-\-\-\-+\-\-\-+    +\-\-\-\-\-\-+\-\-\-\-\-+             +\-\-\-+\-\-\-\-+\-\-\-+
404 \& ! File:  foo !    ! File:  bar !             ! File:  qux !
405 \& ! First: 101 !    ! First: 119 !             ! First: 180 !
406 \& ! Next:&bar \-+\-\-\->! Next:&... \-+\-\-\-> ... \-\-\->! Next:NULL  !
407 \& | Prev:NULL  !<\-\-\-+\-Prev:&foo  !<\-\-\- ... \-\-\-\-+\-Prev: &... !
408 \& +============+    +============+             +============+
409 \& ! Time:  100 !    ! Time:  120 !             ! Time:  180 !
410 \& ! Value:  10 !    ! Value: 0.1 !             ! Value: 2,2 !
411 \& +\-\-\-\-\-\-\-\-\-\-\-\-+    +\-\-\-\-\-\-\-\-\-\-\-\-+             +\-\-\-\-\-\-\-\-\-\-\-\-+
412 \& ! Time:  110 !    ! Time:  130 !             ! Time:  190 !
413 \& ! Value:  26 !    ! Value: 0.1 !             ! Value: 7,3 !
414 \& +\-\-\-\-\-\-\-\-\-\-\-\-+    +\-\-\-\-\-\-\-\-\-\-\-\-+             +\-\-\-\-\-\-\-\-\-\-\-\-+
415 \& :            :    :            :             :            :
416 \& +\-\-\-\-\-\-\-\-\-\-\-\-+    +\-\-\-\-\-\-\-\-\-\-\-\-+             +\-\-\-\-\-\-\-\-\-\-\-\-+
417 \& ! Time:  230 !    ! Time:  250 !             ! Time:  310 !
418 \& ! Value:  42 !    ! Value: 0.2 !             ! Value: 1,2 !
419 \& +\-\-\-\-\-\-\-\-\-\-\-\-+    +\-\-\-\-\-\-\-\-\-\-\-\-+             +\-\-\-\-\-\-\-\-\-\-\-\-+
420 .Ve
421 .PP
422 The above diagram demonstrates:
423 .IP "\(bu" 4
424 Files/values are stored in a (balanced) tree.
425 .IP "\(bu" 4
426 Tree nodes and entries in the update queue are the same data structure.
427 .IP "\(bu" 4
428 The local time (\*(L"First\*(R") and the time specified in updates (\*(L"Time\*(R") may differ.
429 .IP "\(bu" 4
430 Timed out values are inserted at the \*(L"tail\*(R".
431 .IP "\(bu" 4
432 Explicitly flushed values are inserted at the \*(L"head\*(R".
433 .IP "\(bu" 4
434 \&\s-1ASCII\s0 art rocks.
435 .SH "SECURITY CONSIDERATIONS"
436 .IX Header "SECURITY CONSIDERATIONS"
437 .SS "Authentication"
438 .IX Subsection "Authentication"
439 There is no authentication.
440 .PP
441 The client/server protocol does not yet have any authentication mechanism. It
442 is likely that authentication and encryption will be added in a future version,
443 but for the time being it is the administrator's responsibility to secure the
444 traffic from/to the daemon!
445 .PP
446 It is highly recommended to install a packet filter or similar mechanism to
447 prevent unauthorized connections. Unless you have a dedicated \s-1VLAN\s0 or \s-1VPN\s0 for
448 this, using network sockets is probably a bad idea!
449 .SS "Authorization"
450 .IX Subsection "Authorization"
451 There is minimal per-socket authorization.
452 .PP
453 Authorization is currently done on a per-socket basis. That means each socket
454 has a list of commands it will accept and it will accept. It will accept only
455 those commands explicitly listed but it will (currently) accept these commands
456 from anyone reaching the socket.
457 .PP
458 If the networking sockets are to be used, it is necessary to restrict the
459 accepted commands to those needed by external clients. If, for example,
460 external clients want to draw graphs of the cached data, they should only be
461 allowed to use the \f(CW\*(C`FLUSH\*(C'\fR command.
462 .SS "Encryption"
463 .IX Subsection "Encryption"
464 There is no encryption.
465 .PP
466 Again, this may be added in the future, but for the time being it is your job
467 to keep your private data private. Install a \s-1VPN\s0 or an encrypted tunnel if you
468 statistics are confidential!
469 .SS "Sanity checking"
470 .IX Subsection "Sanity checking"
471 There is no sanity checking.
472 .PP
473 The daemon will blindly write to any file it gets told, so you really should
474 create a separate user just for this daemon. Also it does not do any sanity
475 checks, so if it gets told to write values for a time far in the future, your
476 files will be messed up good!
477 .SS "Conclusion"
478 .IX Subsection "Conclusion"
479 .IP "\(bu" 4
480 Security is the job of the administrator.
481 .IP "\(bu" 4
482 We recommend to allow write access via \s-1UNIX\s0 domain sockets only.
483 .IP "\(bu" 4
484 You have been warned.
485 .SH "PROTOCOL"
486 .IX Header "PROTOCOL"
487 The daemon communicates with clients using a line based \s-1ASCII\s0 protocol which is
488 easy to read and easy to type. This makes it easy for scripts to implement the
489 protocol and possible for users to use telnet to connect to the daemon
490 and test stuff \*(L"by hand\*(R".
491 .PP
492 The protocol is line based, this means that each record consists of one or more
493 lines. A line is terminated by the line feed character \f(CW0x0A\fR, commonly
494 written as \f(CW\*(C`\en\*(C'\fR. In the examples below, this character will be written as
495 \&\f(CW\*(C`<LF>\*(C'\fR (\*(L"line feed\*(R").
496 .PP
497 After the connection has been established, the client is expected to send a
498 \&\*(L"command\*(R". A command consists of the command keyword, possibly some arguments,
499 and a terminating newline character. For a list of commands, see
500 \&\*(L"Valid Commands\*(R" below.
501 .PP
502 Example:
503 .PP
504 .Vb 1
505 \&  FLUSH /tmp/foo.rrd<LF>
506 .Ve
507 .PP
508 The daemon answers with a line consisting of a status code and a short status
509 message, separated by one or more space characters. A negative status code
510 signals an error, a positive status code or zero signal success. If the status
511 code is greater than zero, it indicates the number of lines that follow the
512 status line.
513 .PP
514 Examples:
515 .PP
516 .Vb 1
517 \& 0 Success<LF>
518 \&
519 \& 2 Two lines follow<LF>
520 \& This is the first line<LF>
521 \& And this is the second line<LF>
522 .Ve
523 .SS "Valid Commands"
524 .IX Subsection "Valid Commands"
525 The following commands are understood by the daemon:
526 .IP "\fB\s-1FLUSH\s0\fR \fIfilename\fR" 4
527 .IX Item "FLUSH filename"
528 Causes the daemon to put \fIfilename\fR to the \fBhead\fR of the update queue
529 (possibly moving it there if the node is already enqueued). The answer will be
530 sent \fBafter\fR the node has been dequeued.
531 .IP "\fB\s-1FLUSHALL\s0\fR" 4
532 .IX Item "FLUSHALL"
533 Causes the daemon to start flushing \s-1ALL\s0 pending values to disk.  This
534 returns immediately, even though the writes may take a long time.
535 .IP "\fB\s-1PENDING\s0\fR \fIfilename\fR" 4
536 .IX Item "PENDING filename"
537 Shows any \*(L"pending\*(R" updates for a file, in order.  The updates shown have
538 not yet been written to the underlying \s-1RRD\s0 file.
539 .IP "\fB\s-1FORGET\s0\fR \fIfilename\fR" 4
540 .IX Item "FORGET filename"
541 Removes \fIfilename\fR from the cache.  Any pending updates \fB\s-1WILL\s0 \s-1BE\s0 \s-1LOST\s0\fR.
542 .IP "\fB\s-1QUEUE\s0\fR" 4
543 .IX Item "QUEUE"
544 Shows the files that are on the output queue.  Returns zero or more lines
545 in the following format, where <num_vals> is the number of values
546 to be written for the <file>:
547 .Sp
548 .Vb 1
549 \&    <num_vals> <file>
550 .Ve
551 .IP "\fB\s-1HELP\s0\fR [\fIcommand\fR]" 4
552 .IX Item "HELP [command]"
553 Returns a short usage message. If no command is given, or \fIcommand\fR is
554 \&\fB\s-1HELP\s0\fR, a list of commands supported by the daemon is returned. Otherwise a
555 short description, possibly containing a pointer to a manual page, is returned.
556 Obviously, this is meant for interactive usage and the format in which the
557 commands and usage summaries are returned is not well defined.
558 .IP "\fB\s-1STATS\s0\fR" 4
559 .IX Item "STATS"
560 Returns a list of metrics which can be used to measure the daemons performance
561 and check its status. For a description of the values returned, see
562 \&\*(L"Performance Values\*(R" below.
563 .Sp
564 The format in which the values are returned is similar to many other line based
565 protocols: Each value is printed on a separate line, each consisting of the
566 name of the value, a colon, one or more spaces and the actual value.
567 .Sp
568 Example:
569 .Sp
570 .Vb 10
571 \& 9 Statistics follow
572 \& QueueLength: 0
573 \& UpdatesReceived: 30
574 \& FlushesReceived: 2
575 \& UpdatesWritten: 13
576 \& DataSetsWritten: 390
577 \& TreeNodesNumber: 13
578 \& TreeDepth: 4
579 \& JournalBytes: 190
580 \& JournalRotate: 0
581 .Ve
582 .IP "\fB\s-1UPDATE\s0\fR \fIfilename\fR \fIvalues\fR [\fIvalues\fR ...]" 4
583 .IX Item "UPDATE filename values [values ...]"
584 Adds more data to a filename. This is \fBthe\fR operation the daemon was designed
585 for, so describing the mechanism again is unnecessary. Read \*(L"\s-1HOW\s0 \s-1IT\s0 \s-1WORKS\s0\*(R"
586 above for a detailed explanation.
587 .Sp
588 Note that rrdcached only accepts absolute timestamps in the update values.
589 Updates strings like \*(L"N:1:2:3\*(R" are automatically converted to absolute
590 time by the \s-1RRD\s0 client library before sending to rrdcached.
591 .IP "\fB\s-1WROTE\s0\fR \fIfilename\fR" 4
592 .IX Item "WROTE filename"
593 This command is written to the journal after a file is successfully
594 written out to disk.  It is used during journal replay to determine which
595 updates have already been applied.  It is \fIonly\fR valid in the journal; it
596 is not accepted from the other command channels.
597 .IP "\fB\s-1BATCH\s0\fR" 4
598 .IX Item "BATCH"
599 This command initiates the bulk load of multiple commands.  This is
600 designed for installations with extremely high update rates, since it
601 permits more than one command to be issued per \fIread()\fR and \fIwrite()\fR.
602 .Sp
603 All commands are executed just as they would be if given individually,
604 except for output to the user.  Messages indicating success are
605 suppressed, and error messages are delayed until the client is finished.
606 .Sp
607 Command processing is finished when the client sends a dot (\*(L".\*(R") on its
608 own line.  After the client has finished, the server responds with an
609 error count and the list of error messages (if any).  Each error messages
610 indicates the number of the command to which it corresponds, and the error
611 message itself.  The first user command after \fB\s-1BATCH\s0\fR is command number one.
612 .Sp
613 .Vb 9
614 \&    client:  BATCH
615 \&    server:  0 Go ahead.  End with dot \*(Aq.\*(Aq on its own line.
616 \&    client:  UPDATE x.rrd 1223661439:1:2:3            <\-\-\- command #1
617 \&    client:  UPDATE y.rrd 1223661440:3:4:5            <\-\-\- command #2
618 \&    client:  and so on...
619 \&    client:  .
620 \&    server:  2 Errors
621 \&    server:  1 message for command 1
622 \&    server:  12 message for command 12
623 .Ve
624 .IP "\fB\s-1QUIT\s0\fR" 4
625 .IX Item "QUIT"
626 Disconnect from rrdcached.
627 .SS "Performance Values"
628 .IX Subsection "Performance Values"
629 The following counters are returned by the \fB\s-1STATS\s0\fR command:
630 .IP "\fBQueueLength\fR \fI(unsigned 64bit integer)\fR" 4
631 .IX Item "QueueLength (unsigned 64bit integer)"
632 Number of nodes currently enqueued in the update queue.
633 .IP "\fBUpdatesReceived\fR \fI(unsigned 64bit integer)\fR" 4
634 .IX Item "UpdatesReceived (unsigned 64bit integer)"
635 Number of \s-1UPDATE\s0 commands received.
636 .IP "\fBFlushesReceived\fR \fI(unsigned 64bit integer)\fR" 4
637 .IX Item "FlushesReceived (unsigned 64bit integer)"
638 Number of \s-1FLUSH\s0 commands received.
639 .IP "\fBUpdatesWritten\fR \fI(unsigned 64bit integer)\fR" 4
640 .IX Item "UpdatesWritten (unsigned 64bit integer)"
641 Total number of updates, i.\ e. calls to \f(CW\*(C`rrd_update_r\*(C'\fR, since the
642 daemon was started.
643 .IP "\fBDataSetsWritten\fR \fI(unsigned 64bit integer)\fR" 4
644 .IX Item "DataSetsWritten (unsigned 64bit integer)"
645 Total number of \*(L"data sets\*(R" written to disk since the daemon was
646 started. A data set is one or more values passed to the \fB\s-1UPDATE\s0\fR
647 command. For example: \f(CW\*(C`1223661439:123:456\*(C'\fR is one data set with two
648 values. The term \*(L"data set\*(R" is used to prevent confusion whether
649 individual values or groups of values are counted.
650 .IP "\fBTreeNodesNumber\fR \fI(unsigned 64bit integer)\fR" 4
651 .IX Item "TreeNodesNumber (unsigned 64bit integer)"
652 Number of nodes in the cache.
653 .IP "\fBTreeDepth\fR \fI(unsigned 64bit integer)\fR" 4
654 .IX Item "TreeDepth (unsigned 64bit integer)"
655 Depth of the tree used for fast key lookup.
656 .IP "\fBJournalBytes\fR \fI(unsigned 64bit integer)\fR" 4
657 .IX Item "JournalBytes (unsigned 64bit integer)"
658 Total number of bytes written to the journal since startup.
659 .IP "\fBJournalRotate\fR \fI(unsigned 64bit integer)\fR" 4
660 .IX Item "JournalRotate (unsigned 64bit integer)"
661 Number of times the journal has been rotated since startup.
662 .SH "SIGNALS"
663 .IX Header "SIGNALS"
664 .IP "\s-1SIGINT\s0 and \s-1SIGTERM\s0" 4
665 .IX Item "SIGINT and SIGTERM"
666 The daemon exits normally on receipt of either of these signals.  Pending
667 updates are handled in accordance with the \fB\-j\fR and \fB\-F\fR options.
668 .IP "\s-1SIGUSR1\s0" 4
669 .IX Item "SIGUSR1"
670 The daemon exits \s-1AFTER\s0 flushing all updates out to disk.  This may take a
671 while.
672 .IP "\s-1SIGUSR2\s0" 4
673 .IX Item "SIGUSR2"
674 The daemon exits immediately, without flushing updates out to disk.
675 Pending updates will be replayed from the journal when the daemon starts
676 up again.  \fB\s-1WARNING:\s0 if journaling (\-j) is \s-1NOT\s0 enabled, any pending
677 updates \s-1WILL\s0 \s-1BE\s0 \s-1LOST\s0\fR.
678 .SH "BUGS"
679 .IX Header "BUGS"
680 No known bugs at the moment.
681 .SH "SEE ALSO"
682 .IX Header "SEE ALSO"
683 rrdtool, rrdgraph
684 .SH "AUTHOR"
685 .IX Header "AUTHOR"
686 Florian Forster <octo\ at\ verplant.org>
687 .PP
688 Both \fBrrdcached\fR and this manual page have been written by Florian.
689 .SH "CONTRIBUTORS"
690 .IX Header "CONTRIBUTORS"
691 kevin brintnall <kbrint@rufus.net>