Code

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