Code

Imported upstream SVN snapshot 1.4~rc2+20090928.
[pkg-rrdtool.git] / doc / rrdfetch.1
1 .\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.08)
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 "RRDFETCH 1"
127 .TH RRDFETCH 1 "2009-06-09" "1.3.999" "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 rrdfetch \- Fetch data from an RRD.
134 .SH "SYNOPSIS"
135 .IX Header "SYNOPSIS"
136 \&\fBrrdtool\fR \fBfetch\fR \fIfilename\fR \fI\s-1CF\s0\fR
137 [\fB\-\-resolution\fR|\fB\-r\fR\ \fIresolution\fR]
138 [\fB\-\-start\fR|\fB\-s\fR\ \fIstart\fR]
139 [\fB\-\-end\fR|\fB\-e\fR\ \fIend\fR]
140 [\fB\-\-daemon\fR\ \fIaddress\fR]
141 .SH "DESCRIPTION"
142 .IX Header "DESCRIPTION"
143 The \fBfetch\fR function is normally used internally by the graph
144 function to get data from \fB\s-1RRD\s0\fRs. \fBfetch\fR will analyze the \fB\s-1RRD\s0\fR
145 and try to retrieve the data in the resolution requested.
146 The data fetched is printed to stdout. \fI*UNKNOWN*\fR data is often
147 represented by the string \*(L"NaN\*(R" depending on your \s-1OS\s0's printf
148 function.
149 .IP "\fIfilename\fR" 8
150 .IX Item "filename"
151 the name of the \fB\s-1RRD\s0\fR you want to fetch the data from.
152 .IP "\fI\s-1CF\s0\fR" 8
153 .IX Item "CF"
154 the consolidation function that is applied to the data you
155 want to fetch (\s-1AVERAGE\s0,MIN,MAX,LAST)
156 .IP "\fB\-\-resolution\fR|\fB\-r\fR \fIresolution\fR (default is the highest resolution)" 8
157 .IX Item "--resolution|-r resolution (default is the highest resolution)"
158 the interval you want the values to have (seconds per
159 value). \fBrrdfetch\fR will try to match your request, but it will return
160 data even if no absolute match is possible. \fB\s-1NB\s0.\fR See note below.
161 .IP "\fB\-\-start\fR|\fB\-s\fR \fIstart\fR (default end\-1day)" 8
162 .IX Item "--start|-s start (default end-1day)"
163 start of the time series. A time in seconds since epoch (1970\-01\-01)
164 is required. Negative numbers are relative to the current time. By default,
165 one day worth of data will be fetched. See also AT-STYLE \s-1TIME\s0 \s-1SPECIFICATION\s0
166 section for a detailed explanation on  ways to specify the start time.
167 .IP "\fB\-\-end\fR|\fB\-e\fR \fIend\fR (default now)" 8
168 .IX Item "--end|-e end (default now)"
169 the end of the time series in seconds since epoch. See also AT-STYLE
170 \&\s-1TIME\s0 \s-1SPECIFICATION\s0 section for a detailed explanation of how to
171 specify the end time.
172 .IP "\fB\-\-daemon\fR \fIaddress\fR" 8
173 .IX Item "--daemon address"
174 Address of the rrdcached daemon. If specified, a \f(CW\*(C`flush\*(C'\fR command is sent
175 to the server before reading the \s-1RRD\s0 files. This allows \fBrrdtool\fR to return
176 fresh data even if the daemon is configured to cache values for a long time.
177 For a list of accepted formats, see the \fB\-l\fR option in the rrdcached manual.
178 .Sp
179 .Vb 1
180 \& rrdtool fetch \-\-daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd AVERAGE
181 .Ve
182 .SS "\s-1RESOLUTION\s0 \s-1INTERVAL\s0"
183 .IX Subsection "RESOLUTION INTERVAL"
184 In order to get RRDtool to fetch anything other than the finest resolution \s-1RRA\s0
185 \&\fBboth\fR the start and end time must be specified on boundaries that are
186 multiples of the desired resolution. Consider the following example:
187 .PP
188 .Vb 7
189 \& rrdtool create subdata.rrd \-s 10 DS:ds0:GAUGE:300:0:U \e
190 \&  RRA:AVERAGE:0.5:30:3600 \e
191 \&  RRA:AVERAGE:0.5:90:1200 \e
192 \&  RRA:AVERAGE:0.5:360:1200 \e
193 \&  RRA:MAX:0.5:360:1200 \e
194 \&  RRA:AVERAGE:0.5:8640:600 \e
195 \&  RRA:MAX:0.5:8640:600
196 .Ve
197 .PP
198 This \s-1RRD\s0 collects data every 10 seconds and stores its averages over 5
199 minutes, 15 minutes, 1 hour, and 1 day, as well as the maxima for 1 hour
200 and 1 day.
201 .PP
202 Consider now that you want to fetch the 15 minute average data for the
203 last hour.  You might try
204 .PP
205 .Vb 1
206 \& rrdtool fetch subdata.rrd AVERAGE \-r 900 \-s \-1h
207 .Ve
208 .PP
209 However, this will almost always result in a time series that is
210 \&\fB\s-1NOT\s0\fR in the 15 minute \s-1RRA\s0. Therefore, the highest resolution \s-1RRA\s0,
211 i.e. 5 minute averages, will be chosen which in this case is not
212 what you want.
213 .PP
214 Hence, make sure that
215 .IP "1." 3
216 both start and end time are a multiple of 900
217 .IP "2." 3
218 both start and end time are within the desired \s-1RRA\s0
219 .PP
220 So, if time now is called \*(L"t\*(R", do
221 .PP
222 .Vb 3
223 \& end time == int(t/900)*900,
224 \& start time == end time \- 1hour,
225 \& resolution == 900.
226 .Ve
227 .PP
228 Using the bash shell, this could look be:
229 .PP
230 .Vb 4
231 \& TIME=$(date +%s)
232 \& RRDRES=900
233 \& rrdtool fetch subdata.rrd AVERAGE \-r $RRDRES \e
234 \&    \-e $(($TIME/$RRDRES*$RRDRES)) \-s e\-1h
235 .Ve
236 .PP
237 Or in Perl:
238 .PP
239 .Vb 3
240 \& perl \-e \*(Aq$ctime = time; $rrdres = 900; \e
241 \&          system "rrdtool fetch subdata.rrd AVERAGE \e
242 \&                  \-r $rrdres \-e @{[int($ctime/$rrdres)*$rrdres]} \-s e\-1h"\*(Aq
243 .Ve
244 .SS "AT-STYLE \s-1TIME\s0 \s-1SPECIFICATION\s0"
245 .IX Subsection "AT-STYLE TIME SPECIFICATION"
246 Apart from the traditional \fISeconds since epoch\fR, RRDtool does also
247 understand at-style time specification. The specification is called
248 \&\*(L"at-style\*(R" after the Unix command \fIat\fR\|(1) that has moderately complex
249 ways to specify time to run your job at a certain date and time. The
250 at-style specification consists of two parts: the \fB\s-1TIME\s0 \s-1REFERENCE\s0\fR
251 specification and the \fB\s-1TIME\s0 \s-1OFFSET\s0\fR specification.
252 .SS "\s-1TIME\s0 \s-1REFERENCE\s0 \s-1SPECIFICATION\s0"
253 .IX Subsection "TIME REFERENCE SPECIFICATION"
254 The time reference specification is used, well, to establish a reference
255 moment in time (to which the time offset is then applied to). When present,
256 it should come first, when omitted, it defaults to \fBnow\fR. On its own part,
257 time reference consists of a \fItime-of-day\fR reference (which should come
258 first, if present) and a \fIday\fR reference.
259 .PP
260 The \fItime-of-day\fR can be specified as \fB\s-1HH:MM\s0\fR, \fB\s-1HH\s0.MM\fR,
261 or just \fB\s-1HH\s0\fR. You can suffix it with \fBam\fR or \fBpm\fR or use
262 24\-hours clock. Some special times of day are understood as well,
263 including \fBmidnight\fR (00:00), \fBnoon\fR (12:00) and British
264 \&\fBteatime\fR (16:00).
265 .PP
266 The \fIday\fR can be specified as \fImonth-name\fR \fIday-of-the-month\fR and
267 optional a 2\- or 4\-digit \fIyear\fR number (e.g. March 8 1999). Alternatively,
268 you can use \fIday-of-week-name\fR (e.g. Monday), or one of the words:
269 \&\fByesterday\fR, \fBtoday\fR, \fBtomorrow\fR. You can also specify the \fIday\fR as a
270 full date in several numerical formats, including \fBMM/DD/[\s-1YY\s0]YY\fR,
271 \&\fB\s-1DD\s0.MM.[\s-1YY\s0]YY\fR, or \fB\s-1YYYYMMDD\s0\fR.
272 .PP
273 \&\fI\s-1NOTE1\s0\fR: this is different from the original \fIat\fR\|(1) behavior, where a
274 single-number date is interpreted as MMDD[\s-1YY\s0]YY.
275 .PP
276 \&\fI\s-1NOTE2\s0\fR: if you specify the \fIday\fR in this way, the \fItime-of-day\fR is
277 \&\s-1REQUIRED\s0 as well.
278 .PP
279 Finally, you can use the words \fBnow\fR, \fBstart\fR, or \fBend\fR as your time
280 reference. \fBNow\fR refers to the current moment (and is also the default
281 time reference). \fBStart\fR (\fBend\fR) can be used to specify a time
282 relative to the start (end) time for those tools that use these
283 categories (\fBrrdfetch\fR, rrdgraph).
284 .PP
285 Month and day of the week names can be used in their naturally
286 abbreviated form (e.g., Dec for December, Sun for Sunday, etc.). The
287 words \fBnow\fR, \fBstart\fR, \fBend\fR can be abbreviated as \fBn\fR, \fBs\fR, \fBe\fR.
288 .SS "\s-1TIME\s0 \s-1OFFSET\s0 \s-1SPECIFICATION\s0"
289 .IX Subsection "TIME OFFSET SPECIFICATION"
290 The time offset specification is used to add/subtract certain time
291 intervals to/from the time reference moment. It consists of a \fIsign\fR
292 (\fB+\fR\ or\ \fB\-\fR) and an \fIamount\fR. The following time units can be
293 used to specify the \fIamount\fR: \fByears\fR, \fBmonths\fR, \fBweeks\fR, \fBdays\fR,
294 \&\fBhours\fR, \fBminutes\fR, or \fBseconds\fR. These units can be used in
295 singular or plural form, and abbreviated naturally or to a single
296 letter (e.g. +3days, \-1wk, \-3y). Several time units can be combined
297 (e.g., \-5mon1w2d) or concatenated (e.g., \-5h45min = \-5h\-45min =
298 \&\-6h+15min = \-7h+1h30m\-15min, etc.)
299 .PP
300 \&\fI\s-1NOTE3\s0\fR: If you specify time offset in days, weeks, months, or years,
301 you will end with the time offset that may vary depending on your time
302 reference, because all those time units have no single well defined
303 time interval value (1\ year contains either 365 or 366 days, 1\ month
304 is 28 to 31 days long, and even 1\ day may be not equal to 24 hours
305 twice a year, when DST-related clock adjustments take place).
306 To cope with this, when you use days, weeks, months, or years
307 as your time offset units your time reference date is adjusted
308 accordingly without too much further effort to ensure anything
309 about it (in the hope that \fImktime\fR\|(3) will take care of this later).
310 This may lead to some surprising (or even invalid!) results,
311 e.g. 'May\ 31\ \-1month' = 'Apr\ 31' (meaningless) = 'May\ 1'
312 (after \fImktime\fR\|(3) normalization); in the \s-1EET\s0 timezone
313 \&'3:30am Mar 29 1999 \-1 day' yields '3:30am Mar 28 1999' (Sunday)
314 which is an invalid time/date combination (because of 3am \-> 4am \s-1DST\s0
315 forward clock adjustment, see the below example).
316 .PP
317 In contrast, hours, minutes, and seconds are well defined time
318 intervals, and these are guaranteed to always produce time offsets
319 exactly as specified (e.g. for \s-1EET\s0 timezone, '8:00\ Mar\ 27\ 1999\ +2\ days' = '8:00\ Mar\ 29\ 1999', but since there is 1\-hour \s-1DST\s0 forward
320 clock adjustment that occurs around 3:00\ Mar\ 28\ 1999, the actual
321 time interval between 8:00\ Mar\ 27\ 1999 and 8:00\ Mar\ 29\ 1999
322 equals 47 hours; on the other hand, '8:00\ Mar\ 27\ 1999\ +48\ hours' =
323 \&'9:00\ Mar\ 29\ 1999', as expected)
324 .PP
325 \&\fI\s-1NOTE4\s0\fR: The single-letter abbreviation for both \fBmonths\fR and \fBminutes\fR
326 is \fBm\fR. To disambiguate them, the parser tries to read your mind\ :)
327 by applying the following two heuristics:
328 .IP "1." 3
329 If \fBm\fR is used in context of (i.e. right after the) years,
330 months, weeks, or days it is assumed to mean \fBmonths\fR, while
331 in the context of hours, minutes, and seconds it means minutes.
332 (e.g., in \-1y6m or +3w1m \fBm\fR is interpreted as \fBmonths\fR, while in
333 \&\-3h20m or +5s2m \fBm\fR the parser decides for \fBminutes\fR).
334 .IP "2." 3
335 Out of context (i.e. right after the \fB+\fR or \fB\-\fR sign) the
336 meaning of \fBm\fR is guessed from the number it directly follows.
337 Currently, if the number's absolute value is below 25 it is assumed
338 that \fBm\fR means \fBmonths\fR, otherwise it is treated as \fBminutes\fR.
339 (e.g., \-25m == \-25 minutes, while +24m == +24 months)
340 .PP
341 \&\fIFinal \s-1NOTES\s0\fR: Time specification is case-insensitive.
342 Whitespace can be inserted freely or omitted altogether.
343 There are, however, cases when whitespace is required
344 (e.g., 'midnight\ Thu'). In this case you should either quote the
345 whole phrase to prevent it from being taken apart by your shell or use
346 \&'_' (underscore) or ',' (comma) which also count as whitespace
347 (e.g., midnight_Thu or midnight,Thu).
348 .SS "\s-1TIME\s0 \s-1SPECIFICATION\s0 \s-1EXAMPLES\s0"
349 .IX Subsection "TIME SPECIFICATION EXAMPLES"
350 \&\fIOct 12\fR \*(-- October 12 this year
351 .PP
352 \&\fI\-1month\fR or \fI\-1m\fR \*(-- current time of day, only a month before
353 (may yield surprises, see \s-1NOTE3\s0 above).
354 .PP
355 \&\fInoon yesterday \-3hours\fR \*(-- yesterday morning; can also be specified
356 as \fI9am\-1day\fR.
357 .PP
358 \&\fI23:59 31.12.1999\fR \*(-- 1 minute to the year 2000.
359 .PP
360 \&\fI12/31/99 11:59pm\fR \*(-- 1 minute to the year 2000 for imperialists.
361 .PP
362 \&\fI12am 01/01/01\fR \*(-- start of the new millennium
363 .PP
364 \&\fIend\-3weeks\fR or \fIe\-3w\fR \*(-- 3 weeks before end time
365 (may be used as start time specification).
366 .PP
367 \&\fIstart+6hours\fR or \fIs+6h\fR \*(-- 6 hours after start time
368 (may be used as end time specification).
369 .PP
370 \&\fI931225537\fR \*(-- 18:45  July 5th, 1999
371 (yes, seconds since 1970 are valid as well).
372 .PP
373 \&\fI19970703 12:45\fR \*(-- 12:45  July 3th, 1997
374 (my favorite, and its even got an \s-1ISO\s0 number (8601)).
375 .SH "ENVIRONMENT VARIABLES"
376 .IX Header "ENVIRONMENT VARIABLES"
377 The following environment variables may be used to change the behavior of
378 \&\f(CW\*(C`rrdtool\ fetch\*(C'\fR:
379 .IP "\fB\s-1RRDCACHED_ADDRESS\s0\fR" 4
380 .IX Item "RRDCACHED_ADDRESS"
381 If this environment variable is set it will have the same effect as specifying
382 the \f(CW\*(C`\-\-daemon\*(C'\fR option on the command line. If both are present, the command
383 line argument takes precedence.
384 .SH "AUTHOR"
385 .IX Header "AUTHOR"
386 Tobias Oetiker <tobi@oetiker.ch>