Code

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