Code

Imported upstream version 1.3.8.
[pkg-rrdtool.git] / doc / rrdfetch.1
1 .\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.05)
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
6 .if t .sp .5v
7 .if n .sp
8 ..
9 .de Vb \" Begin verbatim text
10 .ft CW
11 .nf
12 .ne \\$1
13 ..
14 .de Ve \" End verbatim text
15 .ft R
16 .fi
17 ..
18 .\" Set up some character translations and predefined strings.  \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
21 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
24 .tr \(*W-
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
26 .ie n \{\
27 .    ds -- \(*W-
28 .    ds PI pi
29 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
31 .    ds L" ""
32 .    ds R" ""
33 .    ds C` ""
34 .    ds C' ""
35 'br\}
36 .el\{\
37 .    ds -- \|\(em\|
38 .    ds PI \(*p
39 .    ds L" ``
40 .    ds R" ''
41 'br\}
42 .\"
43 .\" Escape single quotes in literal strings from groff's Unicode transform.
44 .ie \n(.g .ds Aq \(aq
45 .el       .ds Aq '
46 .\"
47 .\" If the F register is turned on, we'll generate index entries on stderr for
48 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
49 .\" entries marked with X<> in POD.  Of course, you'll have to process the
50 .\" output yourself in some meaningful fashion.
51 .ie \nF \{\
52 .    de IX
53 .    tm Index:\\$1\t\\n%\t"\\$2"
54 ..
55 .    nr % 0
56 .    rr F
57 .\}
58 .el \{\
59 .    de IX
60 ..
61 .\}
62 .\"
63 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
64 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
65 .    \" fudge factors for nroff and troff
66 .if n \{\
67 .    ds #H 0
68 .    ds #V .8m
69 .    ds #F .3m
70 .    ds #[ \f1
71 .    ds #] \fP
72 .\}
73 .if t \{\
74 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
75 .    ds #V .6m
76 .    ds #F 0
77 .    ds #[ \&
78 .    ds #] \&
79 .\}
80 .    \" simple accents for nroff and troff
81 .if n \{\
82 .    ds ' \&
83 .    ds ` \&
84 .    ds ^ \&
85 .    ds , \&
86 .    ds ~ ~
87 .    ds /
88 .\}
89 .if t \{\
90 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
91 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
92 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
93 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
94 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
95 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
96 .\}
97 .    \" troff and (daisy-wheel) nroff accents
98 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
99 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
100 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
101 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
102 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
103 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
104 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
105 .ds ae a\h'-(\w'a'u*4/10)'e
106 .ds Ae A\h'-(\w'A'u*4/10)'E
107 .    \" corrections for vroff
108 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
109 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
110 .    \" for low resolution devices (crt and lpr)
111 .if \n(.H>23 .if \n(.V>19 \
112 \{\
113 .    ds : e
114 .    ds 8 ss
115 .    ds o a
116 .    ds d- d\h'-1'\(ga
117 .    ds D- D\h'-1'\(hy
118 .    ds th \o'bp'
119 .    ds Th \o'LP'
120 .    ds ae ae
121 .    ds Ae AE
122 .\}
123 .rm #[ #] #H #V #F C
124 .\" ========================================================================
125 .\"
126 .IX Title "RRDFETCH 1"
127 .TH RRDFETCH 1 "2008-03-15" "1.3.8" "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 .SH "DESCRIPTION"
141 .IX Header "DESCRIPTION"
142 The \fBfetch\fR function is normally used internally by the graph
143 function to get data from \fB\s-1RRD\s0\fRs. \fBfetch\fR will analyze the \fB\s-1RRD\s0\fR
144 and try to retrieve the data in the resolution requested.
145 The data fetched is printed to stdout. \fI*UNKNOWN*\fR data is often
146 represented by the string \*(L"NaN\*(R" depending on your \s-1OS\s0's printf
147 function.
148 .IP "\fIfilename\fR" 8
149 .IX Item "filename"
150 the name of the \fB\s-1RRD\s0\fR you want to fetch the data from.
151 .IP "\fI\s-1CF\s0\fR" 8
152 .IX Item "CF"
153 the consolidation function that is applied to the data you
154 want to fetch (\s-1AVERAGE\s0,MIN,MAX,LAST)
155 .IP "\fB\-\-resolution\fR|\fB\-r\fR \fIresolution\fR (default is the highest resolution)" 8
156 .IX Item "--resolution|-r resolution (default is the highest resolution)"
157 the interval you want the values to have (seconds per
158 value). \fBrrdfetch\fR will try to match your request, but it will return
159 data even if no absolute match is possible. \fB\s-1NB\s0.\fR See note below.
160 .IP "\fB\-\-start\fR|\fB\-s\fR \fIstart\fR (default end\-1day)" 8
161 .IX Item "--start|-s start (default end-1day)"
162 start of the time series. A time in seconds since epoch (1970\-01\-01)
163 is required. Negative numbers are relative to the current time. By default,
164 one day worth of data will be fetched. See also AT-STYLE \s-1TIME\s0 \s-1SPECIFICATION\s0
165 section for a detailed explanation on  ways to specify the start time.
166 .IP "\fB\-\-end\fR|\fB\-e\fR \fIend\fR (default now)" 8
167 .IX Item "--end|-e end (default now)"
168 the end of the time series in seconds since epoch. See also AT-STYLE
169 \&\s-1TIME\s0 \s-1SPECIFICATION\s0 section for a detailed explanation of how to
170 specify the end time.
171 .SS "\s-1RESOLUTION\s0 \s-1INTERVAL\s0"
172 .IX Subsection "RESOLUTION INTERVAL"
173 In order to get RRDtool to fetch anything other than the finest resolution \s-1RRA\s0
174 \&\fBboth\fR the start and end time must be specified on boundaries that are
175 multiples of the desired resolution. Consider the following example:
176 .PP
177 .Vb 7
178 \& rrdtool create subdata.rrd \-s 10 DS:ds0:GAUGE:300:0:U \e
179 \&  RRA:AVERAGE:0.5:30:3600 \e
180 \&  RRA:AVERAGE:0.5:90:1200 \e
181 \&  RRA:AVERAGE:0.5:360:1200 \e
182 \&  RRA:MAX:0.5:360:1200 \e
183 \&  RRA:AVERAGE:0.5:8640:600 \e
184 \&  RRA:MAX:0.5:8640:600
185 .Ve
186 .PP
187 This \s-1RRD\s0 collects data every 10 seconds and stores its averages over 5
188 minutes, 15 minutes, 1 hour, and 1 day, as well as the maxima for 1 hour
189 and 1 day.
190 .PP
191 Consider now that you want to fetch the 15 minute average data for the
192 last hour.  You might try
193 .PP
194 .Vb 1
195 \& rrdtool fetch subdata.rrd AVERAGE \-r 900 \-s \-1h
196 .Ve
197 .PP
198 However, this will almost always result in a time series that is
199 \&\fB\s-1NOT\s0\fR in the 15 minute \s-1RRA\s0. Therefore, the highest resolution \s-1RRA\s0,
200 i.e. 5 minute averages, will be chosen which in this case is not
201 what you want.
202 .PP
203 Hence, make sure that
204 .IP "1." 3
205 both start and end time are a multiple of 900
206 .IP "2." 3
207 both start and end time are within the desired \s-1RRA\s0
208 .PP
209 So, if time now is called \*(L"t\*(R", do
210 .PP
211 .Vb 3
212 \& end time == int(t/900)*900,
213 \& start time == end time \- 1hour,
214 \& resolution == 900.
215 .Ve
216 .PP
217 Using the bash shell, this could look be:
218 .PP
219 .Vb 4
220 \& TIME=$(date +%s)
221 \& RRDRES=900
222 \& rrdtool fetch subdata.rrd AVERAGE \-r $RRDRES \e
223 \&    \-e $(($TIME/$RRDRES*$RRDRES)) \-s e\-1h
224 .Ve
225 .PP
226 Or in Perl:
227 .PP
228 .Vb 3
229 \& perl \-e \*(Aq$ctime = time; $rrdres = 900; \e
230 \&          system "rrdtool fetch subdata.rrd AVERAGE \e
231 \&                  \-r $rrdres \-e @{[int($ctime/$rrdres)*$rrdres]} \-s e\-1h"\*(Aq
232 .Ve
233 .SS "AT-STYLE \s-1TIME\s0 \s-1SPECIFICATION\s0"
234 .IX Subsection "AT-STYLE TIME SPECIFICATION"
235 Apart from the traditional \fISeconds since epoch\fR, RRDtool does also
236 understand at-style time specification. The specification is called
237 \&\*(L"at-style\*(R" after the Unix command \fIat\fR\|(1) that has moderately complex
238 ways to specify time to run your job at a certain date and time. The
239 at-style specification consists of two parts: the \fB\s-1TIME\s0 \s-1REFERENCE\s0\fR
240 specification and the \fB\s-1TIME\s0 \s-1OFFSET\s0\fR specification.
241 .SS "\s-1TIME\s0 \s-1REFERENCE\s0 \s-1SPECIFICATION\s0"
242 .IX Subsection "TIME REFERENCE SPECIFICATION"
243 The time reference specification is used, well, to establish a reference
244 moment in time (to which the time offset is then applied to). When present,
245 it should come first, when omitted, it defaults to \fBnow\fR. On its own part,
246 time reference consists of a \fItime-of-day\fR reference (which should come
247 first, if present) and a \fIday\fR reference.
248 .PP
249 The \fItime-of-day\fR can be specified as \fB\s-1HH:MM\s0\fR, \fB\s-1HH\s0.MM\fR,
250 or just \fB\s-1HH\s0\fR. You can suffix it with \fBam\fR or \fBpm\fR or use
251 24\-hours clock. Some special times of day are understood as well,
252 including \fBmidnight\fR (00:00), \fBnoon\fR (12:00) and British
253 \&\fBteatime\fR (16:00).
254 .PP
255 The \fIday\fR can be specified as \fImonth-name\fR \fIday-of-the-month\fR and
256 optional a 2\- or 4\-digit \fIyear\fR number (e.g. March 8 1999). Alternatively,
257 you can use \fIday-of-week-name\fR (e.g. Monday), or one of the words:
258 \&\fByesterday\fR, \fBtoday\fR, \fBtomorrow\fR. You can also specify the \fIday\fR as a
259 full date in several numerical formats, including \fBMM/DD/[\s-1YY\s0]YY\fR,
260 \&\fB\s-1DD\s0.MM.[\s-1YY\s0]YY\fR, or \fB\s-1YYYYMMDD\s0\fR.
261 .PP
262 \&\fI\s-1NOTE1\s0\fR: this is different from the original \fIat\fR\|(1) behavior, where a
263 single-number date is interpreted as MMDD[\s-1YY\s0]YY.
264 .PP
265 \&\fI\s-1NOTE2\s0\fR: if you specify the \fIday\fR in this way, the \fItime-of-day\fR is
266 \&\s-1REQUIRED\s0 as well.
267 .PP
268 Finally, you can use the words \fBnow\fR, \fBstart\fR, or \fBend\fR as your time
269 reference. \fBNow\fR refers to the current moment (and is also the default
270 time reference). \fBStart\fR (\fBend\fR) can be used to specify a time
271 relative to the start (end) time for those tools that use these
272 categories (\fBrrdfetch\fR, rrdgraph).
273 .PP
274 Month and day of the week names can be used in their naturally
275 abbreviated form (e.g., Dec for December, Sun for Sunday, etc.). The
276 words \fBnow\fR, \fBstart\fR, \fBend\fR can be abbreviated as \fBn\fR, \fBs\fR, \fBe\fR.
277 .SS "\s-1TIME\s0 \s-1OFFSET\s0 \s-1SPECIFICATION\s0"
278 .IX Subsection "TIME OFFSET SPECIFICATION"
279 The time offset specification is used to add/subtract certain time
280 intervals to/from the time reference moment. It consists of a \fIsign\fR
281 (\fB+\fR\ or\ \fB\-\fR) and an \fIamount\fR. The following time units can be
282 used to specify the \fIamount\fR: \fByears\fR, \fBmonths\fR, \fBweeks\fR, \fBdays\fR,
283 \&\fBhours\fR, \fBminutes\fR, or \fBseconds\fR. These units can be used in
284 singular or plural form, and abbreviated naturally or to a single
285 letter (e.g. +3days, \-1wk, \-3y). Several time units can be combined
286 (e.g., \-5mon1w2d) or concatenated (e.g., \-5h45min = \-5h\-45min =
287 \&\-6h+15min = \-7h+1h30m\-15min, etc.)
288 .PP
289 \&\fI\s-1NOTE3\s0\fR: If you specify time offset in days, weeks, months, or years,
290 you will end with the time offset that may vary depending on your time
291 reference, because all those time units have no single well defined
292 time interval value (1\ year contains either 365 or 366 days, 1\ month
293 is 28 to 31 days long, and even 1\ day may be not equal to 24 hours
294 twice a year, when DST-related clock adjustments take place).
295 To cope with this, when you use days, weeks, months, or years
296 as your time offset units your time reference date is adjusted
297 accordingly without too much further effort to ensure anything
298 about it (in the hope that \fImktime\fR\|(3) will take care of this later).
299 This may lead to some surprising (or even invalid!) results,
300 e.g. 'May\ 31\ \-1month' = 'Apr\ 31' (meaningless) = 'May\ 1'
301 (after \fImktime\fR\|(3) normalization); in the \s-1EET\s0 timezone
302 \&'3:30am Mar 29 1999 \-1 day' yields '3:30am Mar 28 1999' (Sunday)
303 which is an invalid time/date combination (because of 3am \-> 4am \s-1DST\s0
304 forward clock adjustment, see the below example).
305 .PP
306 In contrast, hours, minutes, and seconds are well defined time
307 intervals, and these are guaranteed to always produce time offsets
308 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
309 clock adjustment that occurs around 3:00\ Mar\ 28\ 1999, the actual
310 time interval between 8:00\ Mar\ 27\ 1999 and 8:00\ Mar\ 29\ 1999
311 equals 47 hours; on the other hand, '8:00\ Mar\ 27\ 1999\ +48\ hours' =
312 \&'9:00\ Mar\ 29\ 1999', as expected)
313 .PP
314 \&\fI\s-1NOTE4\s0\fR: The single-letter abbreviation for both \fBmonths\fR and \fBminutes\fR
315 is \fBm\fR. To disambiguate them, the parser tries to read your mind\ :)
316 by applying the following two heuristics:
317 .IP "1." 3
318 If \fBm\fR is used in context of (i.e. right after the) years,
319 months, weeks, or days it is assumed to mean \fBmonths\fR, while
320 in the context of hours, minutes, and seconds it means minutes.
321 (e.g., in \-1y6m or +3w1m \fBm\fR is interpreted as \fBmonths\fR, while in
322 \&\-3h20m or +5s2m \fBm\fR the parser decides for \fBminutes\fR).
323 .IP "2." 3
324 Out of context (i.e. right after the \fB+\fR or \fB\-\fR sign) the
325 meaning of \fBm\fR is guessed from the number it directly follows.
326 Currently, if the number's absolute value is below 25 it is assumed
327 that \fBm\fR means \fBmonths\fR, otherwise it is treated as \fBminutes\fR.
328 (e.g., \-25m == \-25 minutes, while +24m == +24 months)
329 .PP
330 \&\fIFinal \s-1NOTES\s0\fR: Time specification is case-insensitive.
331 Whitespace can be inserted freely or omitted altogether.
332 There are, however, cases when whitespace is required
333 (e.g., 'midnight\ Thu'). In this case you should either quote the
334 whole phrase to prevent it from being taken apart by your shell or use
335 \&'_' (underscore) or ',' (comma) which also count as whitespace
336 (e.g., midnight_Thu or midnight,Thu).
337 .SS "\s-1TIME\s0 \s-1SPECIFICATION\s0 \s-1EXAMPLES\s0"
338 .IX Subsection "TIME SPECIFICATION EXAMPLES"
339 \&\fIOct 12\fR \*(-- October 12 this year
340 .PP
341 \&\fI\-1month\fR or \fI\-1m\fR \*(-- current time of day, only a month before
342 (may yield surprises, see \s-1NOTE3\s0 above).
343 .PP
344 \&\fInoon yesterday \-3hours\fR \*(-- yesterday morning; can also be specified
345 as \fI9am\-1day\fR.
346 .PP
347 \&\fI23:59 31.12.1999\fR \*(-- 1 minute to the year 2000.
348 .PP
349 \&\fI12/31/99 11:59pm\fR \*(-- 1 minute to the year 2000 for imperialists.
350 .PP
351 \&\fI12am 01/01/01\fR \*(-- start of the new millennium
352 .PP
353 \&\fIend\-3weeks\fR or \fIe\-3w\fR \*(-- 3 weeks before end time
354 (may be used as start time specification).
355 .PP
356 \&\fIstart+6hours\fR or \fIs+6h\fR \*(-- 6 hours after start time
357 (may be used as end time specification).
358 .PP
359 \&\fI931225537\fR \*(-- 18:45  July 5th, 1999
360 (yes, seconds since 1970 are valid as well).
361 .PP
362 \&\fI19970703 12:45\fR \*(-- 12:45  July 3th, 1997
363 (my favorite, and its even got an \s-1ISO\s0 number (8601)).
364 .SH "AUTHOR"
365 .IX Header "AUTHOR"
366 Tobias Oetiker <tobi@oetiker.ch>