40f2ea6b6f7e3cd701026439ea7c020278864a35
[rrdtool.git] / doc / rrdtool.pod
1 =head1 NAME
2
3 rrdtool - round robin database tool
4
5 =for html <div align="right"><a href="rrdtool.pdf">PDF</a> version.</div>
6
7 =head1 SYNOPSIS
8
9 B<rrdtool> B<-> [workdir]| I<function>
10
11 =head1 DESCRIPTION
12
13 =head2 OVERVIEW
14
15 It is pretty easy to gather status information from all sorts of
16 things, ranging from the temperature in your office to the number of
17 octets which have passed through the FDDI interface of your
18 router. But it is not so trivial to store this data in a efficient and
19 systematic manner. This is where B<rrdtool> kicks in. It lets you
20 I<log and analyze> the data you gather from all kinds of data-sources
21 (B<DS>). The data analysis part of rrdtool is based on the ability to
22 quickly generate graphical representations of the data values
23 collected over a definable time period.
24
25 In this man page you will find general information on the design and
26 functionality of the Round Robin Database Tool (rrdtool). For a more
27 detailed description of how to use the individual functions of the
28 B<rrdtool> check the corresponding man page.
29
30 For an introduction to the usage of rrdtool make sure you check L<rrdtutorial>.
31
32 =head2 FUNCTIONS
33
34 While the man pages talk of command line switches you have to set in
35 order to make B<rrdtool> work it is important to note that the
36 B<rrdtool> can be 'remote controlled' through a set of pipes. This
37 saves a considerable amount of startup time when you plan to make
38 B<rrdtool> do a lot of things quickly. Check the section on L<"Remote
39 Control"> further down. There is also a number of language bindings
40 for rrdtool which allow you to use it directly from perl, python, tcl,
41 php, ...
42
43 =over 8
44
45 =item B<create>
46
47 Set up a new Round Robin Database (RRD). Check L<rrdcreate>.
48
49 =item B<update>
50
51 Store new data values into an RRD. Check L<rrdupdate>.
52
53 =item B<updatev>
54
55 Operation equivalent to B<update> except for output. Check L<rrdupdate>.
56
57 =item B<graph>
58
59 Create a graph from data stored in one or several RRD. Apart from
60 generating graphs, data can also be extracted to stdout. Check L<rrdgraph>.
61
62 =item B<dump>
63
64 Dump the contents of an RRD in plain ASCII. In connection with 
65 restore you can use it to transport an rrd from one architecture to another.
66 Check L<rrddump>.
67
68 =item B<restore>
69
70 Restore an RRD in XML format to a binary rrd ... Check L<rrdrestore>
71
72 =item B<fetch>
73
74 Get data for a certain time period from a RRD. The graph function
75 uses fetch to retrieve its data from an rrd. Check L<rrdfetch>.
76
77 =item B<tune>
78
79 Alter setup of an RRD. Check L<rrdtune>.
80
81 =item B<last>
82
83 Find last update time of an RRD. Check L<rrdlast>.
84
85 =item B<info>
86
87 Get information about an RRD. Check L<rrdinfo>.
88
89 =item B<rrdresize>
90
91 Change the size of individual RRAs ... Dangerous! Check L<rrdresize>.
92
93 =item B<xport>
94
95 Export data retrieved from one or several RRD. Check L<rrdxport>
96
97 =item B<rrdcgi>
98
99 This is a standalone tool for producing rrd graphs on the fly. Check
100 L<rrdcgi>.
101
102 =back
103
104 =head2 HOW DOES RRDTOOL WORK?
105
106 =over 8
107
108 =item Data acquisition
109
110 When monitoring the state of a system, it is convenient to have the
111 data available at a constant interval. Unfortunately you may not
112 always be able to fetch data at exactly the time you want
113 to. Therefore B<rrdtool> lets you update the logfile at any time you
114 want. It will automatically interpolate the value of the data-source
115 (B<DS>) at the latest official time-slot and write this value to the
116 log. The value you have supplied is stored as well and is also taken
117 into account when interpolating the next log entry.
118
119 =item Consolidation
120
121 You may log data at a 1 minute interval, but you are also be
122 interested to know the development of the data over the last year. You
123 could do this by simply storing the data in 1 minute interval, for one
124 year. While this would take considerable disk space it would also take
125 a lot of time to analyze the data when you wanted to create a graph
126 covering the whole year. B<rrdtool> offers a solution to this of this
127 problem through its data consolidation feature. When setting up
128 an Round Robin Database (B<RRD>), you can define at which interval
129 this consolidation should occur, and what consolidation function
130 (B<CF>) (average, minimum, maximum, total, last) should be used to
131 build the consolidated values (see rrdcreate). You can define any
132 number of different consolidation setups within one B<RRD>. They will
133 all be maintained on the fly when new data is loaded into the B<RRD>.
134
135 =item Round Robin Archives
136
137 Data values of the same consolidation setup are stored into Round
138 Robin Archives (B<RRA>). This is a very efficient manner to store data
139 for a certain amount of time, while using a known amount of storage
140 space. 
141
142 It works like this: If you want to store 1000 values in 5 minute
143 interval, B<rrdtool> will allocate space for 1000 data values and a
144 header area. In the header it will store a pointer telling
145 which one of the values in the storage area was last written to. New
146 values are written to the Round Robin Archive in a ...  you guess it
147 ... round robin manner. This automatically limits the history to the last
148 1000 values. Because you can define several B<RRA>s within a single B<RRD>,
149 you can setup another one, storing 750 data values at a 2 hour interval
150 and thus keeping a log for the last two months although at a lower
151 resolution.
152
153 The use of B<RRA>s guarantees that the B<RRD> does not grow over
154 time and that old data is automatically eliminated. By using the
155 consolidation feature, you can still keep data for a very long time,
156 while gradually reducing the resolution of the data along the time
157 axis. Using different consolidation functions (B<CF>) allows you to
158 store exactly the type of information that actually interests
159 you. (Maximum one minute traffic on the LAN, minimum temperature of
160 the wine cellar, total minutes down time ...)
161
162 =item Unknown Data
163
164 As mentioned earlier, the B<RRD> stores data at a constant
165 interval. Now it may happen that no new data is available when a
166 value has to be written to the B<RRD>. Data acquisition may not be
167 possible for one reason or an other. The B<rrdtool> handles these
168 situations by storing an I<*UNKNOWN*> value into the database. The
169 value 'I<*UNKNOWN*>' is supported through all the functions of the
170 database. When consolidating the amount of I<*UNKNOWN*> data is
171 accumulated and when a new consolidated value is ready to be written
172 to its Round Robin Archive (B<RRA>) a validity check is performed to
173 make sure that the percentage of unknown data in the new value is
174 below a configurable level. If so, an I<*UNKNOWN*> value will be
175 written to the B<RRA>.
176
177 =item Graphing
178
179 The B<rrdtool> also allows one to generate reports in numerical and
180 graphical form based on the data stored in one or several
181 B<RRD>s. The graphing feature is fully configurable. Size, color and
182 contents of the graph can be defined freely. Check L<rrdgraph>
183 for more information on this.
184
185 =item Aberrant Behavior Detection
186
187 by Jake Brutlag E<lt>jakeb@corp.webtv.netE<gt>
188
189 The  B<rrdtool> also provides the building blocks for near real-time
190 aberrant behavior detection. These components include:
191
192 =over 12
193
194 =item *
195
196 An algorithm for predicting the values time series one time step into the future.
197
198 =item *
199
200 A measure of deviation between the predicted values and the observed values.
201
202 =item *
203
204 A mechanism to decide if and when an observed value
205 or sequence of observed values is I<too deviant> from the predicted value(s).
206
207 =back
208
209 Each of these components is briefly described:
210
211 Holt-Winters Time Series Forecasting Algorithm is an online, or incremental, 
212 algorithm that adaptively predicts future observations in a time series. It's 
213 forecast is the sum of three components: a baseline (or intercept), a linear 
214 trend over time (or slope), and a seasonal coefficient (a periodic effect, 
215 such as a daily cycle). There is one seasonal coefficient for each time point 
216 in the period (cycle). After a value is observed, each of these components is 
217 updated via exponential smoothing. So the algorithm learns from past values 
218 and uses them to predict the future. The rate of adaptation is governed by 
219 3 parameters, alpha (intercept), beta (slope), and gamma (seasonal). The prediction 
220 can also be viewed as a smoothed value for the time series.
221
222 The measure of deviation is a seasonal weighted absolute deviation. The term 
223 I<seasonal> means deviation is measured separately for each time point in the 
224 seasonal cycle. As with Holt-Winters Forecasting, deviation is predicted using 
225 the measure computed from past values (but only at that point in the seasonal cycle). 
226 After the value is observed, the algorithm learns from the observed value via 
227 exponential smoothing. Confidence bands for the observed time series are generated 
228 by scaling the sequence of predicted deviation values (we usually think of the sequence 
229 as a continuous line rather than a set of discrete points).
230
231 Aberrant behavior (a potential failure) is reported whenever the number of 
232 times the observed value violates the confidence bands meets or exceeds a 
233 specified threshold within a specified temporal window (i.e. 5 violations 
234 during the past 45 minutes with a value observed every 5 mintues).
235
236 This functionality is embedded in a set of related B<RRAs>. In particular, a FAILURES
237 B<RRA> logs potential failures. Presumably a front-end application to B<rrdtool> can
238 utilize this B<RRA> to initiate real-time alerts if that is desired.
239
240 You can find a detailed description of how to set this up in L<rrdcreate>.
241
242 =back
243
244 =head2 REMOTE CONTROL
245
246 When you start B<rrdtool> with the command line option 'B<->', it waits
247 for input via standard in. With this feature you can improve
248 performance by attaching B<rrdtool> to another process (mrtg is one
249 example) through a set of pipes. Over the pipes B<rrdtool> accepts the
250 same arguments as on the command line and some spezial commands like
251 B<quit, cd, mkdir> and B<ls>. For detail helps about the server commands
252 type :
253
254    rrdtool help cd|mkdir|ls|quit
255
256 When a command is completed, rrdtool will print the string  'C<OK>', 
257 followed by timing information of the form B<u:>I<usertime> 
258 B<s:>I<systemtime> both values are running totals of seconds 
259 since rrdtool was started. If an error occurs, a line of the 
260 form 'C<ERROR:> I<Description of error>' will be printed. B<rrdtool>
261 will not abort if possible, but follow the ERROR line with an OK line.
262 If a B<workdir> is spezified and the UID is 0, rrdtool will do a 
263 chroot to the workdir. If the UID is not 0, rrdtool only changes the
264 current directory to B<workdir>.
265
266 =head2 RRD Server
267
268 If you want to create a RRD-Server, you must choose a TCP/IP Service 
269 number and add them to I</etc/services> like this:
270
271  rrdsrv      13900/tcp                       # rrd server
272
273 Attention: the tcp port 13900 isn't official registered for rrdsrv. You
274 can use any unused port in your services, but the server an the client
275 system must use the same port of curse.
276 After this you can add the rrdtool as meta-server to I</etc/inetd.conf>
277 for example:
278   
279  rrdsrv stream tcp nowait root /opt/rrd/bin/rrdtool rrdtool - /var/rrd
280
281 Don't forget to create the database directory /var/rrd and reinitialize
282 your inetd.
283 If all was correct, you can access the server with perl sockets, tools
284 like netcat or a quickhack test 'telnet localhost rrdsrv'.
285
286
287
288 =head1 SEE ALSO
289
290 rrdcreate, rrdupdate, rrdgraph, rrddump, rrdfetch, rrdtune, rrdlast, rrdxport
291
292 =head1 BUGS
293
294 Bugs ? Features !
295
296 =head1 AUTHOR
297
298 Tobias Oetiker <oetiker@ee.ethz.ch>
299