~ubuntu-branches/ubuntu/saucy/rrdtool/saucy-proposed

« back to all changes in this revision

Viewing changes to doc/rrdcached.html

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2010-07-22 08:07:01 UTC
  • mfrom: (1.2.8 upstream) (3.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100722080701-k46mgdfz6euxwqsm
Tags: 1.4.3-1ubuntu1
* Merge from debian unstable, Remaining changes:
  - debian/control: Don't build against ruby1.9 as we don't want
    it in main.
* require libdbi >= 0.8.3 to prevent aborts when using dbi datasources

Show diffs side-by-side

added added

removed removed

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